I am using nodejs and serial-port npm package to connect my smartphone via the com port. I am sending sms using AT commands. The problem I am facing is that it only send sms when there is no empty character in the string. e.g "myTest" will be sent but "my Test" does not get sent and gives error. Here is my code.
const SerialPort = require('serialport');
const serialPort = new SerialPort('myComPort');
serialPort.on('open', () => {
serialPort.write('AT+CMGF=1\r'); // set SMS text mode
serialPort.write('AT+CMGS="02122323232"\r'); // send sms message
serialPort.write('my' + ' ' +String.fromCharCode(26)+'Test' + ' '+ String.fromCharCode(26)+'STring\r\n');
serialPort.write('\x1A');
serialPort.write('^z');
});
How I can send string with spaces as sms.