node-gsm-modem
NodeJS module to control GSM modem connected to serial port.
Thanks to
Emil Sedgh for PDU.js. I had to change it though.
Chris Williams for node-serialport
vchatterji for contributing to the module
Usage
Install using npm:
npm install --save gsm-modem
Require the module:
var Modem = require('gsm-modem');
Connect to the modem:
var modem1 = new Modem({
ports : ['/dev/ttyUSB0', '/dev/ttyUSB1', '/dev/ttyUSB2']
});
modem1.connect(function (err) {
if (err) {
console.error('Error connecting modem: ', err);
return;
}
// Start giving commands here...
}
Connect options
ports: Array of serial ports to search for a modem. The module will try to connect to every ports specified and send AT command. The first port modem answers to will be used as data/command port, others will be used for listening only. Default: [/dev/ttyUSB0,/dev/ttyUSB1,/dev/ttyUSB2]
debug: boolean if the module should output all data it sends/receives. Default: false
auto_hangup: boolean indicating whether modem should send ATH (hangup) command when incoming call is received. Default: false
commandTimeout: milliseconds, how long to wait for response on any AT command. Default: 15000
ussdTimeout: milliseconds, how long to wait for USSD after sending the command. Default: 15000
forever: boolean, indicated whether module should run in daemon mode automatically handling modem connects and disconnects. Default: false
API
See wiki page.
Checked on modems
- Huawei 3121S
- Huawei E171 / E173
- Huawei E1550
- Huawei K3765
- ZTE MF656A
- ZTE MF180
- Wavecom WISMO2C
TODO
- 8bit encoding
- Text mode