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

Not able to getSimInbox or onNewMessage #70

Closed TimDaub closed 3 years ago

TimDaub commented 3 years ago

Hi,

a few days ago I got good results with this library, e.g. I was able to get a response from modem.on("onNewMessage"). Now, when I run the script in /examples of this repo, I can send messages.

However, when I try getting messages in my inbox through:

modem.on("onNewMessage", console.log);
modem.getSimInbox(console.log)
// {"status":"success","request":"getSimInbox","data":[]}
modem.executeCommand('AT+CPMS="SM"', console.log);
// {"status":"success","request":"executeCommand","data":{"result":" 0,20,0,20,0,20"}}
modem.executeCommand('AT+CPMS="ME"', console.log);
// Result {"status":"success","request":"executeCommand","data":{"result":" 0,20,0,20,0,20"}}
modem.executeCommand('AT+CPMS="MT"', console.log);
//{"status":"ERROR","request":"executeCommand","data":"Execute Command returned Error: +CMS ERROR: 302"}

I checked this page too already: https://www.developershome.com/sms/cpmsCommand.asp I'm using a Huawei E3531i-2. My options are

const { SIM_PIN } = process.env;
module.exports = {
  baudRate: 115200,
  dataBits: 8,
  stopBits: 1,
  parity: "none",
  rtscts: false,
  xon: false,
  xoff: false,
  xany: false,
  autoDeleteOnReceive: true,
  enableConcatenation: true,
  incomingCallIndication: true,
  incomingSMSIndication: true,
  pin: SIM_PIN,
  customInitCommand: "",
  logger: console
};
$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 006: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Any ideas?

TimDaub commented 3 years ago

Actually, it was my dongle that was not in the correct usb mode. For anyone wondering how to setup a Huawei E3531: https://github.com/TimDaub/http-sms-gateway/blob/master/docs/setup.md#setting-up-the-huawei-e3531-mobile-network-dongle