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

Lengthy SMS results in CMS ERROR: 325 #66

Closed jensModvig closed 1 year ago

jensModvig commented 4 years ago

When sending a SMS, with a length of anywhere in-between 142-148 (inclusive) characters, the modem (im using sim800L) sends back "+CMS ERROR: 325", from which i understand is an input-error. According to the internet, the SMS limit is 160 characters, and I believe this might be a serialport-gsm error, I am not sure though, and I might have setup the communication wrong. The module is using firmware version 1418B04SIM800L24 and my serialport-gsm options are:

let options = { baudRate: 115200, dataBits: 8, stopBits: 1, parity: 'none', rtscts: false, xon: false, xoff: false, xany: false, autoDeleteOnReceive: true, enableConcatenation: true, incomingCallIndication: false, incomingSMSIndication: false, pin: '', customInitCommand: '', //logger: console }

On top of that, when sending 141 characters exactly, no error is thrown, but the SMS never gets sent, but anything below that seems to work. I am also able to send longer messages of around 440 characters no problem. Is anyone else experiencing this problem? I apologize if it is a mistake on my part.

jensModvig commented 4 years ago

I just double-checked. I am able to send a message 144 characters long using text-mode and custom written code, but I am not able to do the same using serialport gsm. I would love if somebody could test it too, too see if it is an error caused by SIM800L's PDU mode or a problem with serialport gsm let str = ''; for (let i = 0; i < 144; i++) { str += 'a'; }

zabsalahid commented 4 years ago

Hi @jensModvig ! I'm sorry but I can't help you right now, the devices I use for testing are not with me right now at home. (they're at the office).

twgrops commented 4 years ago

Hi I am having the same issue as @jensModvig. I am able to send a message up to 140 characters fine, 141 no error but does not send and anything larger sends back "+CMS ERROR: 325" input error. The input I tried is just "aaaaaaaaa" repeated.

let options = { baudRate: 9600, dataBits: 8, stopBits: 1, parity: 'none', rtscts: false, xon: false, xoff: false, xany: false, autoDeleteOnReceive: true, enableConcatenation: true, incomingCallIndication: true, incomingSMSIndication: true, pin: '', customInitCommand: '', logger: console }

The device I am using is a Sim800C which is the USB version on COM5 Port.

AlexHodson commented 4 years ago

@zabsalahid I am having the same issue as @twgrops and @jensModvig. Is there any idea on when this will be fixed?

Apollon77 commented 4 years ago

Does someone of you can develop nodejs andcame have a look? I'm sure @zabsalahid is happy to take an PR that fixes it ... else you need to wait till someone finds the time to reproduce it. You could also help by proving example code that always triggs the error . You could enable debug and provide an exact debug log for the issue.

zabsalahid commented 4 years ago

Sorry guys I still can't help you on that. I still don't have access to modem for testing due to this pandemic

AlexHodson commented 4 years ago

No worries, I will do my best to have a look at it over the weekend. If I can fix it, I'll let you know.

twgrops commented 4 years ago

Hi @Apollon77 here is an example of code I was working with

/**
 * Modem.js handles all the settings to run the serial port sim800c device
 * 
 * Code based on serialportgsm node package found https://www.npmjs.com/package/serialport-gsm
 */

const serialportgsm = require('serialport-gsm')

let modem = serialportgsm.Modem()

/**
 * Options for the sim800c controller
 */
let options = {
    // Rate at which information is transferred - 9600 to 115200 bps
    baudRate: 9600,
    // Number of bits for each character - 8bits has become universal as it is a byte - https://en.wikipedia.org/wiki/Serial_port
    dataBits: 8,
    // Stop bits 1 or 2 used for adding processing time with higher baud rates - https://www.mathworks.com/help/instrument/stopbits.html#:~:text=end%20of%20byte-,Description,the%20end%20of%20data%20transmission.
    stopBits: 1,
    parity: 'none',
    // Flow control settings - https://en.wikipedia.org/wiki/Software_flow_control
    rtscts: false,
    xon: false,
    xoff: false,
    xany: false,
    // Delete from our 'sim' after receiving
    autoDeleteOnReceive: true,
    // Allows multi incomming message received to be concatonated
    enableConcatenation: true,
    // Allows indication of call incomming
    incomingCallIndication: true,
    // Allows indication of sms incomming
    incomingSMSIndication: true,
    // If sim card is pin locked enter the pin here
    pin: '',
    // Custom initialise commands - used after pin check - expected to return 'OK' (Empty means no custom command)
    customInitCommand: '',
    // Provide a logger instance, 'debug' is used only to output written and received serial data. Use 'console' for debugging purposes.
    logger: console
}

//Make sure com port is the number in device manager
modem.open('COM4', options,{});

/**
 * Modem is initialised here
 */
modem.on('open',  (data) => {
        // Initialise the modem
        modem.initializeModem((data)=>{
            modem.sendSMS("0749777xxxx", "Test message", false, (data)=>{})
        });
})

/**
 * Export module app
 */
module.exports = modem

Here are some examples to replace and try please make sure phone number is correct

//141 chars and fails error +cms 325 - invalid input
            //modem.sendSMS("0749777xxxx", "This is a long test string for testing the sms. This is a long test string for testing the sms. This is a long test string for testing the sms.", false, (data)=>{})
            //140 chars and works
            modem.sendSMS("0749777xxxx", "This is a long test string for testing the sms. This is a long test string for testing the sms. This is a long test string for testing the s", false, (data)=>{})
Apollon77 commented 4 years ago

I can try to find time after my vacation ... whated to restart my work on this also after the vacation :-) But maybe someone else is faster ;-) @AlexHodson thank you!

jensModvig commented 3 years ago

Any update on when this can be fixed? I have an automatic SMS setup that crashes now and then because of this bug. I really don't want to be annoying, I just wanted to communicate that it is still important, if someone that understand the code can find time.

AlexHodson commented 3 years ago

I haven't been able to resolve the issue yet. Just for clarity @jensModvig, has it ever been able to send large text in your implementations?

jensModvig commented 3 years ago

@AlexHodson Do you mean if it was ever possible to send messages of the length 142-148 (inclusive) characters in previous versions? I don't think so, I don't have any proof that it once worked. I have run my implementation on older versions, but I didn't notice the bug. But I believe I was just lucky, since I didn't send as many messages back then.

AlexHodson commented 3 years ago

I've had another look at this, and I don't think it is anything to do with the serialport-gsm package directly. The package depends on the node-pdu package which seems to be what is causing the problem. I am currently working on a potential fix, will hopefully have a PR soon.

jensModvig commented 3 years ago

I am so happy to hear that!

jensModvig commented 3 years ago

@AlexHodson I just downloaded your pull request from your github, and tried sending a message 144 characters long, sadly It still crashes :( Exactly the same error

AlexHodson commented 3 years ago

@jensModvig it should work for 7 bit and 16 bit. I can see you are using 8 bit. I will have another look for 8 bit messaging

AlexHodson commented 3 years ago

@jensModvig I've tested using 8 bit on my board and it works fine sending standard SMS. Are you trying to send a class 0 message (Flash Message)?

jensModvig commented 3 years ago

@AlexHodson I am sending a normal message. It still doesn't work for me, I have attached a script, to reproduce the error. You have to change two constants (NUMBER and SERIAL_ADDRESS) to make it work for you. testSMS.zip When running the script you should first recieve a SMS saying "hey" followed by an error printed to console (because it tries to send a message of 144 character length)

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Apollon77 commented 3 years ago

really solved?

jensModvig commented 3 years ago

It is not solved

Apollon77 commented 3 years ago

... and I verified it :-)) @zabsalahid can be closed!

hippyaki commented 2 years ago

For those, facing issue from AT Command,

Use AT+CMGF=1 to change to Text Mode.

Then, you can continue on your message depending on the carrier service.

Apollon77 commented 1 year ago

@zabsalahid can be closed

Klylylydeee commented 1 year ago

I still can't send sms length that is over 140+. May I know the changes needed for this to work?

Apollon77 commented 1 year ago

Please provide a Debug log