I have a problem, I'm testing the library API and I can not make the modules communicate. The two modules are in AP = 2. Can anyone explain why nothing happens rx?
Tx
#include <XBee.h>
XBee xbee = XBee();
uint8_t payload[] = { 'H', 'i' };
XBeeAddress64 addr64 = XBeeAddress64(0x00000000, 0x00000000);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
void setup() {
Serial.begin(9600);
xbee.begin(9600);
}
void loop()
{
xbee.send(zbTx);
delay(1000);
}
Rx
#include <XBee.h>
XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
// create reusable response objects for responses we expect to handle
Rx16Response rx16 = Rx16Response();
Rx64Response rx64 = Rx64Response();
uint8_t option = 0;
uint8_t data = 0;
void setup() {
// start serial
Serial.begin(9600);
xbee.begin(9600);
}
// continuously reads packets, looking for RX16 or RX64
void loop() {
xbee.readPacket();
if (xbee.getResponse().isAvailable()) {
// got something
if (xbee.getResponse().getApiId() == RX_16_RESPONSE ||
xbee.getResponse().getApiId() == RX_64_RESPONSE) {
// got a rx packet
if (xbee.getResponse().getApiId() == RX_16_RESPONSE) {
xbee.getResponse().getRx16Response(rx16);
option = rx16.getOption();
data = rx16.getData(0);
for (int i=0; i< rx16.getDataLength(); i++)
{
Serial.print(rx16.getData(i), BYTE);
}
}
else {
xbee.getResponse().getRx64Response(rx64);
option = rx64.getOption();
data = rx64.getData(0);
for (int i=0; i< rx64.getDataLength(); i++)
{
Serial.print(rx64.getData(i), BYTE);
} }}}}