What I’m trying to do is use the ConnectPortX gateway to set up a network with two additional endpoints. I simply want to discover the two devices and send them an 8 bit command.
I’m looking through the zb_ex4_disc.py and zb_ex2_rw.py example files and trying to make sense of their code so I can manipulate it to suit my demo application.
I understand most of ex4_disc, in that it simply gives me a two variable array with the nodes and its respective data. The print part is helpful but the list is really what I need.
So I assume that at this point I have enough information to send out data, I have the short and long addresses for my zigbee radios. So moving on to ex2_rw, and the stuff I don’t completely understand; sockets. I was trying to read some basic stuff about Python and sockets but it was a bit over my head with TCP/UDP and that or it wasn’t transparent/evident enough what the code was doing. Now, first the code creates a socket:
sd = socket(‘’,‘’,‘’)
Now I would assume I have to do this for each endpoint:
ep1= socket(‘’,‘’,‘’)
ep2= socket(‘’,‘’,‘’)
Now comes the part that I don’t get
sd.bind((“”,0xe8,0,0))
I haven’t really figured out what relevance ‘bind’ has, does it send the end address 0xe8 to the socket I’ve created? So that in my code it would be something like:
ep1.bind((“”,ep1_short_address,0,0))?
The last part of the example code is:
sd.sendto(data, 0, src_addr)
Now data will obviously be my 8 bit code, the 0 is for non-blocking but the problem I have is with src_addr. When looking at the Digi Python handbook I see that the command sendto() the tuple addr format is (addr_string, endpoint, profile_id, cluster_id) and the node class itself contains: type, addr_extend, addr_short, addr_parent,profile_id,manufact_id,label) so my question would be, can I pass just addr_short to it or should I pass everything it wants? Something like:
ep1.sendto(8bit,0,0x34)?
Or should I set up a ep1_addr = [node.addr_string,0x34,node.profile_id,node.cluster_id]
and call ep1.sendto(8bit,0,ep1_addr) ?
Thanks in advance.
Mike