emilsedgh / modem

Send and receive messages and make ussd queries using your GSM modems
161 stars 68 forks source link

Random behaviour fr receiving messages #5

Open alexislg2 opened 10 years ago

alexislg2 commented 10 years ago

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 ?

emilsedgh commented 10 years ago

Use something like the following code to see if the modem port is opened and still operational:

function checkModem() {
  var c = modem.execute('AT', function() {
    console.log('AT Test response', arguments);
  });

  c.on('timeout', function() {
    console.log('AT Test timed out');
  });
}
setInverval(checkModem, 120000);
alexislg2 commented 10 years ago

Thanks! Have you ever experienced this problem? If so, do you know what is the cause of this? By the way, what can I do when I detect a timeout to reload the modem?

alexislg2 commented 10 years ago

I found out why this happened. It's because the modem seems to 'forget' that we have registered for sms notifications I need to put this in a regular interval to fix this problem this.execute('AT+CNMI=2,1,0,2,0');

emilsedgh commented 10 years ago

This is weird. Never had such issue. Glad to see your problem fixed :)