日期:2014-05-20  浏览次数:20668 次

JAVA短信猫碰问题,无法启动设备,抛出SMSLibException例外
  参照网上的资料写了一个短信猫程序, 自己的机器, 测试了几台机器都没有问题,但放客户服务器(2003 Server)上面总是抛出SMSLibException例外,我以为是SIM卡的问题,后来我换成我的SIM卡, 居然能启动,  客户自己新办的一张卡死活都不行, 后再换了一张别人的卡还是不行, 难道只认我的? 不知道那出问题了, 大侠指点指点,
 

    public void startDevice() {

        lbDevice.setText("正在启动SMS设备...");
        comName = smsDevice.getComName();
        if (!"".equals(comName)) {
            String comNo = comName.substring(3, comName.length());
            talog.append("端口号:"+comNo+"\n");
            //网关  
            SerialModemGateway gateway = new SerialModemGateway("modem.com" + comNo, "COM" + comNo, 9600, "wavecom", "");

            //收件箱  
            gateway.setInbound(true);
            //发件箱  
            gateway.setOutbound(true);
            
            //ping码   前面我以为是ping码的问题, 把下面的代码注销也是一样
            gateway.setSimPin("0000");
            
            try {
                srv = new Service();
                srv.addGateway(gateway);
                //服务启动  
                srv.startService();
                deviceIsntStart = true;
                lbDevice.setText("SMS设备已启动...");
            } catch (GatewayException ex) {
                Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
                talog.append("启动失败:GatewayException \n");
                lbDevice.setText("SMS设备启动失败...");
            } catch (SMSLibException ex) {
                Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
                talog.append("启动失败:SMSLibException "+ new SMSLibException().getMessage()+" \n");
                lbDevice.setText("SMS设备启动失败...");
            } catch (IOException ex) {
                Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
                talog.append("启动失败:IOException \n");
                lbDevice.setText("SMS设备启动失败...");
            } catch (InterruptedException ex) {
                Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
                talog.append("启动失败:InterruptedException \n");
                lbDevice.setText("SMS设备启动失败...");
            }
        }else{
            lbDevice.setText("启动SMS设备失败,端口无法获取...");
        }
    }