Node discovery
XBee modules provide some features for discovering and searching nodes.

Structure used in discovery

Discovering nodes is used to discover and report all modules on its current operating channel and PAN ID.
To store the reported information by other nodes, a structure called Node has been created.
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 (always 0xFFFE)
  • 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 (always 0xFFFE)
  • DT: Device Type. It specifies if the node is a Coordinator (0), Router (1) or End Device (2)
  • ST: Status (Reserved)
  • PID: Profile ID. Profile ID used to application layer addressing
  • MID: Manufacturer ID. ID set by the manufacturer to identify the module
  • RSSI: RSSI of last hop (disabled in XBee 900HP by default)
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:
{
xbee900HP.scanNetwork();
}
Related variables:
xbee900HP.totalScannedBrothers → stores the number of discovered brothers
xbee900HP.scannedBrothers → Node structure array that stores the info
Scan network example:

Searching specific nodes

Another possibility for discovering a node is searching for a specific one. 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 purpose.
The Node Identifier can be set calling the setNodeIdentifier() function:
{
xbee900HP.setNodeIdentifier(\"node01\");
}
Searching a specific node is done by the nodeSearch() function. It is necessary to indicate the Node Identifier to search and the buffer where the MAC address is stored.
Example of use:
{
uint8_t mac[8];
xbee900HP.nodeSearch("node01", mac);
}
Related variables:
mac[0-7] → Stores the 64-bit address of the searched node
Node search example:

Node discovery to a specific node

When executing a Node Discovery all the nodes respond to it. If its Node Identifier is known, a Node Discovery using its NI as an input can be executed.
Example of use:
{
xbee900HP.scanNetwork("node01");
}
Related variables:
xbee900HP.totalScannedBrothers → stores the number of discovered brothers. Must be '1'.
xbee900HP.scannedBrothersNode structure array that stores the info

Node discovery time

It is the amount of time a node will wait for responses from other nodes when performing a ND.
Parameter range: From 0x0020 to 0x2EE0 [x100 ms].
Default value: 0x0082.
Example of use:
{
uint8_t time[2] = { 0x00, 0x82 };
xbee900HP.setScanningTime(time);
xbee900HP.getScanningTime();
}
Available Information:
xbee900HP.scanTime[0-1] → stores the time a node will wait for responses.