I loaded an example Xbee Api program to my Arduino Diecimila (compiled ok).
That program makes two Xbee nodes (1 Router and 1 Coordinator) communicate in API mode (same PAN ID, same baud rate, same channel, and API mode enable).
I plugged an Xbee node (Router) to the Arduino board. This couple hardware is now not linked to the pc but is powered.
Then i plugged an Xbee node (Coordinator) to the PC by USB port (configured with X-CTU).
1/ How can i be sure that the program is running on the Arduino board?
(and transmitting request to the Xbee router on it?)
2/If it run, How can i retrieve some information sended to the Coordinator?
Thank you.
Here the code: from Xbee-Arduino project
Code: Select all
#include <XBee.h>
// Create an XBee object at the top of your sketch
XBee xbee = XBee();
// create an array for holding the data you want to send. You can change the contents of your array later on in the loop.
uint8_t payload[] = { 'X', 'B', 'e', 'e' };
// Specify the address of the remote XBee (this is the SH + SL)
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x404a50cc ); //0x403e0f30 // 0x404a52B4 pour le coordinateur
// Create a TX Request
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
// Create a Status Response object
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
// Tell XBee to start Serial
void setup() {
xbee.begin(9600);
}
void loop() {
// Send your request
xbee.send(zbTx);
// We'll wait up to five seconds for the status response. If the receiving XBee is powered on, the response will
// arrive very quickly, but if the remote XBee is not powered on or associated it could take a few seconds for a response.
if (xbee.readPacket(5000)) {
// Got a response!
// Should be a ZB TX Status
if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE) {
// It is, now get the status response
xbee.getResponse().getZBTxStatusResponse(txStatus);
// Check if it was delivered
if (txStatus.getDeliveryStatus() == SUCCESS) {
// Packet was successfully delivered
} else {
// The remote XBee did not receive our packet. is it powered on?
}
}
}
}