best way to access packet?

44 views
Skip to first unread message

Paul Keyes

unread,
Apr 16, 2012, 2:00:16 PM4/16/12
to xbee-api
Hi All,

I'm working on a project in which I have multiple remote xbee radios
(attached to arduinos, using the axbee arduino library) all
communicating with a single computer using the java xbee api. I have
two questions:

1. When the computer receives a response (response =
xbee.getResponse();), is there a way to easily get the MY address of
the sending radio?

2. What is the best way to access the payload in the received
packet? I am currently doing this:
receivedPacket = response.getProcessedPacketBytes();
PayloadByte0 = receivedPacket[receivedPacket.length-3];
...because I have found by reading the logs and by trial and error
that the payload byte 0 ends up at that position in the receivedPacket
array... but it seems like there should be a better way?

Thanks so much,
Paul

Andrew Rapp

unread,
Apr 20, 2012, 9:52:38 AM4/20/12
to xbee...@googlegroups.com
It depends on the type of the response.  You didn't mention if you are using series 1 or 2 -- many of the packets are different. The payload is accessed by getData, but you need to cast XBeeResponse to the proper subclass. The remote address is generally getRemoteAddress.  Take a look at the developer's guide, javadoc and the examples in the download.


--
You received this message because you are subscribed to the Google Groups "xbee-api" group.
To post to this group, send email to xbee...@googlegroups.com.
To unsubscribe from this group, send email to xbee-api+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xbee-api?hl=en.


Reply all
Reply to author
Forward
0 new messages