andrewrapp / xbee-arduino

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

Arduino + XBee S2B ZB : Failed when sending to a specific XBee address #46

Open TiksTriks opened 7 years ago

TiksTriks commented 7 years ago

Hello all,

My first words are to the amazing Andrew's work with the libraries to facilitate the use of XBee's. I'm a newbie using XBee's and this library is an excellent tool! Thank you Andrew!

Now, my issue is, when using Arduino, I can't address to a specific XBee address. When I try to send a packet to a specific XBee address it replies with "Failed to send packet. Status: 0xFF"

I'm using the "HelloSend.ino" sample code provided with the book Building Wireless Sensor Networks Using Arduino by Matthijs Kooijman. Thank you Matthijs.

(note: I'm using .txt extension files to be easier to post here)

Here is my code (I have changed only the addressing) to send a packet to the XCTU XBee Router address 0x0013A2004146B59A .

void sendPacket() {
    // Prepare the Zigbee Transmit Request API packet
    ZBTxRequest txRequest;

    txRequest.setAddress64(0x0013A2004146B59A);  //send packet to XCTU XBee Router

    uint8_t payload[] = {'X', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!'};
    txRequest.setPayload(payload, sizeof(payload));

    // And send it
    uint8_t status = xbee.sendAndWait(txRequest, 5000);
    if (status == 0) {
      DebugSerial.println(F("Succesfully sent packet"));
    } else {
      DebugSerial.print(F("Failed to send packet. Status: 0x"));
      DebugSerial.println(status, HEX);
    }
}

See full code here : HelloSend.txt

I also tried a different approach setting the address using XBeeAddress64: XBeeAddress64 remoteAddress = XBeeAddress64(0x0013A200, 0x4146B59A);

Also gives me an error when assigning to a specific XBee address using Arduino! Could anyone help me on what I'm doing wrong?

My best regards!

This is my scenario:

ZigBee Coordinator API (connected to Arduino Uno): 0x0013A2004146B5F2 profile_23A7_Coordinator_0x0013A2004146B5F2.txt

ZigBee Router API (connected to Arduino Uno): 0x0013A2004146B626 profile_23A7_Router_0x0013A2004146B626.txt

ZigBee Router API (connected to XCTU): 0x0013A2004146B59A profile_23A7_Router_0x0013A2004146B59A.txt

My Tests:

With XCTU XBee (ZigBee Router API ):

With Arduino Xbee (ZigBee Router API ):

With Arduino Xbee (ZigBee Coordinator API ):

All works fine when addressing to 0x000000000000FFFF using Arduino Xbee Coordinator.

andrewrapp commented 7 years ago

You should use AP=2 however I'm not convinced that explains the issue. The FF response indicates no reply from the local xbee, as if it wasn't connected. Have you looked at the docs to see if there are any changes to the api for S2B? I don't have any S2B radios so I'm unable to troubleshoot

ibrahimuslu commented 6 years ago

I have read the past issues and saw that we should configure modules as API 2 👍 https://github.com/andrewrapp/xbee-arduino#configuration

that code snippet is for that

jialarcon commented 5 years ago

Hi, I am having the exact same problem with XBee Series 2, always getting the timeout code 0xFF if I try to address an specific router... TiksTriks, did you finally solved the problem ? Regards

jialarcon commented 5 years ago

Hey ! I just double checked to see which API conf I had and it was wrong !, After switching to API 2 (escaped) it works perfectly so I can use full specific addressing. Regards