During the Connect() process of an XBee device, the library automatically reads and saves basic identification data from the XBee device. The parameters read are saved in the corresponding properties of the XBee device object, allowing you to access them at any time:
| Parameter | Property |
|---|---|
64-bit address |
XBee64BitAddr |
16-bit address |
XBee16BitAddr |
Node Identifier |
NodeID |
Firmware version |
FirmwareVersion |
Hardware version |
HardwareVersion |
IPv4 address (only for Cellular devices) |
IPAddress |
IMEI (only for Cellular devices) |
IMEIAddress |
The Connect() process also determines the communication protocol of the XBee device object. This is typically something you need to know beforehand if you are not using the generic XBeeBLEDevice object. However, the API performs this operation to ensure that the class you instantiated is the correct one. So, if you instantiated a Zigbee device (XBeeZigbeeBLEDevice) and the Connect() process realizes that the physical device is actually a DigiMesh device, you receive an XBeeException indicating it.
The protocol of the device is saved in the XBeeProtocol property:
// Instantiate an XBee device object.
XBeeBLEDevice myXBeeBLEDevice = new XBeeBLEDevice("00:00:00:00:00:00", "password");
// Connect the device.
myXBeeBLEDevice.Connect();
// Get the device protocol.
XBeeProtocol xbeeProtocol = myXBeeBLEDevice.XBeeProtocol;
Refresh XBee device information
The XBee device object provides the method ReadDeviceInfo() to read and refresh the identification data of the XBee device at any time. The parameters read and saved by this method are the same ones that were read and saved during the Connect() process. Most of the parameters are not susceptible to change, but you can refresh them to ensure you have the latest values stored in the XBee device object.
| Method | Description |
|---|---|
ReadDeviceInfo() |
Reads and saves some parameters from the device and obtains its protocol. |
The ReadDeviceInfo() method may fail for the following reasons:
-
The device is not connected, throwing an InterfaceNotOpenException.
-
There is a timeout reading any of the identification parameters, throwing a TimeoutException.
-
Other errors caught as XBeeException.
// Instantiate an XBee device object.
XBeeBLEDevice myXBeeBLEDevice= new XBeeBLEDevice("00:00:00:00:00:00", "password");
// Connect the device.
myXBeeBLEDevice.Connect();
[...]
// Refresh the device information.
myXBeeBleDevice.ReadDeviceInfo();