I’m running my first tests with the ConnectPort X2 gateway and our ATMega8-controlled XBee2. On the micro side, I am sending single bytes to the UART (and hence XBee). On the gateway side though, using a tweaked version of Digi’s zigbee_test.py, the arriving payloads are 20 bytes long. Here’s the gateway code:
This example binds to application endpoint 0xe8,
receives a single frame at this endpoint, and
displays the source address and payload
include the sockets module into the namespace:
from socket import *
Create the socket, datagram mode, proprietary transport:
sd = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT)
Bind to endpoint 0xe8 (234):
sd.bind((“”, 0xe8, 0, 0))
Block until a single frame is received, up to 72 bytes:
payload, src_addr = sd.recvfrom(72)
print "src_addr: ", src_addr
print “len(payload): %d” % len(payload)
for index, byte in enumerate(payload):
print “payload[%d] = %s (%d)” % (index, hex(ord(byte)), ord(byte))
and here’s what I see as output:
#> python zigbee_test.py
src_addr: (‘[00:13:a2:00:40:0a:23:98]!’, 232, 49413, 149)
len(payload): 20
payload[0] = 0x8e (142)
payload[1] = 0x47 (71)
payload[2] = 0x0 (0)
payload[3] = 0x13 (19)
payload[4] = 0xa2 (162)
payload[5] = 0x0 (0)
payload[6] = 0x40 (64)
payload[7] = 0xa (10)
payload[8] = 0x23 (35)
payload[9] = 0x98 (152)
payload[10] = 0x20 (32)
payload[11] = 0x0 (0)
payload[12] = 0xff (255)
payload[13] = 0xfe (254)
payload[14] = 0x1 (1)
payload[15] = 0x2 (2)
payload[16] = 0xc1 (193)
payload[17] = 0x5 (5)
payload[18] = 0x10 (16)
payload[19] = 0x1e (30)
Newbie Questions:
-
Why is the source address showing up in the payload?
-
More generally, why 20 bytes? What is the structure of this data? Is the so-called payload actually the full Zigbee protocol frame? (I doubt it)
-
What is special about 72 for the socket recvfrom? Is this the maximum data length?
We’re looking forward to getting this working. Any help is much appreciated.