API (Application Programming Interface) operating mode is an alternative to AT mode. API operating mode requires that communication with the device be done through a structured interface. In other words, data is communicated via API frames.
The API specifies how commands, command responses, and module status messages are sent and received from the device using the serial interface. With API operating mode, you can:
-
Configure the XBee device itself.
-
Configure remote devices in the network.
-
Manage data transmission to multiple destinations.
-
Receive success/failure status of each transmitted RF packet.
-
Identify the source address of each received packet.
Depending on the AP parameter value, the radio module can operate in one of two modes: API (AP = 1) or API escaped (AP = 2) operating mode.
API escaped operating mode
API escaped operating mode (AP = 2) is similar to API mode except that when working in API escaped mode, some bytes of the API frame specific data must be escaped. Since XBee Studio is compatible with both API and API escaped operating modes, you do not need to manually escape characters.
API escaped operating mode increases the reliability of RF transmission by preventing conflicts with special characters such as the start-of-frame byte (0x7E). API non-escaped (API=1) operation relies solely on the start delimiter and length bytes to differentiate API frames. In API escaped mode, on the other hand, those special bytes are escaped. Since 0x7E can only appear at the start of an API packet, a module can always "assume" that a new packet has started if 0x7E is received at any time while in API escaped mode.
Escape characters
When sending or receiving an API frame in API escaped mode, specific data values must be escaped (flagged) so they do not interfere with the data frame sequence.
To escape a data byte, insert 0x7D and follow it with the byte to be escaped XOR’d with 0x20. The data bytes that need to be escaped are as follows:
-
0x7E: Frame delimiter
-
0x7D: Escape
-
0x11: XON
-
0x13: XOFF
| XBee Studio automatically escapes the appropriate characters when interacting with devices configured in API escaped mode. |