I have gone through several post but didn't find any exact solution.
Some posts worked fine but it can send only one SMS.
So I decided to post a solution where a user can send multiple SMS.
Step1: create a file SMSGsm.js:
var SerialPort = require("serialport").SerialPort;
var mynum = '749863XXXX';
var mymsg = 'Hi Jyoti Sagar.....Welcome to Node.js world!';
var port = '';
var body = '';
port = "COM6"; // as per the modem installed on port
var serialPort = "";
serialPort = new SerialPort(port, {
baudrate: 38400, dataBits: 8, parity: 'none', stopBits: 1, flowControl: false
});
serialPort.on('error', function (err) {
console.log(err);
});
serialPort.on("open", function (err) {
if (err) {
console.log(err);
}
else {
console.log('Serial communication open');
// AT^SYSCFG=mode, order, band, roaming, domain
// mode(2): Automatic search; order(2): 3G first, then 2G;
// band(3FFFFFFF): Any band; roaming(2): No change; domain(4): No change
serialPort.write("AT^SYSCFG=2,2,3FFFFFFF,2,4");
serialPort.write('\r');
//serialPort.on('data', function (data) {
// console.log("Received data: " + data);
//});
sending_sms_gsm(serialPort, mymsg , mynum);
var tempFunc = setInterval(function () {
serialPort.close();
newFunc();
}, 10000);
var newFunc = function () {
clearInterval(tempFunc);
}
}
});
function sending_sms_gsm(serial, mymsg, mynum) {
serial.write("AT+CMGF=1");
serial.write('\r');
serial.write("AT+CMGS=\"");
serial.write(mynum);
serial.write('"')
serial.write('\r');
serial.write(mymsg);
serial.write(new Buffer([0x1A]));
serial.write('ctrl^z');
}
So the USER needs to create a client and pass the mobile number and message(only up to 160 characters)
Please reply with your feedback.
Thanks
Jyoti Sagar