Docs

You are here:
Configuring RCM radio module

RCM module configuration

Having a working RCM connection (see Initializing and running the connection) allows us now to communicate with a RCM radio module and set it up for network operation. At this stage we usually need to configure the basic properties of the module that allow it to communicate across the RCM network. We will discuss them now.

Device unique identifier (UID)

The RCM protocol is based on IEEE 802.15.4 PHY and MAC layers, that define the addressing used to deliver messages across the network. Both of these standards relay on a concept of a 64-bit globally unique identifier (also called EUI-64) that unambiguously identifies a node. The RCM radio module hardware may have the EUI-64 built-in, however if it doesn't or if we want to enforce a different one, we can use the RCM_SetUID function to set it up. The complementary RCM_GetUID call can read the currently set UID from the device.

Network identifier (PANID), network role and network address

Each RCM network is identified by unique 64-bit identifier called Personal Area Network ID (PAN ID). A node that wants to join a network can choose the network identifier it want's to connect to. Each RCM device can be given one of three roles: coordinator, router or end device. The coordinator is the node that starts and maintains the network. Routers are nodes that can route (relay) packets, while end devices can only communicate with coordinators or routers and do not have the routing capability. In addition to role, every node in the network is given a short 16-bit network address. This address can be set manually or picked up randomly by the RCM communication stack.

The RCM_SetConfiguration function shall be used to deliver information about PAN ID, role and addressing mode to the RCM radio module. A complementary RCM_GetConfiguration function can be used to read back these settings.

Security settings

In order to enable message encryption, the RCM_EnableSecurity function should be called, that also sets up a 128-bit network key that is used to cipher the messages. All nodes that wish to communicate within a secured network must provide the same network key. Security settings affect the maximum number of bytes that can fit into a single RCM message packet. In order to determinte how many bytes can fit into a single RCM packet with the current settings, the RCM_GetMaxPayloadSize function can be used.

Output power

In order to control the output power of the RCM radio module, the RCM_SetOutputPower and RCM_GetOutputPower functions can be used.

An example of RCM module configuration

The following example illustrates the concepts that we have learned so far:

#include "rcm.h"
// Structure holding information about the connection
static RCMConnection rcm;
// Declare a structure named frameBuffer, that will fit infinite SCOM packets
static SCOM_DECLARE_FRAME_BUFFER_USING_HEAP(frameBufferInHeap);
// Declare a structure named messageBufferInHeap that can fit unlimited number of RCM messages
static RCM_DECLARE_MESSAGE_BUFFER_USING_HEAP(messageBufferInHeap);
int rcm_config_example(IODevice iodevice)
{
int result = 0;
OSTime startTime;
// get current time
startTime = OS_GetSystemTime();
// try to open the connection using specified IODevice
if (RCM_RESULT_OK == RCM_Open(&rcm, iodevice, &frameBufferInHeap, &messageBufferInHeap, OS_GetSystemTime)) {
// connection opened, run it
if (RCM_RESULT_OK == RCM_Run(&rcm)) {
// threads run successfully
// configure the RCM module
RCM_SetUID(&rcm, 0x0123456789abcdef);
while (0 == result) {
// ... do something with the RCM module (read on!)
// check connection
if (RCM_RESULT_OK != RCM_GetConnectionState(&rcm)) {
// connection broke down (hardware error?)
// exit with error code
result = 2;
}
// check timeout
if (OS_GetSystemTime() - startTime > 5000) {
// timeout
break;
}
OS_Sleep(2000);
}
// stop the RCM threads
RCM_Stop(&rcm);
} else {
// error
result = 2;
}
// finally close the connection
RCM_Close(&rcm);
} else {
// error
result = 1;
}
return result;
}
Go to Top