Unsupported operating mode: AT mode

When i use XBee Java Library User Guide.
I use the code to test my Xbee.

the code is here(the same with the code in pdf) and i find something strange。

package com.digi.xbee.example;
import com.digi.xbee.api.WiFiDevice;
import com.digi.xbee.api.XBeeDevice;
import com.digi.xbee.api.exceptions.XBeeException;
import com.digi.xbee.api.models.XBeeProtocol;
public class MainApp {
/* Constants */
// TODO Replace with the port where your sender module is connected to.
private static final String PORT = “COM5”;
// TODO Replace with the baud rate of your sender module.
private static final int BAUD_RATE = 9600;
private static final String DATA_TO_SEND = “Hello XBee World!”;
public static void main(String[] args) {
XBeeDevice myDevice = new XBeeDevice(PORT, BAUD_RATE);
byte[] dataToSend = DATA_TO_SEND.getBytes();
try {
myDevice.open();
byte[] sleepTime = myDevice.getParameter(“SP”);
System.out.println(sleepTime[0]);
System.out.format(“Sending broadcast data: ‘%s’”, new String
(dataToSend));
if (myDevice.getXBeeProtocol() == XBeeProtocol.XBEE_WIFI) {
myDevice.close();
myDevice = new WiFiDevice(PORT, BAUD_RATE);
myDevice.open();
((WiFiDevice)myDevice).sendBroadcastIPData(0x2616, dataToSend);
} else
myDevice.sendBroadcastData(dataToSend);
System.out.println(" >> Success");
} catch (XBeeException e) {
System.out.println(" >> Error");
e.printStackTrace();
System.exit(1);
} finally {
myDevice.close();
}
}
}

when i connect my xbee with a arduino uno R3,i got this :
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/lenovo/eclipse-workspace/myFirstXBeeApp/libs/slf4j-jdk14-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/lenovo/eclipse-workspace/myFirstXBeeApp/libs/slf4j-nop-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/lenovo/eclipse-workspace/myFirstXBeeApp/libs/slf4j-simple-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.JDK14LoggerFactory]
八月 31, 2020 7:26:44 下午 com.digi.xbee.api.AbstractXBeeDevice open
信息: [COM5 - 9600/8/N/1/N] Opening the connection interface…
八月 31, 2020 7:26:44 下午 com.digi.xbee.api.AbstractXBeeDevice open
信息: [COM5 - 9600/8/N/1/N] Connection interface open.
八月 31, 2020 7:26:49 下午 com.digi.xbee.api.AbstractXBeeDevice close
信息: [COM5 - 9600/8/N/1/N] Connection interface closed.
>> Errorcom.digi.xbee.api.exceptions.InvalidOperatingModeException: Unsupported operating mode: AT mode

at com.digi.xbee.api.AbstractXBeeDevice.open(AbstractXBeeDevice.java:3153)
at com.digi.xbee.api.XBeeDevice.open(XBeeDevice.java:135)
at com.digi.xbee.example.MainApp.main(MainApp.java:18)

i DO determine that my xbee is in API mode.And the interesting thing is that i also have a arduino board without chip(so it can not upload program in arduino).When i use this borken board,this code can run well,and i can receive “Hello XBee World” from XCTU.

Does anyone have a similar problem?Can anyone give me some advice?

This sounds like you are not getting to COM port that the XBee is connected to. You may need to run some jumpers on you board to connect the two.