I was wondering why I can not set the value of the CE on the Xbee, I am also trying to set up EE and KY, but the only thing that works is the ID.
I tried setting turnOn = 0x01 or 1 or 0x31 (Hex for 1). I looked at what X-ctu is doing and I am sending the same information (Value 0x01) , though I can not see the actual xbee frame being sent, I know my values and command are correct. The response is 0x00 for success.
Also I do have code at the end to issue ATWR and ATAC. I also tried to issue only the CE command or others, the thing is I know it is changing the value because I can take it will take it out of CE mode (CE = 0).
Below is the code. Any ideas.
Also I wrote some code that will take the xbee and pop it into API mode 2 from the ardiuno board, so that all the Xbee's will not have to be set up, the board can do it on a one time set up. Where can I submit that for this project.
Thanks,
Donald
include
include </root/Arduino/libraries/xbee-arduino-master/Printers.h>
XBeeWithCallbacks xbee;
define DebugSerial Serial
define SerialXbee Serial1
void setup() {
DebugSerial.begin(9600);
DebugSerial.println("Starting up...");
SerialXbee.begin(9600);
xbee.begin(SerialXbee);
delay(1);
// Let all responses be printed
xbee.onResponse(printResponseCb, (uintptr_t)(Print ) & DebugSerial);
xbee.onPacketError(printErrorCb, (uintptr_t)(Print) & DebugSerial);
// The paramater for the command value
uint8_t idPan [8] = {0x90,0xda,0xdc,0xff,0x45,0x5a,0xab,0xdf};
uint8_t turnOn = 1;
// Send a command to the xbee
// Set the Pan ID in the device
AtCommandRequest req((uint8_t)"ID",(uint8_t) idPan,8);
xbee.send(req);
// Set the device to a co-ordinator (Brain only)
req.clearCommandValue();
req.setCommand((uint8_t)"CE");
req.setCommandValue((uint8_t) turnOn);
req.setCommandValueLength(1);
xbee.send(req);
// Set the device for channel verification
// req.clearCommandValue();
// req.setCommand((uint8_t)"JV");
// req.setCommandValue((uint8_t) turnOn);
// req.setCommandValueLength(1);
// xbee.send(req);
// Turn on Sleep Mode Pin set to one, so turn on value will work
// req.clearCommandValue();
// req.setCommand((uint8_t)"SM");
// req.setCommandValue((uint8_t) turnOn);
// req.setCommandValueLength(1);
// Turn on Encryption
req.clearCommandValue();
req.setCommand((uint8_t)"EE");
req.setCommandValue((uint8_t) turnOn);
req.setCommandValueLength(1);
// Set the name of the device
uint8_t kyKey[16] = Data; // Changed I don't want to post my KY Code
req.clearCommandValue();
req.setCommand((uint8_t)"KY");
req.setCommandValue((uint8_t) kyKey);
req.setCommandValueLength(16);
xbee.send(req);
// Write the settings to the Xbee
req.clearCommandValue();
req.setCommand((uint8_t)"WR");
xbee.send(req);
// Apply settings to Xbee right away without bootup
req.clearCommandValue();
req.setCommand((uint8_t)"AC");
xbee.send(req);
// Call NO
}
// continuously reads packets, looking for ZB Receive or Modem Status
void loop() {
xbee.loop();
}
I was wondering why I can not set the value of the CE on the Xbee, I am also trying to set up EE and KY, but the only thing that works is the ID. I tried setting turnOn = 0x01 or 1 or 0x31 (Hex for 1). I looked at what X-ctu is doing and I am sending the same information (Value 0x01) , though I can not see the actual xbee frame being sent, I know my values and command are correct. The response is 0x00 for success. Also I do have code at the end to issue ATWR and ATAC. I also tried to issue only the CE command or others, the thing is I know it is changing the value because I can take it will take it out of CE mode (CE = 0). Below is the code. Any ideas. Also I wrote some code that will take the xbee and pop it into API mode 2 from the ardiuno board, so that all the Xbee's will not have to be set up, the board can do it on a one time set up. Where can I submit that for this project. Thanks, Donald
include
include </root/Arduino/libraries/xbee-arduino-master/Printers.h>
XBeeWithCallbacks xbee;
define DebugSerial Serial
define SerialXbee Serial1
void setup() { DebugSerial.begin(9600); DebugSerial.println("Starting up..."); SerialXbee.begin(9600); xbee.begin(SerialXbee); delay(1); // Let all responses be printed xbee.onResponse(printResponseCb, (uintptr_t)(Print ) & DebugSerial); xbee.onPacketError(printErrorCb, (uintptr_t)(Print) & DebugSerial); // The paramater for the command value uint8_t idPan [8] = {0x90,0xda,0xdc,0xff,0x45,0x5a,0xab,0xdf}; uint8_t turnOn = 1; // Send a command to the xbee // Set the Pan ID in the device AtCommandRequest req((uint8_t)"ID",(uint8_t) idPan,8); xbee.send(req); // Set the device to a co-ordinator (Brain only) req.clearCommandValue(); req.setCommand((uint8_t)"CE"); req.setCommandValue((uint8_t) turnOn); req.setCommandValueLength(1); xbee.send(req); // Set the device for channel verification // req.clearCommandValue(); // req.setCommand((uint8_t)"JV"); // req.setCommandValue((uint8_t) turnOn); // req.setCommandValueLength(1); // xbee.send(req); // Turn on Sleep Mode Pin set to one, so turn on value will work // req.clearCommandValue(); // req.setCommand((uint8_t)"SM"); // req.setCommandValue((uint8_t) turnOn); // req.setCommandValueLength(1); // Turn on Encryption req.clearCommandValue(); req.setCommand((uint8_t)"EE"); req.setCommandValue((uint8_t) turnOn); req.setCommandValueLength(1); // Set the name of the device uint8_t kyKey[16] = Data; // Changed I don't want to post my KY Code req.clearCommandValue(); req.setCommand((uint8_t)"KY"); req.setCommandValue((uint8_t) kyKey); req.setCommandValueLength(16); xbee.send(req); // Write the settings to the Xbee req.clearCommandValue(); req.setCommand((uint8_t)"WR"); xbee.send(req); // Apply settings to Xbee right away without bootup req.clearCommandValue(); req.setCommand((uint8_t)"AC"); xbee.send(req); // Call NO }
// continuously reads packets, looking for ZB Receive or Modem Status void loop() { xbee.loop(); }