Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Richard MacCutchan 25-Aug-15 12:48pm    
Please reply with your feedback.
What sort of feedback? You need to ask a question.
jsagar05 26-Aug-15 3:39am    
This is the solution I have provided for users.
So by feedback I mean to say to comment on how much useful is this post....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900