14.2.3.2.2 Using parameters influencing network start

Certain CS parameters are used to achieve an appropriate form of network start. This helps choose a proper network by predefining the network PANID or set either static or stochastic addressing scheme, etc.

Choosing device type

In addition to the CS_DEVICE_TYPE parameter which specifies the type of a device according to Zigbee specification, another parameter, called CS_RX_ON_WHEN_IDLE should be taken into consideration to determine the device type. CS_RX_ON_WHEN_IDLE indicates whether the radio is turned on permanently. Therefore on routers and the coordinator its value must always be true. If parameter's value is false which must happen on end devices only, the radio is turned on to transmit data only and to wait for response from a parent for a certain short period of time. Besides, being set to false the parameter enables polling mechanism allowing sleeping end devices to receive deferred messages stored by its parent while the end device slept. For that reason, on sleeping end devices CS_RX_ON_WHEN_IDLE shall be set to false.

For example, suppose that the device type is to be specified at run-time, then a typical way to configure a sleeping end device is as follows:

//Prepare variablesDeviceType_t deviceType = DEVICE_TYPE_END_DEVICE;
bool rxOnWhenIdle = false;

//Set parameters CS_WriteParameter(CS_DEVICE_TYPE_ID,&deviceType);
CS_WriteParameter(CS_RX_ON_WHEN_IDLE_ID, &rxOnWhenIdle);

Handling the network PANID

There are two identifier for the network: extended PANID and short (also called network) PANID. The first taking 64-bit values is the main idetifier, while a 16-bit value for the second in most cases is generated randomly and is used in frame headers instead of the extended PANID to reduce overhead. The extended PANID is predefined with the CS_EXT_PANID parameter causing the coordinator to form a network with the PANID equal to this parameter and other nodes to join the network with the PANID equal to this parameter. If a router or an end device specifies 0x0 for CS_EXT_PANID, then it will join the first suitable network.

The short PANID can also be predefined on the coordinator, for example, when it has to be reset and restore connection to the same network after is powers on. In this case CS_NWK_PREDEFINED_PANID shall be set to 1. The parameters can be configured either in compile or run time. The following example shows the latter case:

//Prepare variables 
bool predefPANID = true;
uint16_t nwkPANID = CPU_TO_LE16(0x1111); //Set to 16-bit value converted to little endian format
CS_WriteParameter(CS_NWK_PREDEFINED_PANID_ID,&predefPANID); //Indicate that the PANID is predefined
CS_WriteParameter(CS_NWK_PANID_ID, &nwkPANID); //Set the PANID value

Stochastic and static addressing

The user can choose between stochastic and static addressing schemes to address nodes in the network by setting the CS_NWK_UNIQUE_ADDR parameter to 0 or 1, respectively. Addressing scheme determines the method used for assigning a short (network) address for the device in the following way: in stochastic scheme a short address is chosen by the stack automatically during network start different from all existing addresses in the network, while in static addressing the value provided by the CS_NWK_ADDR parameter is used. In the latter case it is up to the user to ensure that all addresses assigned to nodes in the network are unique.