rtpavlovsk21 / python-xbee

Automatically exported from code.google.com/p/python-xbee
MIT License
0 stars 0 forks source link

How do I get the original node identifier? #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I understand this forum is for bugs, but I don't know how else to ask 
questions. I recently saw lady-ada's watcher and she used this man's XBee-API.

http://www.ladyada.net/media/wattcher/xbee.py

Is this API built into your python-xbee package? if not, could this be added? 
Because right now, I have an output from by XBees where I can see their 
options, data, and some odds and ends but it would help if I could also get to 
see the origin node identifier, RSSI, etc.

Original issue reported on code.google.com by ronthecon on 14 Jun 2012 at 8:17

GoogleCodeExporter commented 9 years ago
Unfortunately no, the library no longer supports the old API, and I do not plan 
to re-instate it.

As it turns out, this is the very same project as the one you linked; 
python-xbee originally began from the code you linked as written by Amit 
Synderman.

I led a complete rework of the library about two years ago, which brought it to 
its approximate current form. The goal was to make the codebase cleaner, easier 
to use, and to more completely support the XBee API.

The new implementation of the API for IEEE 802.15.4 XBees (i.e. Series 1) is 
quite complete; everything you mentioned should be there. Here is a listing of 
all of the packets we currently support: 
http://code.google.com/p/python-xbee/source/browse/xbee/ieee.py.

The basic idea is that information coming back from the new library will be a 
dictionary containing the information listed on that page for each packet type. 
For example, a "rx" packet containing data the attached device recently 
received over the air would look like the following dictionary:

{"id":"rx",
 "source_addr": <two byte address of the source radio>,
 "rssi": <one byte RSSI>,
 "options": <one byte for tx options flags>,
 "rf_data": <n number of received data bytes>
}

Take a look at some of the examples 
(http://code.google.com/p/python-xbee/source/browse/#hg%2Fexamples) to get a 
better feel for how to use the new version of the library.

Does this help answer your question?

Original comment by pmalms...@gmail.com on 14 Jun 2012 at 8:49

GoogleCodeExporter commented 9 years ago
I think so. So I just look at the source_addr? 

My output:
{'reserved': b'\xfe\x02', 'options': b'R', 'frame_id': b'\x00', 'source_addr': 
b'\x13\xa2\x00@h\xcfF\xff', 'data': 
b'\x01#\x00VxOceanWasp03,x:12,y:-492,z:945,bat:91%\r\n', 'id': 'rx_long_addr'}

So my source_addr is not my Node Identifier but it is the Mac Address of my 
XBee. It's not the full mac address because it's missing numbers in the middle 
and at the end. The end is supposed to be \x46 not \xff. I just put the node 
identifier in the data string so I know it's coming from OceanWasp03. 

Original comment by ronthecon on 19 Jun 2012 at 6:33

GoogleCodeExporter commented 9 years ago
Oops, I misinterpreted Node Identifier. Unfortunately, XBee API responses do 
not include a Node Identifier, and only include the physical address of the 
sender as you mentioned. 

As you demonstrate, sending the Node Identifier along with data works. You 
could also consider using a dictionary to map from source address to Node 
Identifier, and do a lookup there whenever you receive something.

Original comment by pmalms...@gmail.com on 20 Jun 2012 at 12:53

GoogleCodeExporter commented 9 years ago

Original comment by pmalms...@gmail.com on 14 Apr 2013 at 7:00