0

我正在尝试学习使用 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)
4

1 回答 1

0

我认为您在开始服务之前缺少这样的东西:

Service.getInstance().addGateway(gateway);

这是SMSlib 示例。

于 2014-01-19T07:36:19.467 回答