Go Down

Topic: Xbee Andrew Rapp Xbee Library GetAdress (Read 1 time) previous topic - next topic

andy0087

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

andy0087

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

PaulS

Quote
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.

andy0087

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  :)

andy0087


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.

andy0087

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

    ....

andy0087


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());



andy0087

Hmm i tried:

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

But no reliable result :/

Jack Christensen

The following works for me, with Series2 XBees.

Code: [Select]
   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);
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

andy0087


The following works for me, with Series2 XBees.

Code: [Select]
   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?

Jack Christensen

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
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

andy0087


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 :)

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

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

it must be possible :/

andy0087

YAY!!!!!!!

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

8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)

Jack Christensen


YAY!!!!!!!

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

8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)


Way to go!  :D
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Go Up