السلام عليكم و رحمة الله
I have build my ZigBee networks containing 5 XBee Pro S2 as Router and one gateway CPX4 as Coordinator.
I choose the star topology because each xbee module will send a temperature value to the server through the gateway.
These XBee modules receive nothing from gateway.(modules---->gateway).
--->In the gateway:
*PAN ID: 0x4a59
*channel: 0xc
*scan all channels
---->In router XBee Pro 2:
*PAN ID: 4a59
*channel scan: 16
*DH, DL destination: 0
in script python
With this code i can find my network XBee the two modules and the gateway :
nodes = zigbee.getnodelist()
print 'Starting up...'
# Print the table:
print "%12s %12s %8s %24s" % \
("Label", "Type", "Short", "Extended")
print "%12s %12s %8s %24s" % \
("-" * 12, "-" * 12, "-" * 8, "-" * 24)
for node in nodes:
print "%12s %12s %8s %12s" % \
(node.label, node.type, \
node.addr_short, node.addr_extended)
I can implemented the protocol CSMA / CD (Carrier Sense Multiple Access / Collision Detection): the module xbee sent these doonnes when the channel is available?
How do I get the data from the 5 XBee?
from socket import *
# Create the socket, datagram mode, proprietary transport:
sd = socket(AF_XBEE, SOCK_DGRAM, XBS_PROT_TRANSPORT)
# Bind to endpoint 0xe8 (232) for ZB/DigiMesh, but 0x00 for 802.15.4
sd.bind(("", 0, 0, 0))
sd.settimeout(1)
# Block until a single frame is received, up to 255 bytes:
print "Waitting For New Packet"
#sd.recvfrom(packetSize)
payload, src_addr = sd.recvfrom(255)
print "payload"
print payload