Digi International Inc XB3C1 Manual Do Utilizador

Página de 146
Operate in API mode
API frame format
Digi XBee3 Cellular LTE Cat 1 Smart Modem User Guide
122
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
Frame Data
Checksum
Data
7E
00 0F 17
01 00 13 A2 00 40 AD 14 2E FF FE 02 4E 49 6D
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.
Start delimiter Length Frame type
Frame Data
Checksum
Data
7E
00 0F 17
01 00 7D 33 A2 00 40 AD 14 2E FF FE 02 4E 49 6D
The length field has a two-byte value that specifies the number of bytes in the frame data field. It does
not include the checksum field.
Length field
The length field is a two-byte value that specifies the number of bytes contained in the frame data
field. It does not include the checksum field.
Frame data
This field contains the information that a device receives or will transmit. The structure of frame data
depends on the purpose of the API frame:
Length
Frame data
Data
1
2
3
4
5
6
7
8
9
...
n
n+1
0x7E
MSB
LSB
Data
n
Frame type is the API frame type identifier. It determines the type of API frame and indicates
how the Data field organizes the information.
n
Data contains the data itself. This information and its order depend on the what type of frame
that the Frame type field defines.
Multi-byte values are sent big-endian.