我正在使用SMSlib将短信发送到手机号码。但是出现以下错误。我什至更换了加密狗,但没有解决。
org.smslib.TimeoutException: No response from device.
at org.smslib.modem.AModemDriver$CharQueue.get(AModemDriver.java:535)
at org.smslib.modem.AModemDriver.getResponse(AModemDriver.java:338)
at org.smslib.modem.AModemDriver.getResponse(AModemDriver.java:313)
at org.smslib.modem.athandler.ATHandler.getSimStatus(ATHandler.java:145)
at org.smslib.modem.AModemDriver.connect(AModemDriver.java:132)
at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:189)
at org.smslib.Service$1Starter.run(Service.java:277)
下面是我的代码-
public static void sendMessage(String number, String message) {
Service srv = Service.getInstance();
try {
srv.addGateway(new SerialModemGateway("modem.com1", "COM5", 9600,
"huawei", "E220"));
} catch (GatewayException e1) {
e1.printStackTrace();
}
try {
srv.startService();
OutboundMessage msg = new OutboundMessage(number, message);
srv.sendMessage(msg);
srv.stopService();
} catch (Exception e) {
e.printStackTrace();
}
}
对于调试跟踪,您可以找到它here
最佳答案
我使用的端口错误。我们必须首先使用SMSLib提供的CommTest
实用程序扫描端口。我使用了另一个库来实际发送机器。