#include <XBee.h> // zbTx;ZBRxResponse rx = ZBRxResponse();...zbTx.setAddress64(rx.getRemoteAddress64()); //return to senderzbTx.setAddress16(0xFFFE);
Looking for a way to read an XBee Address or ID using an Arduino so that I can uniquely identify where a string is originating from without having to have a separate program installed on each Arduino.
Thanks. I have started looking at the API. However, since I am sending from an Arduino to a Connectport X2, I can't have arduino code running on the Connectport (ZB Coordinator) to return the senders address.I need to find a way to get the address from within the local board. Does that make sense?
I set a unique NI in each XBee, then the program interrogates it and inserts it into the transmitted data.
#include <XBee.h> // xbee = XBee(); //XBee objectvoid getXBeeNI(void) { union {byte B; char C;} atCmd[3]; AtCommandRequest atCmdReq; strcpy(&atCmd[0].C, "NI"); atCmdReq = AtCommandRequest(&atCmd[0].B); xbee.send(atCmdReq);}void readXBee(void) { AtCommandResponse atResp; union {byte B; char C;} xbeeNI[9]; //XBee node identifier byte respLen, *resp; xbee.readPacket(); if (xbee.getResponse().isAvailable()) { //incoming traffic switch (xbee.getResponse().getApiId()) { //what kind of packet did we get? case ZB_RX_RESPONSE: //rx data packet ... case ZB_TX_STATUS_RESPONSE: //tx status ... case AT_COMMAND_RESPONSE: //response to AT commands atResp = AtCommandResponse(); xbee.getResponse().getAtCommandResponse(atResp); if (atResp.isOk()) { respLen = atResp.getValueLength(); resp = atResp.getValue(); for (int i=0; i<respLen; i++) { xbeeNI[i].B = resp[i]; } xbeeNI[respLen].B = '\0'; Serial.print(millis(), DEC); Serial.print(" XBee NI="); Serial.println(&xbeeNI[0].C); } else { Serial.println("XBee AT CMD ERROR"); } break;
Hope this isn't too snipped up.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
Thank you for subscribing!
Arduino
via Egeo 16
Torino, 10131
Italy