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

ZBTxRequest has wrong API ID #25

Closed t-hg closed 8 years ago

t-hg commented 8 years ago

Hi Andrew

I followed your example Series2_TX. When I am sending a package to my coordinator, then I do not get any status response from the coordinator.

I found out that the API ID of a ZBTxRequest is not 0x10 but 0x16 which is not even a valid API ID in the XBee protocol.

Am I missing something?

`#include

include

include

// Software Serial Port for Xbee SoftwareSerial xbeeSerial = SoftwareSerial(10,11);

// Create an XBee object at the top of your sketch XBee xbee = XBee();

// Create an array for holding the data you want to send. uint8_t payload[] = { 'H', 'I' };

// Specify the address of the remote XBee (this is the SH + SL) XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x40b7b208);

// Create a TX Request ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));

ZBTxStatusResponse txStatus = ZBTxStatusResponse();

void setup() {

// Start the serial port for debugging Serial.begin(9600);

// Start the xbee serial port xbeeSerial.begin(9600);

// Tell XBee to use Hardware Serial. It's also possible to use SoftwareSerial xbee.setSerial(xbeeSerial); }

void loop() {

Serial.println("Go");

Serial.print("ZB TX API ID: "); Serial.println(zbTx.getApiId());

// Send your request xbee.send(zbTx);

// 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
    Serial.println("Success");
  } else {
    // the remote XBee did not receive our packet. is it powered on?
    Serial.println("Loss");
  }
}

} else if (xbee.getResponse().isError()) { Serial.print("Error reading packet. Error code: ");
Serial.println(xbee.getResponse().getErrorCode()); } else { Serial.println("This should not happen"); }

delay(5000); }`

t-hg commented 8 years ago

I am stupid 0x10 is 16 in decimal. Wonder why it does still not work.