I combined the ZigBee socket examples in the Digi Python Programming Guide, as shown below, in and attempt to ‘sendto’ and ‘recvfrom’ the same (DESTINATION) endpoint device.
import sys
from socket import *
DESTINATION=(‘00:13:a2:00:40:31:a6:99!’,0xe8, 0xc105, 0x11)
sd = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT)
sd.bind((‘’, 0xe8, 0, 0))
sd.sendto(‘Hello World >’, 0, DESTINATION)
Wait for a frame retruned from the endpoint
Block until timeout or a single frame is received
try:
sd.settimeout(10.0)
payload, src_addr = sd.recvfrom(72)
print payload, src_addr
# Send the payload back to the source
sd.sendto(payload, 0, src_addr)
except Exception:
print ‘socket timed out before receiving a frame’
sys.exit()
Two issue arise and I am asking for help in solving them:
1 If I have more then one end device how can I force the socket to wait for a frame from a specific end device (i.e. DESTINATION)? That is, I have an LT sensor and an RS232 (the DESTINATION) module both at 0xe8 endpoint. If the LT sensor is active it responds to the ‘recvfrom’ . I want to ‘recvfrom’ the RS232 module only.
2 With the LT sensor inactive I can ‘rscvfrom’ the RS232 modeule however the ‘frame’ is only 1 char long even though I am sending a longer message. For testing proosed I have the RS232 moduel connected to HyperTerminal
Any help will be greatly apprciated.