I have tested this code for two devices, but it works without any problems for one device, and for the other it only sends an SMS once, and gives a timeout error for the second time.
var serialportgsm = require('serialport-gsm');
var modem = serialportgsm.Modem();
var options = {
baudRate: 115200,
dataBits: 8,
stopBits: 1,
parity: 'none',
rtscts: false,
xon: false,
xoff: false,
xany: false,
autoDeleteOnReceive: true,
enableConcatenation: true,
incomingCallIndication: true,
incomingSMSIndication: true,
pin: '',
customInitCommand: '',
logger: console
};
modem.open(com, options, function (err, result) {
if (err) {
console.log("error in open modem", err);
}
if (result) {
console.log("modem open", result);
}
});
I have tested this code for two devices, but it works without any problems for one device, and for the other it only sends an SMS once, and gives a timeout error for the second time.
var serialportgsm = require('serialport-gsm'); var modem = serialportgsm.Modem(); var options = { baudRate: 115200, dataBits: 8, stopBits: 1, parity: 'none', rtscts: false, xon: false, xoff: false, xany: false, autoDeleteOnReceive: true, enableConcatenation: true, incomingCallIndication: true, incomingSMSIndication: true, pin: '', customInitCommand: '', logger: console }; modem.open(com, options, function (err, result) { if (err) { console.log("error in open modem", err); } if (result) { console.log("modem open", result); } });
modem.on('open', function () { modem.initializeModem(function (msg, err) { if (err) { console.log('Error Initializing Modem - ', err); } else { console.log('InitModemResponse: ', JSON.stringify(msg)); modem.setModemMode(function () { modem.sendSMS(Mobile, Message, false, function (result) { console.log(result); }); }, 'PDU'); } }) });
I also tried not to close the modem after sending the first message, but it still failed to send for the second time on the same device.
Both devices are from the same company and the same model, only their versions are different.
Can someone help me ? thanks.