The rcm:Message class encapsulates a single message in the RCM protocol.
Apart from the payload, each message has the following properties:
- source address (short or UID)
- destination address (short, UID, group or broadcast)
- source endpoint (see Endpoints)
- destination endpoint (see Endpoints)
- radius (maximum number of network hops the message can travel)
- ack mode (message requires acknowledgment or not)
In addition, received messages also carry information about:
- link quality indicator (LQI)
- received signal strength indicator (RSSI)
Preparing and sending outgoing messages.
The default rcm::Message constructor provides a single, general-purpose, uninitialized message.
The rcm:Message class provides three methods of initializing messages in order to prepare them to be sent. These methods differ depending on the type of destination address used:
- the rcm::Message::initOutgoingUsingShortAddr method initializes an outgoing message where the destination node is specified using short (16-bit) network address (unicast message)
- the rcm::Message::initOutgoingUsingUID method initializes an outgoing message where the destination node is specified using 64-bit UID (unicast message)
- the rcm::Message::initOutgoingUsingBroadcast method initializes an outgoing broadcast message (to all nodes)
The following example illustrates all three methods of sending messages:
There are basically two methods of receiving messages:
- polling the endpoint
- installing a message filter in the endpoint
The basic method is polling the rcm::Endpoint object for new messages using rcm::Endpoint::getPendingMessage method. In addition, the rcm::Endpoint::getPendingMessagesCount returns the number of messages awaiting in the reception queue.
The following example illustrates the endpoint polling:
Another method is installing message filter. See Message filters for details.
Both of these methods can also be combined. All messages that do not get filtered will be stored in the endpoint reception queue and can be received using endpoint polling. Note however, that combining two approaches may affect code clarity.
Generated on Thu Feb 22 2018 13:14:54 for RCM API C++ Library by 22.214.171.124