lsongdev/node-gsm

是否支持发送中文短信?

Closed this issue · 5 comments

houaq commented

如题。
把example里的消息内容直接改成中文好像不行,收到中文是乱码。

Any questions ?

houaq commented

I modified the example/index.js as following:

modem.open(async () => {

  await modem.reset()
  await modem.sms_mode(1)
  await modem.sms_send(
    '+8613833110268',
    '中文测试This is a test from gsm2',
		'utf8'
  );

});

The source file is encoded by utf-8, but problem remains:
_20180706162617

use PDU mode and try again ?

houaq commented

How to set PDU mode? Is there an option?

AT Commands Reference Guide

AT+CMGF[= [<mode>]]
Set command selects the format of messages used with send, list, read and write commands.
Parameter:
<mode>
0 - PDU mode, as defined in GSM 3.40 and GSM 3.41 (factory default) 
1 - text mode
Note: issuing AT+CMGF<CR> is the same as issuing the Read command.
Note: issuing AT+CMGF=<CR> is the same as issuing the command AT+CMGF=0<CR>.

In gsm modem api:

const SMS_MODE = {
  PDU: 0,
  TEXT: 1
};
await modem.sms_mode(SMS_MODE.PDU);
await modem.sms_send('phone number', 'pdu string');