
API Operation
API frame format
XBee/XBee-PRO® S2C ZigBee® RF Module
151
API frame format
The firmware supports two API operating modes: without escaped characters and with escaped
characters. Use the AP command to enable either mode. To configure a device to one of these modes,
set the following AP parameter values:
n
AP
= 1: API operation.
n
AP
= 2: API operation (with escaped characters—only possible on UART).
The API data frame structure differs depending on what mode you choose.
API operation (AP parameter = 1)
The following table shows the data frame structure when you enable
AP
= 1:
Frame fields
Byte
Description
Start delimiter
1
0x7E
Length
2 - 3
Most Significant Byte, Least Significant Byte
Frame data
4 - n
API-specific structure
Checksum
n + 1
1 byte
The firmware silently discards any data it receives prior to the start delimiter. If the device does not
receive the frame correctly or if the checksum fails, the device replies with a device status frame
indicating the nature of the failure.
API operation-with escaped characters (AP parameter = 2)
This mode is only available on the UART, not on the SPI serial port. The following table shows the data
frame structure when you enable
AP
= 2:
Frame fields
Byte Description
Start delimiter 1
0x7E
Length
2 - 3
Most Significant Byte, Least Significant Byte
Characters escaped if needed
Frame data
4 - n
API-specific structure
Checksum
n + 1 1 byte
Escape characters
When you are sending or receiving a UART data frame, specific data values must be escaped (flagged)
so they do not interfere with the data frame sequencing. To escape an interfering data byte, insert
0x7D and follow it with the byte to be escaped XOR’d with 0x20.