0

I m trying to get some information from my Xbee but it s not working

This is the code of my Class Test :

 public static void main (String[] args){
     XBee xbee = new XBee();
     try {
        xbee.open("COM3", 9600);
    } catch (XBeeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    while (true) {
        try {
            XBeeResponse response = xbee.getResponse(10000);
            // we got a response!
        } catch (XBeeTimeoutException e) {
            // we timed out without a response
        } catch (XBeeException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

And i m using Xbee API http://code.google.com/p/xbee-api/

but always i get this errors :

com.rapplogic.xbee.api.XBeeException: AT command timed-out while attempt to set/read in API mode. The XBee radio must be in API mode (AP=2) to use with this library at com.rapplogic.xbee.api.XBee.doStartupChecks(XBee.java:124) at com.rapplogic.xbee.api.XBee.initConnection(XBee.java:170) at com.rapplogic.xbee.api.XBee.open(XBee.java:142) at com.mohamed.test.main(test.java:16)

Thank Youuuuuu

user2216648
  • 41
  • 2
  • 8

3 Answers3

0

What platform are you on? If Windows, can you communicate with the XBee using Digi's X-CTU program? Have you confirmed the baud rate and that the module is in the right mode (ATAP must be set to 2)?

tomlogic
  • 11,489
  • 3
  • 33
  • 59
0

From the error, it looks like you haven't set the API mode for your XBee module to 2. Try to set it using X-CTU(windows based program). Here is an example how to using X-CTU to set API mode (XBee Series 2): Setting up X-Bee to API modde

oentoro
  • 740
  • 1
  • 11
  • 32
0

I recomend you that use OutputStream and InputStream of package java.io to comunicate with XBee module by serial. With this class you can send and recevide module information. Sure that the module is in AT mode.