Digi Connectport X4H and Waspmote (libelium)

Hi All,
I’m trying to make a ZB WSN with libelium (Waspmote)
and i needed a gateway so i purchased The Connectport X4H

for 2 months now i tried to make a lot of programs to connect the Waspmote to the Connectport but i faced a a lot of problems and need some help on how to fix them [:-/]

but in the other hand i finally made the system work but there are some problem faced me

First about iDigi Cloud:

Is there a way to remote monitor the python terminal (telnet) to see what is the state of the programs running?

Second about the ZB With Waspmote:

my ZB Program is Looking Like that:

sd.bind(("", 0xe8, 0, 0)) 

while True:
    print "%50s" % ("-"*50) 
    print "Waitting For New Packet"
    payload, src_addr = sd.recvfrom(255) 
    print "RX Frame"  
    print sd.recvfrom(255)   
    print "Decoding Message to Payload"
    print payload
    print "Source Address"
    print src_addr
    if payload [12] == "7":
        sd.sendto(Z, 0, src_addr)
        sd.sendto(Z, 0, src_addr)   

About that code i must send the Packet 2 times to RX the payload
I made many print lines to track the code and i found that after the first packet it pass the [payload, src_addr = sd.recvfrom(255)] then it wait in [print sd.recvfrom(255)]
i tried to remove this line [print sd.recvfrom(255)] it just hanged in the next one [print payload]. [:(]

In waspmote it give me ACK that the gateway RX the Packets.

And The Same Problem when i try to send a payload to the Waspmote i must send the packet 2 times [:-/]

Is there a way to fix this to just TX&RX from the First Packet?

Third About the Gateway ZB:

Some times multiple of nodes send packets at the same time and all the nodes make ACK that the gateway RX the packets but when i use [payload, src_addr = sd.recvfrom(255)] to RX the packets.
what i see is the latest packet only?

Where are the other Packets and how to see them and decode them?

Fourth About Formatting the Packet to send it to Waspmote:

Is there any way to format the packet as The API of Libelium as they need special type of formatting?


Thanks in Advance

I can only guess - if the Libelium a sleeping end-device? if so, then look at this wiki page: http://www.digi.com/wiki/developer/index.php/XBee_Sleeping_Problems

Your problem “first message is lost and second works” sounds like the X4’s SN/Sp are too low which means the “child” (assuming the Libelium sleeps) has been discarded so the first data is lost and it must manually reassociate each time it wakes.

Thanks For the Reply lynnl;
But I made sure that the devices don’t sleep
as i disabled all sleeping on X-CTU for all models
and the gateway never sleeps so why i must send it 2 TX to pass the sd.recvfrom(255)

That was handy, my question already answered. Cheers.

I’m newbie on this and I’m working at the same topic could you give me some help please.
thanks in advance