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

Small problem in AtCommand example #18

Open iuli4n opened 8 years ago

iuli4n commented 8 years ago

Hi,

I'm using xBee modules Series 2, and getting a small problem with the AtCommand example [I downloaded the library through the IDE]. The problem is that the module sends a Modem Status (type 8A) message right when it starts. This means that when the code checks for a response from the first AT command, it will receive this message as a reply; then all the other responses will be offset.

I think that adding a quick call to xbee.readPacket() at the end of the setup() function should fix this.

I also suggest that the example code be changed to give an ASCII output of what the response command is, like this:

    if (atResponse.isOk()) {
          SerialBridge.print("Command [");
          SerialBridge.print((char)atResponse.getCommand()[0]);
          SerialBridge.print((char)atResponse.getCommand()[1]);
          SerialBridge.println("] was successful!");

Otherwise works well so far. Thanks !