use of org.smslib.modem.SerialModemGateway in project wso2-axis2-transports by wso2.
the class GSMImplManager method start.
public void start() {
if (serviceRepo.gatewayInUse(gsmTransportInDetails.getGatewayId())) {
service = serviceRepo.getService(gsmTransportInDetails.getGatewayId());
return;
}
service = new Service();
gateway = new SerialModemGateway(gsmTransportInDetails.getGatewayId(), gsmTransportInDetails.getComPort(), gsmTransportInDetails.getBaudRate(), gsmTransportInDetails.getManufacturer(), gsmTransportInDetails.getModel());
// Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
gateway.setProtocol(AGateway.Protocols.PDU);
// Do we want the Gateway to be used for Inbound messages?
gateway.setInbound(true);
// Do we want the Gateway to be used for Outbound messages?
gateway.setOutbound(true);
// Let SMSLib know which is the SIM PIN.
gateway.setSimPin("0000");
try {
// Add the Gateway to the Service object.
this.service.addGateway(gateway);
// Start! (i.e. connect to all defined Gateways)
this.service.startService();
serviceRepo.addService(gsmTransportInDetails.getGatewayId(), service);
dispatcher = new GSMDispatcher(service, smsInManeger);
dispatcher.setPollInterval(gsmTransportInDetails.getModemPollInterval());
Thread thread = new Thread(dispatcher);
thread.start();
System.out.println("[Axis2] Started in Port :" + gsmTransportInDetails.getComPort() + " ");
} catch (Exception e) {
log.error(e);
}
}
use of org.smslib.modem.SerialModemGateway in project wso2-axis2-transports by wso2.
the class GSMImplManager method sendSMS.
public void sendSMS(SMSMessage sm) throws AxisFault {
if (service == null && !serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) {
// Operating in the Out Only mode
service = new Service();
gateway = new SerialModemGateway(gsmTransportOutDetails.getGatewayId(), gsmTransportOutDetails.getComPort(), gsmTransportOutDetails.getBaudRate(), gsmTransportOutDetails.getManufacturer(), gsmTransportOutDetails.getModel());
// Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
gateway.setProtocol(AGateway.Protocols.PDU);
// Do we want the Gateway to be used for Outbound messages?
gateway.setOutbound(true);
// Let SMSLib know which is the SIM PIN.
gateway.setSimPin("0000");
try {
// Add the Gateway to the Service object.
this.service.addGateway(gateway);
// Similarly, you may define as many Gateway objects, representing
// various GSM modems, add them in the Service object and control all of them.
// Start! (i.e. connect to all defined Gateways)
this.service.startService();
} catch (Exception e) {
throw new AxisFault(e.getMessage(), e);
}
} else if (serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) {
service = serviceRepo.getService(gsmTransportOutDetails.getGatewayId());
}
OutboundMessage msg = new OutboundMessage(sm.getReceiver(), sm.getContent());
try {
// a blocking call.This will be blocked untill the message is sent.
// normal rate is about 6msgs per minute
service.sendMessage(msg);
} catch (Exception e) {
throw new AxisFault(e.getMessage(), e);
}
}
Aggregations