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

+CMS ERROR: 69 #61

Closed 0wx closed 4 years ago

0wx commented 4 years ago

Hai, I currently got this issue while I'm trying to send message

{ status: 'fail',
  request: 'SendSMS',
  data:
   { messageId: 'SU4RVub9mcBTX81YPvdFEoukx',
     message: 'Hello',
     recipient: '+628999999', 
     response: 'Message Failed +CMS ERROR: 69' } }

My code is down bellow:

const serialportgsm = require('serialport-gsm');

var gsmModem = serialportgsm.Modem()
let options = {
    baudRate: 115200,
    dataBits: 8,
    parity: 'none',
    stopBits: 1,
    xon: false,
    rtscts: false,
    xoff: false,
    xany: false,
    autoDeleteOnReceive: true,
    enableConcatenation: true,
    incomingCallIndication: true,
    incomingSMSIndication: true,
    pin: '',
    customInitCommand: 'AT^CURC=0'
}

let phone = {
    name: "My-Name",
    number: "+62899999",
    message: "My message",
    mode: "PDU"
}

// Port is opened
gsmModem.on('open', () => {
    console.log(`Modem Sucessfully Opened`);

    // now we initialize the GSM Modem
    gsmModem.initializeModem((msg, err) => {
        if (err) {
            console.log(`Error Initializing Modem - ${err}`);
        } else {
            console.log(`InitModemResponse: ${JSON.stringify(msg)}`);

            console.log(`Configuring Modem for Mode: ${phone.mode}`);
            // set mode to PDU mode to handle SMS
            gsmModem.setModemMode((msg, err) => {
                if (err) {
                    console.log(`Error Setting Modem Mode - ${err}`);
                } else {
                    console.log(`Set Mode: ${JSON.stringify(msg)}`);
                    gsmModem.sendSMS(phone.number, phone.message, false, (result) => {
                        console.log(result);
                    });

                }
            }, 'PDU')

        }
    });

    gsmModem.on('onNewMessageIndicator', data => {
        //indicator for new message only (sender, timeSent)
        console.log(`Event New Message Indication: ` + JSON.stringify(data));
    });

    gsmModem.on('onNewMessage', data => {
        //whole message data
        console.log(`Event New Message: ` + JSON.stringify(data));
    });

    gsmModem.on('onSendingMessage', data => {
        //whole message data
        console.log(`Event Sending Message: ` + JSON.stringify(data));
    });

    gsmModem.on('onNewIncomingCall', data => {
        //whole message data
        console.log(`Event Incoming Call: ` + JSON.stringify(data));
    });

    gsmModem.on('onMemoryFull', data => {
        //whole message data
        console.log(`Event Memory Full: ` + JSON.stringify(data));
    });

    gsmModem.on('close', data => {
        //whole message data
        console.log(`Event Close: ` + JSON.stringify(data));
    });

});

gsmModem.open('COM24', options);

setTimeout(() => {
    gsmModem.close(() => process.exit);
}, 90000);

Hopefully you can help me, thanks!

Apollon77 commented 4 years ago

According to http://www.micromedia-int.com/es/other/73-english/support-en/faq/gsm/670-cms-error-gsm-network-related-errors this error means:

Requested facility not implemented

SO it seems that you want to use a fetaure which is not implemented by your modem

0wx commented 4 years ago

Thank you for replying me @Apollon77 So how do I send a sms using my modem? I'm currently using Wavecom Q2406B, Or is there another mode beside PDU?

stale[bot] commented 4 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.

0wx commented 4 years ago

I changes the baudRate to 9600 and it's working!