
API Operation
Data bytes that need to be escaped:
XBee/XBee-PRO® S2C ZigBee® RF Module
154
Byte(s)
Description
7E
Start delimeter
00 0A
Length bytes
01
API identifier
01
API frame ID
50 01
Destination address low
00
Option byte
48 65 6C 6C 6F
Data packet
B8
Checksum
To calculate the check sum you add all bytes of the packet, excluding the frame delimiter
7E
and the
length (the second and third bytes).
7E 00 0A 01 01 50 01 00 48 65 6C 6C 6F B8
Add these hex bytes:
01 + 01 + 50 + 01 + 00 + 48 + 65 + 6C + 6C + 6F = 247
Now take the result of 0x247 and keep only the lowest 8 bits which in this example is 0x47 (the two
far right digits). Subtract 0x47 from 0xFF and you get 0xB8 (0xFF - 0x47 = 0xB8). 0xB8 is the checksum
for this data packet.
If an API data packet is composed with an incorrect checksum, the XBee/XBee-PRO ZigBee RF Module
will consider the packet invalid and will ignore the data.
To verify the check sum of an API packet add all bytes including the checksum (do not include the
delimiter and length) and if correct, the last two far right digits of the sum will equal FF.
01 + 01 + 50 + 01 + 00 + 48 + 65 + 6C + 6C + 6F + B8 = 2FF
API examples
Example
: Create an API AT command frame to configure a device to allow joining (set
NJ
to 0xFF).
The frame should look like:
0x7E 0x00 0x05 0x08 0x01 0x4E 0x4A 0xFF 5F
Where
n
0x0005 = length
n
0x08 = AT Command API frame type
n
0x01 = Frame ID (set to non-zero value)
n
0x4E4A = AT Command (
NJ
)
n
0xFF = value to set command to
n
0x5F = Checksum
The checksum is calculated as [0xFF - (0x08 + 0x01 + 0x4E + 0x4A + 0xFF)]
Example
: Send an
ND
command to discover the devices in the PAN.
The frame should look like:
0x7E 0x00 0x04 0x08 0x01 0x4E 0x44 0x64
Where:
Содержание XBee
Страница 1: ...XBee XBee PRO S2C ZigBee RF Module User Guide ...
Страница 259: ...AT commands Execution commands XBee XBee PRO S2C ZigBee RF Module 259 Parameter range N A Default N A ...
Страница 289: ...Regulatory information ANATEL Brazil XBee XBee PRO S2C ZigBee RF Module 289 ...
Страница 290: ...Regulatory information ANATEL Brazil XBee XBee PRO S2C ZigBee RF Module 290 ...
Страница 303: ...Load ZigBee firmware on 802 15 4 devices Background 304 Load ZB firmware 305 XBee XBee PRO S2C ZigBee RF Module 303 ...