日期:2014-05-20 浏览次数:20711 次
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设备失败,端口无法获取...");
}
}