Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onNewMessage and onNewMessageIndicator never fired #1

Closed
slachtar opened this issue Feb 4, 2019 · 11 comments
Closed

onNewMessage and onNewMessageIndicator never fired #1

slachtar opened this issue Feb 4, 2019 · 11 comments

Comments

@slachtar
Copy link

slachtar commented Feb 4, 2019

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 zabsalahid pinned this issue Feb 5, 2019
@zabsalahid
Copy link
Owner

zabsalahid commented Feb 5, 2019

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')
})

@zabsalahid zabsalahid unpinned this issue Feb 5, 2019
@slachtar
Copy link
Author

slachtar commented Feb 5, 2019

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
Copy link
Owner

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

@slachtar
Copy link
Author

slachtar commented Feb 6, 2019

@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
Copy link
Owner

@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
Copy link
Author

slachtar commented Feb 7, 2019

@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
Copy link
Owner

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

@zabsalahid
Copy link
Owner

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

@slachtar
Copy link
Author

slachtar commented Feb 12, 2019 via email

zabsalahid pushed a commit that referenced this issue Mar 5, 2019
@iamqinglong
Copy link

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

@cuongdev
Copy link

cuongdev commented Jul 7, 2019

These event is not working. How to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants