Python xbee node to_socket_addr() method returning too many/zero-value fields

Hi,

Trying to make some sense of why I’m not able to communicate with devices.

(This is after disabling xbgw_main.py so I can muck around in the REPL.)

>>> n

>>> n.profile_id
49413
>>> n.to_socket_addr()
(‘[00:13:a2:00:41:b4:c8:e0]!’, 0, 0, 0, 0, 0, 0)

When I try to use this address tuple in sendto, socket complains that there are too many args (there are 7 instead of 6).

But more visibly, none of the endpoint/profile/whatever fields are populated-- yet they exist as attributes on the node object itself.

Is this method completely broken? Or am I doing something wrong?

Thanks!

You look to be doing this wrong.
It should be more like:

xbee_sd.sendto(“Hello, World!”, 0, (‘[00:13:a2:00:40:0a:07:a5]!’, 0xe8, 0xc105, 0x11, 0, 0x42))

1 Like

Turns out I was doing it wrong after all.

That method requires additional args but does not complain if they are not provided.

endpoint=0xe8
profile_id=49413
cluster_id=0x11
nodes = xbee.get_node_list()
node = n = nodes[1]

# --- here's where i went wrong ---
addr = n.to_socket_addr(endpoint, profile_id, cluster_id)[:-1]
# --- end of incompetence ---

sd = socket(AF_XBEE, SOCK_DGRAM, XBS_PROT_TRANSPORT)
sd.bind(('', endpoint, profile_id, cluster_id))
cmd = 
sd.sendto(cmd, 0, addr)