Hardware Reference
In-Depth Information
Table 5-2. ( continued )
Frame Name
Frame Type
Description
Frame Data
Node identification
0x95
Packet used when replying to a
ND command not always seen
through the serial.
Source address: 8 bytes
Source network address: 2 bytes
Options: 1 byte
1-wire sensor: 1 byte
A/D values: 8 bytes
Temperature read: 1 byte
Modem status
0x8A
Module status packet.
Status message: 1 byte
Route record
indicator
0xA1
Used when requesting route
records command not always
seen through the serial.
Source address: 8 bytes
Source network address: 2 bytes
Options: 1 byte
Number of addresses: 1 byte
Address set: 2-byte variable sets
Many to one route
request indicator
0xA3
Seen by modules when a
many-to-one route has been
received.
Source address: 8 bytes
Source network address: 2 bytes
Options: 1 byte
Reserved: 1 byte
Over the air firmware
update status
0xA0
Status of remote firmware
update.
Source address: 8 bytes
Source network address: 2 bytes
Options: 1 byte
Boot loader message: 1 byte
Block number: 1 byte
Target address: 8 bytes
Arduino Data Echo
With a bit of understanding of the formation and reading of packets, this example will demonstrate in code the
phrasing, retransmission, and construction of packets the code receives. The code will run on the Arduino and take
incoming data packets ( 0x90 ) from any module in the network and pull the data out to reassemble the packet and
retransmit back to the original source.
While the packet gets transmitted to the source, the code will print relative data to a serial monitor, such as a
notification when an incoming packet has been received, the raw packet itself, addresses of the originating source,
and the raw reply packet for sending. The code currently identifies and displays two different packets types ( 0x90 ) and
( 0x8B ). This is accomplished through a switch statement after the whole packet has been captured.
The switch statement is pretty effective and can be expanded to recognize and handle current packet types plus
any future additions. The packets are received and constructed in a byte array of 80 bytes, which is done to buffer the
packets and to help ensure they're complete before any phrasing is done or transmission starts. Although the XBee
modules are capable of sending packets of greater sizes, this limit is to save on some space on the Arduino.
The setup is the same as in Figure 5-3 , previously. The code uses software serial at 9600 baud and standard serial
at 57600 baud; the XBee modules have to be reconfigured to 9600 baud. There are two ways to reconfigure the baud
settings:
Use the X-CTU software to set the baud back to setting 3.
AT command packets: one for the remote module and the other for
the local module. The AT command is BD or 0x42 44 , with the parameter being 3.
Construct and issue two
 
 
Search WWH ::




Custom Search