Pages: [1] 2   Go Down
Author Topic: Xbee Andrew Rapp Xbee Library GetAdress  (Read 1259 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ahhhh i forgot the ().... Sorry
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48556
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

....
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm i tried:

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

But no reliable result :/
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3972
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The following works for me, with Series2 XBees.

Code:
   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);
Logged

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

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The following works for me, with Series2 XBees.

Code:
   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?
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3972
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-lol
Logged

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

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-lol

hmm okay smiley

but i cant read the special command i need for getting the adress of the remote unit  smiley-sad smiley-sad smiley-sad and im stressed smiley-grin

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

it must be possible :/
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

YAY!!!!!!!

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

 smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3972
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

YAY!!!!!!!

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

 smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool smiley-cool

Way to go!  smiley-grin
Logged

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

Pages: [1] 2   Go Up
Jump to: