How does the cellular radio?

Hello,

I buy a cellular radio module and I tried to find code on the internet.
I have not managed to make it work without.
I just wish I could send sms.
There is a pin code for my sim card.

Someone would have a functional code for offer me ?

here’s what I’ve trying to code but its not working :


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.Seeed;

namespace gsm
{
    public partial class Program
    {
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            cellularRadio.DebugPrintEnabled = true;
            cellularRadio.PowerOn(50);

            cellularRadio.SmsReceived += new CellularRadio.SmsReceivedHandler(cellularRadio_NewSMSEvent);
            cellularRadio.SmsRetrieved += new CellularRadio.SmsRetrievedHandler(cellularRadio_SMSReady);
            cellularRadio.ModuleInitialized += new CellularRadio.ModuleInitializedHandler(cellularRadio_ModuleInitialized);
            cellularRadio.PinStateRetrieved += new CellularRadio.PinStateRetrievedHandler(cellularRadio_PINEvent);

            cellularRadio.GprsNetworkRegistrationChanged += new CellularRadio.GprsNetworkRegistrationChangedHandler(cellularRadio_GprsNetworkRegistrationChanged);
            cellularRadio.GsmNetworkRegistrationChanged += new CellularRadio.GsmNetworkRegistrationChangedHandler(cellularRadio_GsmNetworkRegistrationChanged);
            cellularRadio.OperatorRetrieved += new CellularRadio.OperatorRetrievedHandler(cellularRadio_OperatorReady);
            Thread powerOnThread = new Thread(new ThreadStart(PowerOnSequenceThread));
            powerOnThread.Start();  
        }

        private void PowerOnSequenceThread()
        {

            cellularRadio.SendATCommand("AT+CPIN?");

            cellularRadio.SendATCommand("AT+CMGR");

            /*cellularRadio.SendATCommand("AT+CREG?");*/
            /*cellularRadio.SendATCommand("AT");

            // Enable GSM network registration status
            cellularRadio.SendATCommand("AT+CREG=1");

            // Enable GPRS network registration status
            cellularRadio.SendATCommand("AT+CGREG=1");

            //Set SMS mode to text
            cellularRadio.SendATCommand("AT+CMGF=1");


            cellularRadio.SendATCommand("AT+CSDH=0");
            // Set the phonebook to be stored in the SIM card
            cellularRadio.SendATCommand("AT+CPBS=\"SM\"");
            // Set the sms to be stored in the SIM card
            cellularRadio.SendATCommand("AT+CPMS=\"SM\"");
            cellularRadio.SendATCommand("AT+CNMI=2,1,0,1,0");
            //// Sets how connected lines are presented
            cellularRadio.SendATCommand("AT+COLP=1");*/
            
           

            /*cellularRadio.SendSms("0786064268", "coucouc");*/

        }

        void cellularRadio_GsmNetworkRegistrationChanged(CellularRadio sender, CellularRadio.NetworkRegistrationState networkState)
        {
            if (Enum.Equals(networkState, CellularRadio.NetworkRegistrationState.Registered))
            { Debug.Print("NetworkRegistrationState -->" + networkState.ToString()); }
            Debug.Print("NetworkRegistrationState           ++>" + networkState.ToString());

            cellularRadio.SendSms("0786064268", "CellTest message");
        }

        void cellularRadio_GprsNetworkRegistrationChanged(CellularRadio sender, CellularRadio.NetworkRegistrationState networkState)
        {
            cellularRadio.SendSms("0786064268", "CellTest message");
        }

        void cellularRadio_OperatorReady(CellularRadio sender, string operatorName)
        {
            if (operatorName != null)
                Debug.Print("OPERATOR: " + operatorName);
            else
                Debug.Print("NO OPERATOR WAS FOUND");
        }



        void cellularRadio_PINEvent(CellularRadio sender, CellularRadio.PINState pinState)
        {
            Debug.Print("PIN: " + pinState);

            if (Enum.Equals(pinState, CellularRadio.PINState.PIN))
            {
                Debug.Print("Module initialized, sending PIN...");
                cellularRadio.SendATCommand("AT+CPIN=7415");
            } 
        }

        void cellularRadio_ModuleInitialized(CellularRadio sender)
        {
            Debug.Print("MODULE INITIALIZED");
        }

        void cellularRadio_SMSReady(CellularRadio sender, CellularRadio.Sms message)
        {
            Debug.Print("SMS READY");
        }

        void cellularRadio_NewSMSEvent(CellularRadio sender, CellularRadio.Sms message)
        {
            Debug.Print("SMS NEW EVENT");
        }

    }
}

Here the error returns me the consol :


CellularRadio : Turning ON
CellularRadio : Turning module on
CellularRadio : SENT: AT

CellularRadio : <AT

OK
>
CellularRadio : SENT: AT+CMGF=1

CellularRadio : <AT+CMGF=1

OK
>
CellularRadio : SENT: AT+CSDH=0

CellularRadio : SENT: AT+CPBS="SM"

CellularRadio : <AT+CSDH=0

ERROR
AT+CPBS="SM"

ERROR
>
CellularRadio : SENT: AT+CPMS="SM"

CellularRadio : SENT: AT+CNMI=2,1,0,1,0

CellularRadio : <AT+CPMS="SM"

ERROR
AT+CNMI=2,1,0,1,0

ERROR
>
CellularRadio : SENT: AT+COLP=1

CellularRadio : SENT: AT+CGREG=1

CellularRadio : <AT+COLP=1

ERROR
AT+CGREG=1

OK
>
CellularRadio : SENT: AT+CREG=1

Le thread '<Sans nom>' (0x5) s'est arrêté avec le code 0 (0x0).
CellularRadio : <AT+CREG=1

OK
>

@ andre.m -

Thank you for your reply, but I had already seen this post and it helps me not for what I want to do.

I just want to send and receive SMS.

@ andre.m -

when I init the module there are AT command are sent. We can see that I have a following error sends its order, so this is why I can not send SMS.

I want to know how to solve them and if anyone have any idea ?

Alicorne, the issue you need to resolve is to look at the detail in the datasheet that shows what the command is doing when it fails, and resolve that error. The other thread, http://ghielectronics.com/community/forum/topic?id=11774&page=1 explicitly has the same error and you need to step through each command and see what is going on as each occurs.

1 Like

As far as I recall, the provided Seeed driver works out of the box for SMS.

It’s best to disable the PIN code using a phone before trying to resolve this.

Also, your thread does not seem to wait until the module is power up and ready (you’ve specified 50s).

1 Like

I disable the PIN code and everything works fine.
I can finally send SMS and make called.

Thank you for your reply.

Could you please post your code snippets?
So I can check why my code doesnt work.
Merci beaucoup

please stop posting in 2 year old threads and expecting someone to respond. Please start your own thread, just one, and ask your question there. We’ll all help, it’s just better to let archived threads stay archived :wink: