API mode in detail
API mode provides a structured interface where data is communicated through the serial interface in organized packets and in a determined order. This enables you to establish complex communication between devices without having to define your own protocol.
By default, XBee devices are configured to work in transparent mode: all data received through the serial input is queued up for radio transmission and data received wirelessly is sent to the serial output exactly as it is received, with no additional information.
Because of this behavior, devices working in Transparent mode have some limitations:
- To read or write the configuration of an device in Transparent mode, you must first transition the device into Command mode.
- If a device needs to transmit messages to different devices, you must update its configuration to establish a new destination. The device must enter Command mode to set up the destination.
- A device operating in Transparent mode cannot identify the source of a wireless message it receives. If it needs to distinguish between data coming from different devices, the sending devices must include extra information known by all the devices so it can be extracted later. To do this, you must define a robust protocol that includes all the information you think you need in your transmissions.
To minimize the limitations of the transparent mode, devices provide an alternative mode called Application Programming Interface (API). API mode provides a structured interface where data is communicated through the serial interface in organized packets and in a determined order. This enables you to establish complex communication between modules without having to define your own protocol.
API mode provides a much easier way to perform the actions listed above:
- Since there are different frames for different purposes (such as configuration and communication), you can configure a device without entering Command mode.
- Since the data destination is included as part of the API frame structure, you can use API mode to transmit messages to multiple devices.
- The API frame includes the source of the message so it is easy to identify where data is coming from.
Advantages of API mode
- Configure local and remote XBee devices in the network.
- Manage wireless data transmission to one or multiple destinations.
- Identify the source address of each received packet.
- Receive success/failure status of each transmitted packet.
- Obtain the signal strength of any received packet.
- Perform advanced network management and diagnosis.
- Perform advanced functions such as remote firmware update, ZDO, ZCL and so on.