RF Data (payload) size is unexpected upon receipt

87 views
Skip to first unread message

Chris Grimmett

unread,
Apr 13, 2018, 4:19:49 PM4/13/18
to xbee-api
I'm using ZigBee 900Mhz series XBees. One is connected to an Arduino Fio, the other is connected to my computer via USB adapter board.

Using the arduino-xbee example Series2_Tx, I'm getting unexpected results with the payload it's sending.

The payload is supposed to be two bytes containing analog pin 5 readings. However, I'm seeing a lot more than two bytes on the other end with XCTU-NG Frame log--



Receive Packet (API 1)

7E 00 21 90 00 13 A2 00 40 B5 1A 26 33 13 01 7E 00 10 10 01 00 7D 33 A2 00 40 B7 74 EC FF FE 00 00 00 50 95 14

Start delimiter: 7E
Length: 00 21 (33)
Frame type: 90 (Receive Packet)
64-bit source address: 00 13 A2 00 40 B5 1A 26
16-bit source address: 33 13
Receive options: 01
RF data: 7E 00 10 10 01 00 7D 33 A2 00 40 B7 74 EC FF FE 00 00 00 50 95
Checksum: 14


You can see the RF data is 21 bytes. That's a lot more than 2! Why is this?


I did make some changes to the example sketch (Baud rate, and XBee addresses) so I will include it--

/**
 * Copyright (c) 2009 Andrew Rapp. All rights reserved.
 *
 * This file is part of XBee-Arduino.
 *
 * XBee-Arduino is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * XBee-Arduino is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with XBee-Arduino.  If not, see <http://www.gnu.org/licenses/>.
 */


#include <XBee.h>

/*
This example is for Series 2 XBee
 Sends a ZB TX request with the value of analogRead(pin5) and checks the status response for success
*/


// create the XBee object
XBee xbee = XBee();

uint8_t payload
[] = { 0, 0 };

// SH + SL Address of receiving XBee
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x40b774ec);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();

int pin5 = 0;

int statusLed = 13;
int errorLed = 13;

void flashLed(int pin, int times, int wait) {

 
for (int i = 0; i < times; i++) {
    digitalWrite
(pin, HIGH);
    delay
(wait);
    digitalWrite
(pin, LOW);

   
if (i + 1 < times) {
      delay
(wait);
   
}
 
}
}

void setup() {
  pinMode
(statusLed, OUTPUT);
  pinMode
(errorLed, OUTPUT);

 
Serial.begin(57600);
  xbee
.setSerial(Serial);
}

void loop() {  
 
// break down 10-bit reading into two bytes and place in payload
  pin5
= analogRead(5);
  payload
[0] = pin5 >> 8 & 0xff;
  payload
[1] = pin5 & 0xff;

  xbee
.send(zbTx);

 
// flash TX indicator
  flashLed
(statusLed, 1, 100);

 
// after sending a tx request, we expect a status response
 
// wait up to half second for the status response
 
if (xbee.readPacket(500)) {
   
// got a response!

   
// should be a znet tx status                
   
if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
      xbee
.getResponse().getZBTxStatusResponse(txStatus);

     
// get the delivery status, the fifth byte
     
if (txStatus.getDeliveryStatus() == SUCCESS) {
       
// success.  time to celebrate
        flashLed
(statusLed, 5, 50);
     
} else {
       
// the remote XBee did not receive our packet. is it powered on?
        flashLed
(errorLed, 3, 500);
     
}
   
}
 
} else if (xbee.getResponse().isError()) {
   
//nss.print("Error reading packet.  Error code: ");  
   
//nss.println(xbee.getResponse().getErrorCode());
 
} else {
   
// local XBee did not provide a timely TX Status Response -- should not happen
    flashLed
(errorLed, 2, 50);
 
}

  delay
(1000);
}




Chris Grimmett

unread,
Apr 14, 2018, 4:31:29 PM4/14/18
to xbee-api
I re-read the xbee-arduino Library README.md which states, "This software will not work correctly with AP=1"

As shown in the packet information I posted, the receiving XBee was running API=1. Also the transmitting XBee was running AT firmware. I switched the transmitting XBee to ZigBee endpoint firmware, and both to API=2.  Problem solved.
Reply all
Reply to author
Forward
0 new messages