XBee socket: timeout of recvfrom(..)

Hey!

I’m just a beginner in Digi Products, Zigbee and Python.
What I’m doing is trying to set up a XBee net with the X4 gateway and two “Smart Energy Meter” (Pikkerton ZBS-110V2). I am already succesfully using a wallrouter and that light/temperature sensor thing.

The code is the following (I deleted all parts of the wiki example code i thought are not necessary for a simple test application)


import sys
import os
from socket import *
from select import *
"""
...
"""
    # Create the socket, datagram mode, proprietary transport:
sd = socket(AF_ZIGBEE, SOCK_DGRAM, ZBS_PROT_TRANSPORT)
    # Bind to endpoint 0xe8 (232) for ZB/DigiMesh, but 0x00 for 802.15.4
sd.bind(("", 0x8e, 0, 0))
    # Configure the socket for non-blocking operation:
sd.setblocking(1)
    # Initialize state variables:
erg = ""
src_addr=("[00:13:a2:00:40:76:7f:14]!",0xe8,0xc105,0x11)
    
#Sensor init
payload = ("SET TXT=10
","SET POW=OFF
","METER START
","METER RESET
")
for pl in payload:
    sd.sendto(pl,0,src_addr)
    print "sending ",pl
    time.sleep(1)

print "starting new Measurement..."
# Send to the socket:
sd.sendto("GET
", 0, src_addr)
# Receive from the socket:
try:
    sd.settimeout(10.0)
    erg, src_addr2 = sd.recvfrom(255)
except:
    print "timeout"

print erg

gc.collect()
sys.exit()

Sending commands to theplug works fine (I hear the sound of the Power On/Off Relais) but the recvfrom function just hangs until timeout occures.

Does anyone know what the fault is? (i know blocking version is not the ‘pretty’ one)

I’m waiting for answers [;)]

Does the Pikkerton return a protocol response? Is the DH/DL set correctly in the Pikkerton?

I changed

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

to

sd.bind(src_addr)

it seems to work now!