Joining an Existing Network

Before a router or end device can join a ZigBee network, it must locate a nearby coordinator or another router that has already joined to join through it.

Router Joining a Network

If a router has not joined a network, it performs a PAN scan in all the channels specified in the list 'Scan Channels', looking for a coordinator or router operating with a valid PAN ID that is allowing joins. The router must find a device that meets the following parameters:

• The \'operating 64-bit PAN ID' of the device is valid depending on the router 'PAN ID'. If router 'PAN ID' is set to zero, any value will be valid. If not, it will be the same to be a valid value. • The discovered device is allowing joins. Parameter 'Node Join Time' has not expired. • The discovered device is operating in one of 'Scan Channels' channels. • The discovered device is operating with the same ZigBee stack profile. • The security police is the same in both devices.

If a device is discovered during the PAN scan and meets all the above requirements, the joining device will send a join request to the device and attempt to join the PAN. If the joining device receives a join response, then the device is considered joined to the PAN.

The status of the last PAN scan and join attempt is recorded into the 'Association Indication' parameter.

Examples

• Router joins known network:

https://development.libelium.com/waspmote/zb-02a-router-joins-known-network

• Router joins unknown network:

https://development.libelium.com/waspmote/zb-02b-router-joins-unknown-network

End Device Joining a Network

If an End Device has not joined a network, it performs a PAN scan in all the channels specified in the list 'Scan Channels', looking for a coordinator or router operating in a valid PAN ID that is allowing joins. The End Device must find a device that meets the following parameters:

• The 'operating 64-bit PAN ID' of the device is valid depending on the End Device\'s 'PAN ID'. If End Device\'s 'PAN ID' is set to zero, any value will be valid. If not, it will be the same to be a valid value. • The discovered device is allowing joins. Parameter 'Node Join Time' has not expired. • The discovered device has room for at least one more node. 'Number of Remaining Children' parameter. • The discovered device is operating in one of 'Scan Channels' channels. • The discovered device is operating with the same ZigBee stack profile. • The security police is the same in both devices.

If a device is discovered during the PAN scan meets all the above requirements, the joining device will send a join request to the device and attempt to join the PAN. If the joining device receives a join response, then the device is considered joined to the PAN.

The status of the last PAN scan and join attempt is recorded into the ' Association Indication' parameter.

Router / End Device Wake Up from Reset Process

Once a router or end device has joined a PAN ID and channel, it retains that information through power cycle or reset events. When the router or end device wakes up from a reset or power cycle, it checks its operating channel and PAN ID against the network configuration commands 'Scan Channels' and 'Extended PAN ID'. It also verifies the applied security policy against the security configuration. If device's operating channel, PAN ID, or security policy does not match the configuration commands, it will leave its current channel and PAN ID and attempt to join a new network based on its 'Scan Channels', 'Extended PAN ID' and security parameter values.

Channel Verification

Channel verification behaviour is supported for both routers and end devices through the 'Channel Verification' parameter. If channel verification is enabled, routers will communicate with the coordinator and end devices will monitor their communications with their parent to determine if they are on a valid channel.

Router Channel Verification

When a router wakes up from a power cycle, if 'Channel Verification' is enabled, the router will send a 64-bit address discovery transmission to the coordinator to discover its 64-bit address. If the coordinator does not respond after 3 request attempts, the router will leave the current network and attempt to join a new network based on its network configuration parameters.

End Device Channel Verification

If 'Channel Verification' is enabled, the end device tracks the status of its poll requests with its parent. If the end device's parent does not send an acknowledgment for 3 consecutive poll requests, the end device will leave its current channel and PAN and attempt to join a network based on its network configuration parameters.

There are some parameters related to a joining a network process.

Association Indication

Specifies the status of the last PAN scan and join attempt of the module. Possible status are:

  • 0x00: Successful. Coordinator started or Router/End Device joined with a parent.

  • 0xAB: Attempted to join a device did not respond.

  • 0xAC: Secure join error. Network security key received unsecured.

  • 0xAD: Secure join error. Network security key not received.

  • 0xAF: Secure join error. Joining device does not have the right preconfigured link key.

  • 0x21: Scan found no PANs.

  • 0x22: Scan found no valid PANs based on current 'Scan Channels' and 'Extended PAN ID'.

  • 0x23: Valid Coordinator or Routers found, but they are not allowing joining.

  • 0x27: Node joining attempt failed.

  • 0x2A: Coordinator Start attempt failed.

  • 0xFF: Scanning for a parent.

  • 0x2B: Checking for an existing coordinator.

Example of use:

{
    xbeeZB.getAssociationIndication();
}

Related variables:

xbeeZB.associationIndication → stores the Association Indication Status

Number of Remaining Children

Specifies the number of End Devices that can join a coordinator or router. Its maximum value for Coordinators is 10 and 12 for a Router. When a Router joins, it does not count as a children, so as many routers as wanted can join a network.

Example of use:

{
    xbeeZB.getRemainingChildren();
}

Related variables:

xbeeZB.remainingChildren → stores the number of remaining children available

Channel Verification

Specifies if Channel Verification is enabled or disabled (JV parameter). If JV=1, a router will verify the coordinator is on its operating channel when joining or coming up from a power cycle. If a coordinator is not detected, the router will leave its current channel and attempt to join a new PAN. If JV=0, the router will continue operating on its current channel even if a coordinator is not detected.

Example of use:

{
    xbeeZB.setChannelVerification(1);
    xbeeZB.getChannelVerification();
}

Related variables:

xbeeZB.channelVerification → stores if Channel Verification is enabled or disabled

Join Notification

Specifies if a node should send a broadcast message when waking up or joining a network. This message is an identification message so as the other nodes can know if it is operating in the same network. It is recommended not to enable this parameter in big networks to prevent excessive broadcast messages.

Example of use:

{
    xbeeZB.setJoinNotification(1);
    xbeeZB.getJoinNotification();
}

Related variables:

xbeeZB.joinNotification → stores if Join Notification is enabled or disabled

Node Discovery

Discovery nodes function is used to discover and to report all modules of its current operating channel and PAN ID.

Structure used in Discovery

A structure called "Node" has been created to store the reported information by other nodes, a structure called 'Node' has been created. This structure has the next fields:

struct Node

{
    uint8_t MY[2];
    uint8_t SH[4];
    uint8_t SL[4];
    char NI[20];
    uint8_t PMY[2];
    uint8_t DT;
    uint8_t ST;
    uint8_t PID[2];
    uint8_t MID[2];
    uint8_t RSSI;
};

MY: 16-bit Network Address of the reported module. SH[4] and SL[4]: 64-bit MAC Source Address of the reported module. NI: Node Identifier of the reported module • PMY: Parent 16-bit network address. It specifies the 16-bit network address of its parent. • DT: Device Type. It specifies if the node is a Coordinator, Router or End Device. • ST: Status. Reserved by xbeeZB. • PID: Profile ID. Profile ID used for application layer addressing. • MID: Manufacturer ID. ID set by the manufacturer to identify the module. • RSSI: Not returned in ZigBee.

To store the found brothers, an array called scannedBrothers has been created. It is an array of structures Node. To specify the maximum number of found brothers, it is defined a constant called MAX_BROTHERS. It is also a variable called totalScannedBrothers that indicates the number of brothers have been discovered. Using this variable as index in the scannedBrothers array, it will be possible to read the information about each node discovered.

Example of use:

{
    xbeeZB.scanNetwork();
}

Related variables:

xbeeZB.totalScannedBrothers → stores the number of discovered brothers

xbeeZB.scannedBrothers → Node structure array that stores the info

• Scan network example:

https://development.libelium.com/waspmote/zb-10-scan-network

Searching nodes

Another possibility to discover a node is searching a specific node. This search is based on using the Node Identifier. The NI of the node to discover is used as the input in the API function responsible of this search. 16-bit and 64-bit addresses of the searched node will be stored in the packet send as an input.

Example of use

{
    uint8_t mac[8];
    xbeeZB.nodeSearch("node01", mac);
}

Related variables:

mac[0-7] → Stores the 64-bit address of the searched node

• Search node example:

https://development.libelium.com/waspmote/zb-11a-node-search-tx

https://development.libelium.com/waspmote/zb-11b-node-search-rx

Node discovery to a specific node

When executing a Node Discovery all the nodes respond to it. If only one node is desired to respond, there is another possibility to find it. If its Node Identifier is known, a Node Discovery using its NI as an input can be executed.

Example of use

{
    xbeeZB.scanNetwork("node01");
}

Related variables:

xbeeZB.totalScannedBrothers → stores the number of discovered brothers. Must be '1'.

xbeeZB.scannedBrothers → Node structure array that stores the info

Node Discovery Time

Is the amount of time a node will wait for responses from other nodes when performing a ND. Range: 0x20 - 0xFF [x 100 msec]. Default: 0x3C.

Example of use:

{
    uint8_t time[2]={0x3C,0x00};// In ZigBee is only used first array position
    xbeeZB.setScanningTime(time); // Set Scanning Time in ND
    xbeeZB.getScanningTime(); // Get Scanning Time in ND
}

Available Information

xbeeZB.scanTime[0] → stores the time a node will wait for responses.

Node Discovery Options

Selects Node Discovery Options. Options available are:

• 0x01 : Append DD value to ND responses. • 0x02 : Local device sends ND response frame when ND is issued.

Example of use:

{
    xbeeZB.setDiscoveryOptions(0x01); // Set Discovery Options for ND
    xbeeZB.getDiscoveryOptions(); // Get Discovery Options for ND
}

Available Information

xbeeZB.discoveryOptions → stores the selected options for ND

If the Node Discovery Time is a long time, the API function may exit before receiving a response, but the module will wait for it, crashing the code. If this time is too short, it is possible the modules do not answer. After testing several times, the best values are 1-2 seconds for setting the API function properly.*

When a Node Discovery is performed, due to it is a broadcast message, it will only reach as many hops as the set in 'Broadcast Max Hops' parameter. So, setting that parameter, a Node Discovery may only reach nodes near or may reach the entire network.

It is recommended to try on the final scenario to find the best value for this parameter.

Last updated