andrewrapp / xbee-arduino

Arduino library for communicating with XBee radios in API mode
GNU General Public License v2.0
337 stars 163 forks source link

Send from XCTU Coordinator to Arduino Router Did Not Work #69

Open facetime88 opened 6 years ago

facetime88 commented 6 years ago

Hello,

This is a great library. But I think there is a bug. I tried to communicate xbee pro s2c on arduino (set as router) to xbee pro s2c in PC XCTU (set as coordinator). No problem when sending from arduino to xtcu. Arduino get ACK (XCTU receive option said C0).

The problem when send request from XCTU to arduino with T0 (transmit options) set to C0 (means request for ACK). XCTU transmit status said delivery status is success. It means xbee on arduino has confirm it received the request made by XCTU. Yet there is no receive on the side of arduino. I use the Series2_Rx example in arduino and put some serial debug. But it never being hit.

Note: This only happen when using specific 64 address. But when in broadcast, arduino side receive normally. XTCU side all the same, whether broadcast or unicast, both get success delivery status.

xbee.readPacket();

if (xbee.getResponse().isAvailable()) {
  Serial.println("available...");
  // got something

  if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) {
    // got a zb rx packet

    // now fill our zb rx class
    xbee.getResponse().getZBRxResponse(rx);

    if (rx.getOption() == ZB_PACKET_ACKNOWLEDGED) {
        // the sender got an ACK
        flashLed(statusLed, 10, 10);
    } else {
        // we got it (obviously) but sender didn't get an ACK
        flashLed(errorLed, 2, 20);
    }
    // set dataLed PWM to value of the first byte in the data
    analogWrite(dataLed, rx.getData(0));
  } else if (xbee.getResponse().getApiId() == MODEM_STATUS_RESPONSE) {
    xbee.getResponse().getModemStatusResponse(msr);
    // the local XBee sends this response on certain events, like association/dissociation

    if (msr.getStatus() == ASSOCIATED) {
      // yay this is great.  flash led
      flashLed(statusLed, 10, 10);
    } else if (msr.getStatus() == DISASSOCIATED) {
      // this is awful.. flash led to show our discontent
      flashLed(errorLed, 10, 10);
    } else {
      // another status
      flashLed(statusLed, 5, 10);
    }
  } else {
    // not something we were expecting
    flashLed(errorLed, 1, 25);    
  }
} else if (xbee.getResponse().isError()) {
  //nss.print("Error reading packet.  Error code: ");  
  //nss.println(xbee.getResponse().getErrorCode());
}`