arrigonfr arrigonfr - 2 months ago 17
Javascript Question

Send SMS with Node.JS SerialPort

I'm trying to do what the title says using an enfora modem for that purpose. However, even though it works correctly in minicom, it won't work in my node.js application.
Here's the code that I'm using:

serialPort.write('AT+CMGF=1\r');
serialPort.write('AT+CMGS="02122323232"\r');
serialPort.write('mensaje'+String.fromCharCode(26)+'\r');


I've also tried replacing String.fromCharCode(26) with the following options. none of which has worked.

'\^z'
'^z'
'^(z)'
'\^(z)'
'<ctrl+Z>'
'<ctrl-Z>'
'\#'
'#'
'\u001A'
Buffer([0x1A])


I sincerely believe that this is the problematic part of the code, because i get an OK message from the first 2 lines, but the third one returns nothing, because it doesn't get processed.

Any help on this would be appreciated.

Answer
    setTimeout(function(){
        serialPort.write('AT+CMGF=1\r')
        setTimeout(function(){
            serialPort.write('AT+CMGS=\"02142323232\"\r')
            setTimeout(function(){
                serialPort.write('test sms\r')
                setTimeout(function(){
                    serialPort.write('\x1A')
                }, 100);
            }, 100);
         }, 100);
     }, 100);