Skip to content

Commit bc52cb4

Browse files
committed
Take a crack at adding README file
It's a bit incoherent, not surprising considering I did the bulk of the work on this software 4 years ago. I'm a bit rusty on it.
1 parent 5be9141 commit bc52cb4

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# XBee/ZigBee daemon
2+
3+
xbee-controller is a daemon to control a network of XBee/ZigBee radio devices
4+
through TCP/IP. The binary protocol is decoded into JSON messages.
5+
6+
# Synopsis
7+
8+
xbee-daemon.pl [-d /dev/ttyUSBx] [-v] listen_addr ...
9+
10+
-d /dev/ttyUSBx Connect to specified device
11+
-v Verbose
12+
13+
listen_addr: A set of one or more listening host:port pairs.
14+
ipv4: 0.0.0.0:7862
15+
ipv4: 127.0.0.1:7862
16+
ipv6: :::7862
17+
ipv6: [::]:7862
18+
19+
The daemon opens the specified device (/dev/ttyUSBx) which is expected to
20+
be an XBee radio modem such as these:
21+
22+
http://littlebirdelectronics.com.au/products/xbee-2mw-wire-antenna-series-2-zb
23+
http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/point-multipoint-rfmodules/xbee-series1-module#overview
24+
25+
with a USB interface, configured as a Coordinator and
26+
using the binary (API) protocol as opposed to the text-based AT protocol.
27+
28+
The daemon will listen on one or more specified host/port pairs. Any packets
29+
received on the XBee network will be decoded and transmitted in JSON format
30+
to all connected clients.
31+
32+
A connected client can send a JSON message to the server, and the server will
33+
transmit that packet out over the local XBee network.
34+
35+
# JSON message format
36+
37+
The JSON message for a packet received over the XBee network looks like this:
38+
39+
```json
40+
{"payload":{"data":"TMP1 T 28.00000269B9E9 01DE\r\n","options":1,"sender16":63874,"sender64_h":1286656,"sender64_l":1081049161,"type":144},"time_s":1416047469,"time_u":269406,"type":"receivePacket"}
41+
```
42+
43+
Let's go through the data structure item by item.
44+
45+
"type": "receivePacket", This message type. Others include: ATResponse, modemStatus, nodeIdentificationIndicator, ...
46+
"time_s": 1416047469, Time the message was received in seconds
47+
"time_u": 269406, Time the message was received, microseconds portion
48+
"payload": { The received message's contents
49+
50+
"data": "...", The received data frame
51+
"options": 1, XBee packet options
52+
"sender16": 63874, 16-bit sender address (in decimal)
53+
"sender64_h": 1286656, High-order 32 bits of the 64-bit sender address (in decimal),
54+
"sender64_l": 1081049161, Low-order 32 bits of the 64-bit sender address (in decimal),
55+
"type": 144 Frame type 0x90, "ZigBee Receive Packet"
56+
}
57+
58+
## Sending a packet over the XBee network
59+
60+
```json
61+
{"payload":{"data":"?\n","dest16":65534,"dest64_h":1286656,"dest64_l":1080068162,"frame_id":253,"options":0,"radius":0},"time_s":1416049321,"time_u":702500,"type":"transmitRequest"}
62+
```
63+
64+
Breaking down the data structure again:
65+
66+
"type": "transmitRequest", Request to transmit a frame
67+
"time_s": 1416049321, Seconds, as above (supplied by daemon)
68+
"time_u": 702500, Microseconds, as above (supplied by daemon)
69+
"payload": { The frame to be transmitted
70+
"data": "...", Data portion of the frame
71+
"dest16": 65534, 0xfffe means we don't know the short 16-bit destination device address
72+
"dest64_h": 1286656, 0x0013a200 the high-order 32 bits of the destination address
73+
"dest64_l": 1080068162, 0x40608842 the low-order 32 bits of the destination address
74+
"frame_id: 253, Frame sequence number (increment per frame sent)
75+
"options": 0, Transmit frame options
76+
"radius:" 0 How many hops are permitted
77+
}
78+
79+
A client sending a "transmitRequest" packet can expect a "transmitStatus" response
80+
with the `delivery_status` and `discovery_status` of the request. If the recipient node
81+
could be found then `remote_address` is provided, to be used as the `dest16` in
82+
future transmissions.
83+
84+
# Specifications
85+
86+
The ZigBee protocol is defined by Digi International Inc. There have been several variants
87+
of the XBee/ZigBee protocol implemented.
88+
89+
The documentation homepage is http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/point-multipoint-rfmodules/xbee-series1-module#docs
90+
91+
Where specification differences exist, this library implements the protocol in document
92+
90000976_G dated 11/15/2010.
93+
94+
The current specification looks like http://ftp1.digi.com/support/documentation/90000982_R.pdf
95+
96+
# Writing a client
97+
98+
See perldoc for module XBee::Client for this. The synopsis is:
99+
100+
```perl
101+
$xcl = XBee::Client->new($server_address);
102+
103+
$packet = $xcl->receivePacket($timeout);
104+
105+
if ($packet && $packet->isData()) {
106+
my $contents = $packet->data();
107+
}
108+
109+
Or
110+
111+
$packet = $xcl->readPacket();
112+
113+
if (! $packet) {
114+
$data_pending = $xcl->poll($timeout);
115+
116+
if ($data_pending) {
117+
$xcl->handleRead($xcl->socket());
118+
$packet = $xcl->readPacket();
119+
}
120+
}
121+
```

0 commit comments

Comments
 (0)