Map27
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
Map27Address Class Reference

Class for handling Map27 Prefix/Ident/Address. More...

#include <Map27/Address.h>

Public Member Functions

 Map27Address ()
 
void setPrefix (uint8_t prefix=MAP27_ADDRESS_DUMMYP)
 
uint8_t prefix () const
 
void setIdent (uint16_t ident=MAP27_ADDRESS_DUMMYI)
 
uint16_t ident () const
 
void setAddress (uint8_t adesc=MAP27_ADDRESS_ADESC_NO_ADDRESS, uint8_t *address=0, uint8_t alen=0)
 
uint8_t adesc () const
 
uint8_t alen () const
 
const uint8_t * address () const
 
uint8_t decodeBasic (uint8_t *buf, uint16_t bufLen)
 
uint8_t decode (uint8_t *buf, uint16_t bufLen)
 
uint8_t encodeBasic (uint8_t *buf, uint16_t bufLen) const
 
uint8_t encode (uint8_t *buf, uint16_t bufLen) const
 
uint16_t mpt1343_prefix () const
 
uint16_t mpt1343_fin (uint16_t ibi) const
 
uint16_t mpt1343_un3d (uint16_t ibi) const
 
uint16_t mpt1343_un2d (uint16_t ibi) const
 
const char * asString ()
 

Detailed Description

Class for handling Map27 Prefix/Ident/Address.

This class provides methods to hold and encapsulate Map27 Prefix, Ident and optional extra Address representations, as well as functions for encoding and decoding them into on-the-wire message formats.

A Map27Address always has a MPT1327 Prefix and Ident. It can also have an optional Address which can be used for specifying PABX number etc.

Some Map27 messages only contain the Prefix and Ident and no Address. We call these 'Basic' and there are separate methods for encoding and decoding them, which ignore the Address component.

Examples:
test.cpp, test2.cpp, and test3.cpp.

Constructor & Destructor Documentation

Map27Address::Map27Address ( )

Constructor. Prefix defaults to MAP27_ADDRESS_DUMMYP. Ident defaults to MAP27_ADDRESS_DUMMYI. Address defaults to MAP27_ADDRESS_NO_ADDRESS.

Member Function Documentation

const uint8_t * Map27Address::address ( ) const

Get a pointer to the current address Caution, this is internal storage and may not be overwritten. The number of valid address bytes can be got with alen()

Returns
Pointer to the internal storage of the current Address
Examples:
test.cpp.
uint8_t Map27Address::adesc ( ) const

Get the current Address type

Returns
the current Addres type, one of MAP27_ADDRESS_ADESC_*
Examples:
test.cpp.
uint8_t Map27Address::alen ( ) const

Get the current address length

Returns
The current Address length in bytes
Examples:
test.cpp.
const char * Map27Address::asString ( )

Formats the address as a string and returns a pointer to temporary storage containing the string

Returns
Pointer to formatted string in private storage
Examples:
test3.cpp.
uint8_t Map27Address::decode ( uint8_t *  buf,
uint16_t  bufLen 
)

Decode Prefix, Ident amnd Address from on-the-wire format.

Parameters
[in]bufPointer to the buffer containing the on-the-wire encoded Prefix, Ident and Address
[in]bufLenLength of buf in bytes
Returns
The number of bytes decoded. Normally 4 or more. Returns 0 on failure (ie buffer not long enough to contain a valid Address).
Examples:
test.cpp.
uint8_t Map27Address::decodeBasic ( uint8_t *  buf,
uint16_t  bufLen 
)

Decode Prefix and Ident (but not Address) from on-the-wire format. Sets the internal Prefix and Ident. Sets the address type to MAP27_ADDRESS_DESC_NO_ADDRESS and the Address length to 0

Parameters
[in]bufPointer to the buffer containing the on-the-wire encoded Prefix and Ident
[in]bufLenLength of buf in bytes
Returns
The number of bytes decoded. Normally 3. Returns 0 on failure (ie buffer not long enough to contain a Prefix and Ident).
Examples:
test.cpp.
uint8_t Map27Address::encode ( uint8_t *  buf,
uint16_t  bufLen 
) const

Encode Prefix, Ident and Address in on-the-wire format to a buffer

Parameters
[in]bufThe buffer where the encoded data is to be written
[in]bufLenLength of available spacec in buf in bytes
Returns
The number of bytes written to buf. 0 on failure (such as insufficient space in buf)
Examples:
test.cpp.
uint8_t Map27Address::encodeBasic ( uint8_t *  buf,
uint16_t  bufLen 
) const

Encode Prefix and Ident (but not Address) in on-the-wire format to a buffer

Parameters
[in]bufThe buffer where the encoded data is to be written
[in]bufLenLength of available spacec in buf in bytes
Returns
The number of bytes written to buf. 0 on failure (such as insufficient space in buf)
Examples:
test.cpp.
uint16_t Map27Address::ident ( ) const

Get the current MPT1327 Unit Ident (UI) return The current MPT1327 Unit Ident (UI)

Examples:
test.cpp.
uint16_t Map27Address::mpt1343_fin ( uint16_t  ibi) const

Convert the given Individual Base Ident to Fleet Individual Number

Parameters
[in]ibiMPT1327 Individual Base Ident
Returns
MPT1343 Fleet Individual Number
Examples:
test.cpp.
uint16_t Map27Address::mpt1343_prefix ( ) const

Get the current prefix in MPT1343 form

Returns
The current prefix in MPT1343 form
Examples:
test.cpp.
uint16_t Map27Address::mpt1343_un2d ( uint16_t  ibi) const

Convert the current MPT1327 Ident and IBI to MPT1343 Unit Number 2 Digit (UN2D)

Parameters
[in]ibiMPT1327 Individual Base Ident
Returns
MPT1343 Unit Number 2 Digit
uint16_t Map27Address::mpt1343_un3d ( uint16_t  ibi) const

Convert the current MPT1327 Ident and IBI to MPT1343 Unit Number 3 Digit (UN3D)

Parameters
[in]ibiMPT1327 Individual Base Ident
Returns
MPT1343 Unit Number 3 Digit
Examples:
test.cpp.
uint8_t Map27Address::prefix ( ) const

Get the current MPT1327 prefix

Returns
The current MPT1327 prefix
Examples:
test.cpp.
void Map27Address::setAddress ( uint8_t  adesc = MAP27_ADDRESS_ADESC_NO_ADDRESS,
uint8_t *  address = 0,
uint8_t  alen = 0 
)

Set the current optional Address An address includes the addres type (adesc), an a number of bytes of address information Map27Address takes care of the encoding of the Address in message rypes that require it

Parameters
[in]adescAddress type. One of MAP27_ADDRESS_ADESC_*
[in]addressArray of encoded address bytes.
[in]alenNumber of bytes in address
Examples:
test.cpp.
void Map27Address::setIdent ( uint16_t  ident = MAP27_ADDRESS_DUMMYI)

Set the MPT1327 Unit Ident (UI)

Parameters
[in]identThe Ident to set
Examples:
test.cpp, and test2.cpp.
void Map27Address::setPrefix ( uint8_t  prefix = MAP27_ADDRESS_DUMMYP)

Set the MPT1327 prefix

Parameters
[in]prefixThe Prefix to set
Examples:
test.cpp, and test2.cpp.

The documentation for this class was generated from the following files: