我正在尝试学习使用 SMSlib 使用 ZTE MF631 usb 调制解调器发送短信。这是我的代码:
Service.getInstance().startService();
SerialModemGateway gateway = new SerialModemGateway("modem.com5","COM5", 115200, "ZTE", "MF631");
gateway.setInbound(true);
gateway.setOutbound(true);
gateway.setSimPin("0000");
gateway.setSmscNumber("+9779800009000");
try {
Service.getInstance().addGateway(gateway);
OutboundMessage outboundMsg = new OutboundMessage("+9779843669921", "Hello there!");
Service.getInstance().sendMessage(outboundMsg);
} finally {
gateway.stopGateway();
Service.getInstance().removeGateway(gateway);
Service.getInstance().stopService();
}
当我运行我的代码时,我收到以下错误:
org.smslib.SMSLibException: No gateways are defined.
at org.smslib.Service.startService_Internal(Service.java:295)
at org.smslib.Service.startService(Service.java:229)
at org.smslib.Service.startService(Service.java:196)
at com.mail.utility.SendSmsUtility.sendSMS(SendSmsUtility.java:10)
at com.mail.action.SendSmsAction.sendSms(SendSmsAction.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)