Xbee Andrew Rapp Xbee Library GetAdress

Hello Forum,

i succeed with talking of 2 XBees in API Mode with the use of the Andrew Rapp Library.

I would like that the base station sees the adressat of a received packet -

Has somebody come thorugh with that issue?

There are for example some classes:

Public Member Functions
XBeeAddress64 (uint32_t msb, uint32_t lsb)
uint32_t getMsb ()
uint32_t getLsb ()
void setMsb (uint32_t msb)
void setLsb (uint32_t lsb)
Detailed Description
Represents a 64-bit XBee Address.

Somebody an idea?

Greetings Andy

Notice: here we set the adress of a device, but this doesnt make use? (generally)...

Somebody an idea?

The usual one. Post your code. Describe what works and what doesn't. If you are looking for help on using those functions, say that. The seem pretty obvious, though. Each XBee has a DH (the most significant byte) and a DL (the least significant byte) address. Those functions get or set both or one or the other values.

Okay here we go:

#include <XBee.h>

XBee xbee = XBee();
ZBRxResponse zbRx = ZBRxResponse();

void setup () {
delay(1000);
xbee.begin(9600);
Serial.println(“starting up yo!”);
}

void loop () {

// 1. This will read any data that is available:
xbee.readPacket();

// 2. Now, to check if a packet was received:
if (xbee.getResponse().isAvailable()) {
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
xbee.getResponse().getZBRxResponse(zbRx);

for (int i = 0; i < zbRx.getDataLength(); i++) {
Serial.print(“payload [”);
Serial.print(i, DEC);
Serial.print("] is “);
Serial.print(zbRx.getData(i));
Serial.println(”");
}
Serial.print(XBeeAddress64.getMsb());
}
}
}

Serial.print(XBeeAddress64.getMsb()); : Error Message → Empf_ngereinheitsketch:28: error: expected primary-expression before ‘.’ token

Thanks for fast reply PaulS :slight_smile:

Ahhhh i forgot the ().... Sorry

Those methods are members of the XBee class. They need to be called on an instance of the class, just like all the other members you are using.

But the MSB isnt constant. So it is not the thing i need :confused:
It says:
payload [1] is 8
payload [2] is 0
503448064payload [0] is 11
payload [1] is 8
payload [2] is 0
503473154payload [0] is 11
payload [1] is 8
payload [2] is 0
3407873payload [0] is 11
payload [1] is 8
payload [2] is 0
33634817payload [0] is 11
payload [1] is 8
payload [2] is 0
55payload [0] is 11
payload [1] is 8
payload [2] is 0
53payload [0] is 11
payload [1] is 8
payload [2] is 0
352321536payload [0] is 11
payload [1] is 8
payload [2] is 0
7682

....

PaulS:
Those methods are members of the XBee class. They need to be called on an instance of the class, just like all the other members you are using.

hmm Empf_ngereinheitsketch:28: error: 'class XBee' has no member named 'XBeeAddress64'

after: Serial.print(xbee.XBeeAddress64().getMsb());

Hmm i tried:

Serial.println(XBeeAddress64().getLsb(), HEX);
Serial.println("");

But no reliable result :confused:

The following works for me, with Series2 XBees.

    XBee xbee = XBee();                                       //XBee object
    ZBRxResponse rx = ZBRxResponse();                         //XBee receive response
    ZBTxRequest zbTx;                                         //XBee transmit request
    ...

    xbee.getResponse().getZBRxResponse(rx);                   //get the received data
    ...
    zbTx.setAddress64(rx.getRemoteAddress64());               //reply to sender
    zbTx.setAddress16(0xFFFE);
    zbTx.setPayload(...);
    zbTx.setPayloadLength(...);
    xbee.send(zbTx);

You use this code for the sending device do you?

Actually both devices send and receive. That code is from a data logging node that receives data from several sensor nodes. Logically it's a star network, data-flow-wise, but of course a mesh network at the physical level with the XBees XD

hmm okay :slight_smile:

but i cant read the special command i need for getting the adress of the remote unit :frowning: :frowning: :frowning: and im stressed :smiley:

need something like serial.read( getadress() );

it must be possible :confused:

YAY!!!!!!!

Serial.print(zbRx.getRemoteAddress64().getMsb(),HEX);

andy0087:
YAY!!!!!!!

Serial.print(zbRx.getRemoteAddress64().getMsb(),HEX);

Way to go! :smiley:

Serial.print(zbRx.getRemoteAddress64().getMsb(),HEX);

How come you only care about the most significant bit? Usually that’s the same for all XBees on a network. It is the least significant bit that is unique. Unless you configured your XBees in an unusual way.

PaulS is right, you just have to change the "getMsb()" by "getLsb()".