API Operation
API escaped operating mode works similarly to API mode. The only difference is that when working in
API escaped mode, the software must escape any payload bytes that match API frame specific data,
such as the start-of-frame byte (0x7E). The following table shows the structure of an API frame with
escaped characters:
Frame fields
Byte Description
Start delimiter 1
Length
2 - 3
Frame data
4 - n API-specific structure
Checksum
n + 1 1 byte
Start delimiter field
This field indicates the beginning of a frame. It is always 0x7E. This allows the device to easily detect a
new incoming frame.
Escaped characters in API frames
If operating in API mode with escaped characters (AP parameter = 2), when sending or receiving a
serial 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 (XORed with 0x20).
The following data bytes need to be escaped:
0x7E: start delimiter
n
0x7D: escape character
n
0x11: XON
n
0x13: XOFF
n
To escape a character:
1. Insert 0x7D (escape character).
2. Append it with the byte you want to escape, XORed with 0x20.
In API mode with escaped characters, the length field does not include any escape characters in the
frame and the firmware calculates the checksum with non-escaped data.
Example: escape an API frame
To express the following API non-escaped frame in API operating mode with escaped characters:
Start delimiter Length Frame type
7E
00 0F 17
You must escape the 0x13 byte:
1. Insert a 0x7D.
2. XOR byte 0x13 with 0x20: 13 ⊕ 20 = 33
The following figure shows the resulting frame. Note that the length and checksum are the same as
the non-escaped frame.
Digi XBee® 3 Zigbee® RF Module
0x7E
Most Significant Byte, Least Significant Byte
Frame Data
Data
01 00 13 A2 00 40 AD 14 2E FF FE 02 4E 49 6D
API frame format
Characters escaped if needed
Checksum
238
Need help?
Do you have a question about the XBee 3 ZigBee and is the answer not in the manual?