1

Im attempting to send a multi part message with at commands, single part works fine and so do special characters but when its multi part so more than 160 characters it says its sent but nothing is received.

async  sendSMS(msisdn, message) {
    message += " ";
    
    // Determine if message uses characters outside the GSM 7-bit default alphabet
    const useUCS2 = !isGSMCharacterSet(message);

    // Set character set based on message content
    const characterSet = useUCS2 ? GSM.CharacterSet.UCS2 : GSM.CharacterSet.GSM;
    await this.setCharacterSet(characterSet);

    await this.setMessageFormat(GSM.MessageFormat.PDU);

    // Generate PDUs for the message. Assume generateSubmit handles segmentation if needed.
    const encoding = useUCS2 ? 'ucs2' : 'gsm';
    const pdus = smsPdu.generateSubmit(msisdn, message, { encoding });

    // Send each PDU segment sequentially
    const results = [];
    for (const pdu of pdus) {
        // Send length of the PDU in bytes, not the message length
        let length = pdu.length
        
        await this.runCommand(`AT+CMGS=${length}`);
        // Send the PDU and store the result
        const result = await this.runCommand(`${pdu.hex}${CTRL_Z}`);
        if (result.startsWith('+CMGS:')) {
            console.log('Segment sent successfully:', result);
        } else {
            console.error('Error sending segment:', result);
            break; // Consider handling this situation more gracefully
        }
        await new Promise(resolve => setTimeout(resolve, 5000)); // Wait 2 seconds before sending the next part
        results.push(result);
    }

    return (results, pdus);
}

Thats my code to send commands its a fork of NodeGSM Module and im using node-sms-pdu to create the pdu This is the response from the server including the pdus but nothing is received Sending SMS COM18 79429010 testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest

Segment sent successfully: +CMGS: 149 Segment sent successfully: +CMGS: 150 Checking status for COM17 Sending SMS COM18 79429010 testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest

Segment sent successfully: +CMGS: 149 Segment sent successfully: +CMGS: 150 Checking status for COM17

response2: [ { buffer: <Buffer 00 41 00 08 81 97 24 09 01 00 00 a0 05 00 03 00 02 01 e8 e5 39 9d 5e 9e d3 e9 e5 39 9d 5e 9e d3 e9 e5 39 9d 5e 9e d3 e9 e5 39 9d 5e 9e d3 e9 e5 39 9d ... 102 more bytes>, hex: '0041000881972409010000A0050003000201E8E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9E5399D5E9ED3E9', length: 151, encoding: 'gsm' }, { buffer: <Buffer 00 41 00 08 81 97 24 09 01 00 00 17 05 00 03 00 02 02 ca 73 3a bd 3c a7 d3 cb 73 3a bd 3c a7 83 00>, hex: '004100088197240901000017050003000202CA733ABD3CA7D3CB733ABD3CA78300', length: 32, encoding: 'gsm' } ]

Message sent successfully to 79429010 from COM18. Message sent successfully to 79429010 from COM18.

Tried changing the timings between each message, changed the different modes, changed formatting of number or message and still nothing

2
  • Inside runCommand are you reading and parsing the responses sent back by the device or is it waiting by time? Commented Feb 8, 2024 at 18:20
  • Its reading and parsing the repsonse, when sending the messages it always responsds that it sent successfuly and the index of the message, today i noticed that when its a new sim card, the card will send a concatenated message successfuly to a number, but it wont send it a second time or ever again to the same number. New number = works, same number twice doesnt work Commented Feb 10, 2024 at 16:53

1 Answer 1

0

Solved - Issue was that node-gsm-pdu wasnt creating unique reference numbers, so i just changed the value from 00 to unique numbers everytime.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.