Binding Multiple Zigbee sockets

Hey i am trying to send and receive data on my Xbee network as a result of which i need to bind to the same socket. I am not able to.
http://www.digi.com/wiki/developer/index.php/Binding_multiple_zigbee_sockets
Any idea what the 'locking mechanism" here means ?

Hi,

Try the code at following link:

http://www.digi.com/wiki/developer/index.php/TCP_to_Zigbee_Dynamic_Name_Mapping

I tried running that code but in the infinite loop none of the if conditions get satisfied and hence it does not work. Do i need to change anything in the code ?

I don’t understand what you mean - to both RX and TX you need to bind to the same socket? Socket don’t live ‘out there’. What you are trying to do is create TWO sockets which shar the same lower-level hooks. That doesn’t work.

You bind once, and have a single socket which you can either read or write to. If you want 2 different programs (or threads) to share a socket … they cannot. You’ll need to make 1 program ask hread the master, then use Queue objects to pass messages between the two.

I ll tell you exactly what I am tring to do. When I am sending data from my Xbee, it creates the socket and binds to it. Now from another system, I want to receive this data on my connectport. To receive this data I have to bind to the same socket. If this cannot be done, how do i proceed ?

Okay, then you are still only binding on 1 socket each - the fact that you have 2 different systems means each has 1
bind only. It works fine (if done correctly).

Look at this page instead of the other:
http://www.digi.com/wiki/developer/index.php/ZigBee_Extensions_to_the_Python_socket_API

So this works fine on the sending system:
DESTINATION=(“00:0d:6f:00:00:06:89:29!”, 0xe8, 0xc105, 0x11)
sd = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT)
sd.bind((“”, 0xe8, 0, 0))
sd.sendto(“Hello, World!”, 0, DESTINATION)

And the receiving system would be:
sd = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT)
sd.bind((“”, 0xe8, 0, 0))
payload, src_addr = sd.recvfrom(255)

I ll give you a bigger picture. I have 1 Xbee module from which i want to send data wirelessly to a connectport located somewhere else. I have my dynamic c code to which is getting the data from my machine to the Xbee module. Cant you list the exact steps i need to follow from here to complete this task.

PS - I am stuck on this problem since ages

The interaction between nodes in your case is like a UDP Server and UDP Client interaction. (You can read more if you have the time)
For your case, your connectport (CP) will act like a ZB-Server (hence binding); your remote node (ZB-Client) however won’t need to bind. All you need to do, is just send the data from an origin endpoint to the server’s binded endpoint… is really that simple

If you are talking abt UDP server and client…
My Xbee module is programmed in Dynamic C and the Connectport in Python. So will the code for sending be in Dynamic C and the code for receiving be in Python ??
I am really new to this so can you please also give me a small sample code that I can try ?

My Xbee module is programmed in Dynamic C and the Connectport in Python. So will the code for sending be in Dynamic C and the code for receiving be in Python ??
Yes is the answer to your quoted question

Lynn has already pointed out how you could complete it by reading this page thoroughly http://www.digi.com/wiki/developer/index.php/ZigBee_Extensions_to_the_Python_socket_API
At the bottom of the link, you’ll find 3 simplest sample script for you to test it out on your python machine. I can’t help you out on the Dynamic C part though… The process and steps are clearly stated at that link.
You should go through that page thoroughly, lynn is one of the main contributors there…
Also to learn more of zigbee endpoints, read here instead: http://forums.digi.com/support/forum/viewthread_thread,807#3011

I also do not know how to explain Dyn-C - not my job nor skillset.

I’d suggest you try the easier step of teaching yourself UDP by Python (and C) between 2 PC - there are many perfect online examples of UDP client and server.

Once you understand how to do it between 2 PC, it should be a managable to apply your knowledge to XBee+DynC to XBee+X4+Python