zabsalahid / serialport-gsm

SerialPort-GSM is a simplified plugin for communicating with gsm modems. (Primarily for sms) (Focused in PDU mode)
MIT License
90 stars 47 forks source link

onNewMessage and onNewMessageIndicator never fired #1

Closed slachtar closed 5 years ago

slachtar commented 5 years ago

Hello, first I'd like to thank your for this module. I'm testing it under windows with a Huawei gsm modem, I can send messages with sendSMS function, but I was enable to receive messages and the onNewMessage and onNewMessageIndicator are never fired.

Notice: getSimInbox() function shows the list of messages including the one I sent. Any suggestion please?

Thank you,

Here's my code:

let serialportgsm = require('serialport-gsm');

var firstPort;

let modem = serialportgsm.Modem();

let options = {
    baudRate: 115200,
    dataBits: 8,
    parity: 'none',
    stopBits: 1,
    flowControl: false,
    xon: false,
    rtscts: false,
    xoff: false,
    xany: false,
    buffersize: 0
}

serialportgsm.list((err, result) => {
    firstPort = result[0].comName;
    console.log("Port to be used: ", firstPort);

    modem.open(firstPort, options, function(err){
        if (err) {
            console.log("Error opening port:", err);
        }
    });
})

modem.on('open', data => {
    console.log("Port opened.");
    modem.initializeModem( res => {
        console.log("Modem initialized.\n");

        modem.getSimInbox(function(res){
                console.log("inbox:", res);
        });
    })
})

modem.on('close', result => {
    console.log("Port closed");
})

modem.on('error', err => {  
    console.log("Error", err);
})

modem.on('onSendingMessage', result => { 
    console.log("Sending progress:", result); 
})

modem.on('onNewMessageIndicator', result => { 
    console.log("new msg indicator:", result);
})

modem.on('onNewMessage', messageDetails => {
    console.log("new msg: ", messageDetails);
})
zabsalahid commented 5 years ago

Hello @slachtar !

Thanks for trying out serialport-gsm!

I tried your code and I got an error as a result in calling getSimInbox(). Previously I removed setModemMode as I defaulted it to PDU mode on open. It seems it works/does not work on some gsm.

Can you please try this code and check if it works?

modem.on('open', data => {
  console.log("Port opened.");
  modem.initializeModem(res => {
    console.log("Modem initialized.\n");
  })
  modem.setModemMode(res => {
    console.log(res)
    modem.getSimInbox(function(res) {
      console.log("inbox:", res);
    });
  }, 'PDU')
})
slachtar commented 5 years ago

Hello, thanks for the feedback, here's the output I've got: notice: still the onNewMessage not fired.

Port to be used:  COM30
Port opened.
Modem initialized.

{ status: 'success', request: 'modemMode', data: 'PDU_Mode' }
unsupported sender type.
unsupported sender type.
unsupported sender type.
unsupported sender type.
unsupported sender type.
inbox: { status: 'success',
  request: 'getSimInbox',
  data:
   [ { sender: null,
       message: null,
       index: 0,
       dateTimeSent: 0019-11-30T00:00:00.473Z,
       dateTimeReceived: 2019-02-05T10:55:03.474Z,
       header: [Object] },
     { sender: null,
       message: null,
       index: 1,
       dateTimeSent: 0019-11-30T00:00:00.475Z,
       dateTimeReceived: 2019-02-05T10:55:03.476Z,
       header: [Object] },
     { sender: null,
       message: null,
       index: 2,
       dateTimeSent: 0019-11-30T00:00:00.476Z,
       dateTimeReceived: 2019-02-05T10:55:03.476Z,
       header: [Object] },
     { sender: null,
       message: null,
       index: 3,
       dateTimeSent: 0019-11-30T00:00:00.477Z,
       dateTimeReceived: 2019-02-05T10:55:03.477Z,
       header: [Object] },
     { sender: 'xxxxxxxx',
       message: 'Ok',
       index: 4,
       dateTimeSent: 2019-02-04T15:22:44.477Z,
       dateTimeReceived: 2019-02-05T10:55:03.478Z,
       header: [Object] },
     { sender: null,
       message: null,
       index: 5,
       dateTimeSent: 0019-11-30T00:00:00.478Z,
       dateTimeReceived: 2019-02-05T10:55:03.479Z,
       header: [Object] },
     { sender: 'xxxxxxxx',
       message: 'Ok',
       index: 6,
       dateTimeSent: 2019-02-04T15:27:32.479Z,
       dateTimeReceived: 2019-02-05T10:55:03.480Z,
       header: [Object] },
     { sender: '21698221575',
       message: 'hihihh',
       index: 7,
       dateTimeSent: 2019-02-04T15:29:32.480Z,
       dateTimeReceived: 2019-02-05T10:55:03.480Z,
       header: [Object] },
     { sender: 'xxxxxxxx',
       message: 'hih',
       index: 8,
       dateTimeSent: 2019-02-04T15:30:26.481Z,
       dateTimeReceived: 2019-02-05T10:55:03.481Z,
       header: [Object] },
     { sender: 'xxxxxxxx',
       message: 'gigiggg',
       index: 9,
       dateTimeSent: 2019-02-05T10:54:06.481Z,
       dateTimeReceived: 2019-02-05T10:55:03.481Z,
       header: [Object] } ] }
zabsalahid commented 5 years ago

@slachtar What version are you using? I already updated the package to 1.4.7.

slachtar commented 5 years ago

@zabsalahid updated to the latest version, results are shown below:

Port to be used:  COM30
Port opened.
Modem initialized.

{ status: 'success', request: 'modemMode', data: 'PDU_Mode' }
unsupported sender type.
unsupported sender type.
unsupported sender type.
unsupported sender type.
unsupported sender type.
unsupported sender type.
inbox: { status: 'success',
  request: 'getSimInbox',
  data:
   [ { sender: null,
       message: null,
       index: 0,
       dateTimeSent: 0019-11-30T00:00:00.008Z,
       dateTimeReceived: 2019-02-06T09:49:51.008Z,
       header: [Object] },
     { sender: null,
       message: null,
       index: 1,
       dateTimeSent: 0019-11-30T00:00:00.009Z,
       dateTimeReceived: 2019-02-06T09:49:51.009Z,
       header: [Object] },
     { sender: null,....
zabsalahid commented 5 years ago

@slachtar is onNewMessage never fired at any message received? or only on messages received with 'unsupported sender typeornull` sender? I'm having trouble figuring out why the event is never fired on your end.

slachtar commented 5 years ago

@zabsalahid it's never fired even with messages with unsupported sender type or null sender. If you want I can give you a teamviewer access to check the problem directly.

BTW, same modem is working great with this module: https://github.com/emilsedgh/modem

Thank you

zabsalahid commented 5 years ago

@slachtar sure! I'd like to check it directly. you can reach me at zabsalahid@gmail.com

zabsalahid commented 5 years ago

@slachtar https://github.com/emilsedgh/modem last commit was Apr 13, 2017 😢

slachtar commented 5 years ago

:) I think it's alive because it's based on serialPort which is very active and also AT commands didn't changed since decades.

On Sat, Feb 9, 2019 at 3:35 PM Zab Salahid notifications@github.com wrote:

@slachtar https://github.com/slachtar https://github.com/emilsedgh/modem last commit was Apr 13, 2017 😢

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/zabsalahid/serialport-gsm/issues/1#issuecomment-462049518, or mute the thread https://github.com/notifications/unsubscribe-auth/ACaj6rfywU_pYi2PELhGwkba-qeLeJNiks5vLtywgaJpZM4ahdkL .

-- Slah Lachtar Tel. (+216) 98 221 575

iamqinglong commented 5 years ago

How to solve this ? I'm having this problem too.

cuongdev commented 5 years ago

These event is not working. How to solve this?