Sending ZDO LQI request command from python

Hi,
I have been trying to get a neighbor table from a router.
To my understanding I need to do this by sending a ZDO LQI request. The API
frame looks like following according to the manual (pg. 51, which has a breakdown
description of the LQI API frame )
7E 0016 11 01 0013A200 40401234 FFFE 00 00 0031 0000 00 00 76 00 CE

Is there a way to send this API frame to the coordinator/router through Python running on the embedded system gateway?

I tried creating a socket and binding it to the remote router with the cluster ID = 0x0031, profile ID=0x0000 and end Points=0x0000. It doesn’t seem like I am on the right track.

Also, does anyone have a Xbee Serial Driver for DIA.

I moved this to the Dia forum since you’re asking specifically for a serial driver in Dia.

You’re on the right track. On the gateway your are going to want to bind to the local ZDP endpoint and create a ZDO request to a remote node.

To bind to endpoint 0 you will:

sd = socket(AF_ZIGBEE, SOCK_DGRAM, XBS_PROT_APS)
sd.bind(('', 0, 0, 0))

Next you will format your request:

transaction_id = 0
idx = 0
req = struct.pack('BB', transaction_id, idx)
# send to remote node, src endpoint 0, profile 0,
# using cluster 0x0031
daddr = ('00:13:a2:00:40:40:12:34!', 0, 0, 0x0031)
sd.sendto(req, 0, daddr)

Then you will be able to receive your message:

buf, addr = sd.recvfrom(128)

Finally, you can unpack the ZCL reply using struct.unpack()

I hope this helps you!

Jordan

Regarding a Dia serial driver … a more complete one is coming in a few months, but I have attached a very simple “send” and “receive” only version which sends serial data over Xbee. To talk serially on X2/X4/X8’s serial port would be different

Jordan;

In the example you gave canyou expalin what is:

transaction_id = 0
idx = 0

What is being requested here?

Thnaks

Jordan:
Thanks! for the code. It worked just fine. For some reason I always get 255 as the LQI value. I tried moving around one of the end nodes to see if the LQI value changes but it only decreased by 2. Following is the LQI response I got. You can notice that the LQI value is FF for all three nodes.

I thought LQI was supposed to be more accurate than RSSI. Correct me if i am wrong.

00 00 03 00 03
00 01 00 00 00 00 00 00 70 63 32 40 00 A2 13 00 00 00 34 02 00 FF
00 01 00 00 00 00 00 00 66 A5 2D 40 00 A2 13 00 E7 7E 12 00 01 FF
00 01 00 00 00 00 00 00 B8 08 0A 40 00 A2 13 00 54 96 12 00 01 FF

Lynn: Thanks for the serial driver. I will try to run this driver in Dia to get the serial data pushed up by arduino via zigbee.

LQI takes in many components into its calculation, one of which is RSSI.

LQI is used as the primary component to maintain the mesh routing table. You may find that the number is hard to effect if you truly do have good links between the nodes. How far/what actions did you take to try and manipulate the LQI values?

Jordan

I took the end node so far that it went out of the range and couldn’t be discovered. I tried to create RF signal obstacles by standing in between the end node and the router. For some reason this made the end node undiscoverable. I also tried putting it inside a metal container :). I had a coordinator, a router and two end nodes and a in my zigbee network.

I had a loop that continuously printed the Neighbour table of the router and the LQI for each node in the neighbour table list. I actually noticed the LQI decreased to 253 from 255 but that is not very helpful for me to determine the signal quality.

I wonder if having more nodes in a network or a big depth is going to change the LQI. The only thing I can think of is somehow saturating the network and see if LQI changes. Just a though…

I am in need of the complete python code to read LQI vlaues from wall router and RS232 sensor node from connectport X4 gateway coordinator . Need help > Thanks

hmmm this maybe a very late post, but for those out there who could find the code handy and may want to know the answer to rubout’s question:

In the example you gave canyou expalin what is: transaction_id = 0
idx = 0
refer to document here first: Supporting ZDOs with the XBee API
At Page 15: Lookout for the line in blue fonts and you’ll find its equivalent representation, Transaction sequence number == transaction_id
On Page 10: Lookout for the line in blue fonts and you’ll find its equivalent representation, Start Index == idx

The doc will explain how to use the ZDO provided on most ZB radio chips and how to use it on Digi’s ZB radio.

If the admin is reading this, can somebody from Digi update the document? It’s dated Oct, 3rd, 2008 on the last document update…