Giter Site home page Giter Site logo

modem's People

Contributors

alexislg2 avatar banonotit avatar emilsedgh avatar iamchathu avatar jellyjellyrobot avatar shernshiou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modem's Issues

README.md

Document of Running custom AT commands

  • callback Function called when execution is done, in form of (escape_char, [response])

should be

  • callback Function called when execution is done, in form of ([response], escape_char)

modem.on('sms received') not working, sms not incoming.

Modem HUAWEI E1715. SMS sends ok.

modem.open('COM5', function(){
	modem.on('sms received', function(smsc, sender, time, text) {
		console.log('sms in');
		console.log('sender:'+sender+' text:'+text);
	});

	modem.getMessages(function(messages) {
		console.log(messages);
	});
});

setInterval(function(){}, 1000);

getMessages return empty arr

License

Hi, I see you're not maintaining this package anymore. Can you add a license and maybe transfer ownership?

Add incomming call event

Hi,
can this lib be extended to read incoming callerid information for voice supporting modems?

thanks in advance

Too much bugs...

modem.parseResponse = function(response) {
    var plain = response.slice(response.indexOf(':')+1).trim();
    var parts = plain.split(/,(?=(?:[^"]|"[^"]*")*$)/);
    for(i in parts)
        parts[i] = parts[i].replace(/\"/g, '');

    return parts;
}
modem.parseResponse = function(response) {
    var plain = response.slice(response.indexOf(':')+1).trim();
    var parts = plain.split(/,(?=(?:[^"]|"[^"]*")*$)/);
    for(var i=0;i<parts.length;i++)
        parts[i] = parts[i].replace(/\"/g, '');

    return parts;
}

modem.close = function(device) {
    this.port.removeAllListeners();
    this.port.close();
    this.port = null;
    this.isOpened = false;
    this.emit('close');
}


modem.close = function(device) {
    for(var k in timeouts) clearTimeout(timeouts[k])
    this.port.removeAllListeners();
    try{this.port.close()}catch(e){};
    this.port = null;
    this.isOpened = false;
    this.emit('close');
}

if(this.queue[0] && this.queue[0]['command'].trim().slice(0, data.length) === data) {
        this.queue[0]['command'] = this.queue[0]['command'].slice(data.length); <= Why you do that ?
        return ;
  }

Please.. any update ?

get delivery report indexes

Hey,
The delivery event works well but I would appreciate to have the index of the corresponding SMS so that I can remove it from my Inbox
Thanks

serialport isse!

Hi,

gsm.js

`
function err(message) {
  console.log('Usage: node send_sms.js /path/to/device xxxxyyzz "Foo Bar"');
  process.exit();
}

var device   = process.argv[2];
var receiver = process.argv[3];
var text     = process.argv[4];

if(!device || !receiver || !text) err();

var modem = require('modem').Modem();
modem.open('/dev/ttyS0', function() {
  modem.sms({
    receiver:receiver,
    text:text,
    encoding:'7bit'
  }, function(err, sent_ids) {
    console.log('>>', arguments);
    if(err)
      console.log('Error sending sms:', err);
    else
      console.log('Message sent successfully, here are reference ids:', sent_ids.join(','));
  });
});
`

console error:

node gsm.js /dev/ttyS0 +359894587672 "test node"
DEPRECATION: Please use require('serialport') instead of require('serialport').SerialPort
^C

modem.js


1: var pdu = require('pdu');
2: var sp = require('serialport');
3: var EventEmitter = require('events').EventEmitter;
......
81:    modem.open = function(device, callback) {
82:        modem.port = new sp.SerialPort(device, {
83:           parser: sp.parsers.raw
84:        });

Cant find that DEPRECATION error!

UTF8

Solition of specials character?

Cannot read properties of undefined (reading 'raw')

hi, i just installed this and whenever i run this

var modem = require('modem').Modem();

modem.open("/dev/sg1", function(err){
    if(err){
    throw err;
    }else{
    console.log("Modem is ready");
    }
})

i get this error

../node_modules/modem/lib/modem.js:84
            parser: sp.parsers.raw
                               ^

TypeError: Cannot read properties of undefined (reading 'raw')

Any solution?

Text Disappears from end the text message

Hello @emilsedgh first of all nice work.

I have been testing this package and I have found one problem.
Text is disappearing from the end of the message.

In my tests I have detected that 6 characters disappear. Can You Please check this?

TypeError: Cannot set property 'end_time' of undefined

I'm trying to run the following code on Windows 7:

/* Usage: node send_sms.js /path/to/device xxxxyyzz "Foo Bar" */

function err(message) {
  console.log('Usage: node send_sms.js /path/to/device xxxxyyzz "Foo Bar"');
  process.exit();
}

var device   = 'COM11';
var receiver = '5562XX1685XX';
var text     = 'ola mundo';

console.log('iniciando');

var modem = require('modem').Modem();
modem.open(device, function() {
  modem.sms({
    receiver:receiver,
    text:text,
    encoding:'7bit'
  }, function(err, sent_ids) {
    console.log('>>', arguments);
    if(err)
      console.log('Error sending sms:', err);
    else
      console.log('Message sent successfully, here are reference ids:', sent_ids.join(','));
  });
});

But I'm getting the error:

D:\serialport>node app4.js
>> { '0': null, '1': [ '' ] }
Message sent successfully, here are reference ids:

D:\serialport\node_modules\modem\lib\modem.js:176
                this.queue[0]['end_time'] = new Date();
                                          ^
TypeError: Cannot set property 'end_time' of undefined
    at EventEmitter.<anonymous> (D:\serialport\node_modules\modem\lib\modem.js:176:43)
    at Array.forEach (native)
    at EventEmitter.modem.dataReceived (D:\serialport\node_modules\modem\lib\modem.js:123:15)
    at SerialPort.emit (events.js:95:17)
    at Object.module.exports.raw [as parser] (D:\serialport\node_modules\serialport\parsers.js:8:13)
    at SerialPort.options.dataCallback (D:\serialport\node_modules\serialport\serialport.js:143:15)

Trying to debug the module, I've realized that the line 176 is performed 3 times but the error happens just on the 3rd time.

Kleyson Rios.

+CME ERROR: operation not allowed

Hi everyone, excuse my English, I'm french,
So I do use this library to send USSD from up to three different sim cards.
So I have three gsm modems connected to my computer and
I'm also able to send USSD over one of them (using Huawei E3131) but the others modems (Alcatel X602D and ) give me this error :
+CME ERROR: operation not allowed.
What should I do? Is there any kind of authorization I should give to my app?

The on ring event doesn't work.

I have connected a FAX modem and connected the land line phone.
The connect function works fine for the modem.
But the on ring event is not triggered when I call the land line phone.
But I can see from the debug feature that the caller id is working fine on my modem.

This is what I get on the console.log when I call at the line line which is connected in my modem:
DEBUG modem: COM19 <----
RING

DEBUG modem: Unhandled command:
NMRB = 6945076867
DATE = 0218
TIME = 2042
MESG = 0000

etc

And below you can see my code.
function onRing(number) {
console.log('onring'+number);
}
var modem1 = new Modem({
ports : ['COM19'],
debug : true
});
modem1.on('ring', onRing);

modem1.connect(function (err) {
if (err) {
console.error('Error connecting modem: ', err);
return;
}

});

GSM module is not working

var device = '/dev/ttyUSB0';
var message = {
text : 'Hello',
receiver: '+91xxxx',
encoding: '7bit'
};

modem.open(device, function(){
console.log('OPEN!!');
});

/*

  • Send SMS
    */
    modem.sms(message, function(err, res){
    console.log('SMS', err, res);
    });

OUTPUT:

node gsm_modem.js
OPEN!!

It can't send sms. 'delivery' method is also not working.

Random behaviour fr receiving messages

Hey,
First thanks for your cool package. I use it to send and receive SMS but sometimes, the app stop receiving SMS (no event is emited when a new sms arrives). I have to stop and restart the app in order to receive them?
Have you ever experiences this behaviour ?

can't notify when new sms received

First , I'd like to thank you for this great module ,
Second , I can't notify when new sms received ..
I tried changing the AT+CNMI command to another value like AT+CNMI=2,1,0,2,0 , but it still the same ..

thanks in advance ..

Open not exist serialport throw error

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: Serialport not open.
    at SerialPortFactory.SerialPort.close (/Users/terry/Desktop/iRXBot/modem/node_modules/modem/node_modules/serialport/serialport.js:476:17)
    at EventEmitter.modem.close (/Users/terry/Desktop/iRXBot/modem/node_modules/modem/lib/modem.js:110:19)
    at SerialPort.<anonymous> (/Users/terry/Desktop/iRXBot/modem/node_modules/modem/lib/modem.js:104:19)
    at SerialPort.emit (events.js:107:17)
    at SerialPort.callback (/Users/terry/Desktop/iRXBot/modem/node_modules/modem/node_modules/serialport/serialport.js:101:16)
    at /Users/terry/Desktop/iRXBot/modem/node_modules/modem/node_modules/serialport/serialport.js:224:11

Best SMS Modem MultiSIM

Hi Emil,
Please, what multi sim modem (minimum 3) advise you for your system? or one you advice?
Thank you in advance for your answer.

windows can not open port

hi

modem.open('COM6', function(){

say

E:\node\ussd\node_modules\modem\lib\modem.js:82
        modem.port = new sp.SerialPort(device, {
                     ^

TypeError: sp.SerialPort is not a constructor

i use windows 10 and this is my COMs

PS E:\node\ussd\node_modules\serialport\bin> node .\list.js
COM6    USB\VID_2077&PID_A000&MI_00\6&F9B7265&1&0000    W-Card
COM4    USB\VID_2077&PID_A000&MI_01\6&F9B7265&1&0001    W-Card

Using Modem in Cluster environment

I ma failing to use modem with nodejs cluster, l get the following error

/home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/lib/modem.js:176
this.queue[0]['end_time'] = new Date();
^
TypeError: Cannot set property 'end_time' of undefined
at EventEmitter. (/home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/lib/modem.js:176:43)
at Array.forEach (native)
at EventEmitter.modem.dataReceived (/home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/lib/modem.js:123:15)
at SerialPort.EventEmitter.emit (events.js:95:17)
at Object.module.exports.raw as parser
at Object.SerialPort.options.dataCallback (/home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/node_modules/serialport/serialport.js:167:15)
at SerialPortFactory.SerialPort._emitData (/home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/node_modules/serialport/serialport.js:349:20)
at afterRead (/home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/node_modules/serialport/serialport.js:325:20)
at /home/chris/SoftWyze/node-prjt/bhora-api/node_modules/modem/node_modules/serialport/serialport.js:341:9
at Object.wrapper as oncomplete

This is what my bin/www looks like
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;

var debug = require('debug')('bhora-api');
var app = require('../app');

if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on('exit', function(worker, code, signal) {
    console.log('worker ' + worker.process.pid + ' died');
});

} else {
// Workers can share any TCP connection
// In this case its a HTTP server
app.set('port', process.env.PORT || 3000);

var server = app.listen(app.get('port'), function() {
    debug('Express server listening on port ' + server.address().port);
});

}

app.js is where l try to initialize the modem

Cutting off last characters sending SMS

When using the modem.sms function I am experiencing that the last few characters are cut of when viewing the sms message on the receiving phone.

function sendSMS() {
console.log('Attempting to send SMS');
modem.sms({
receiver: '0761234567',
text: 'Test text from app.js on Mac.',
encoding: '7bit'
}, function (err, sent_ids) {
console.log('>>', arguments);
if (err)
console.log('Error sending sms:', err);
else
console.log('Message sent successfully, here are reference ids:', sent_ids.join(','));
});
}

For instance: Test text from app.js on Mac. gets cut off toTest text from app.js on M

Have you experienced this?

Thanks
Leon

Cannot find module path/to/serialport/.../serialport.node

Hello :) its my first time with node modules and i'm sorry to say "i confused with node modules error generally"

my problem is : after instaling modem node's console log show me an error

Uncaught Error: Cannot find module 'C:\myapps\test-modem\node_modules\modem\node_modules\serialport\build\serialport\v1.7.4\Release\node-webkit-v0.12.2-win32-ia32\serialport.node'

i have a try with renaming path folders to be right and it show me error

Uncaught Error: Invalid access to memory location.
C:\myapps\test-modem\node_modules\modem\node_modules\serialport\build\serialport\v1.7.4\Release\node-webkit-v0.12.2-win32-ia32\serialport.node

thanks and hope to help :)

Can't send SMS: this.queue is empty

I'm executing following program:

var modem = require('modem').Modem();
modem.open('COM4', function() {
    modem.execute('AT+CMGS="03028461532"\rHello World\r'+String.fromCharCode(26)+'\r',
    function(err, result){
        if(err) console.log(err);
        console.log('Result: ' + result);
    });
});

this.queue is empty. Witch raises an error.

send several messages to same recipient with short delay between each message

Hey, sorry me again...
When I send 2 long SMS (ie 3 messages concatenated in one) to same recipient almost simultaneously, my messages are received upside down, ie the beggining of the 1st message is concatenated with the end of the second and so on...
I don't know if this is due to the sender SIM card, the receiver SIM card, the modem.js programm, the phone itself
Any idea of how to avoid that?
thanks

modem no longer responds

Hello Emil,

I found that after a certain execution time, the modem no longer responds? Is it a full buffer problem? or other?
I have to restart regularly features to the catcher sms works.
Have you already seen this problem? Did you reference a modem that everything is working properly?

Happy holidays to you, Hervé

on sms received doesn't work...

Huawei E3131.

var modem = require('modem').Modem();

modem.open('/dev/ttyUSB0', function(){
console.log('open');
modem.on('sms received', function(){
console.log('rcvd');
});
});

When sending sms to the modem number, nothing happens. Modem is opened successfully, as I can send sms. Any idea why and how to debug that?

huwaie e303 modem. Able to send sms; Not able to receive.

Hello Emil,
Thanks for the excellent work.
I am trying simple code to send and receive sms on raspberry pi using e303 modem.
I am able to send the message. But read message returns no messages. Also receive message does not receive any.
If I check the messages with gammu -getallsms, I see all of them on SIM inbox folder.

Regards, Imtiyaz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.