How to use Cellular Radio module

Hi!

I’m using FEZ Spider with .NET Micro Framework 4.1. I have downloaded the CellularRadio.cs file from Gadgeteer site on CodePlex and I have manually added it to my project.

I have written the following code:


// This method is run when the mainboard is powered up or reset.   
void ProgramStarted()
{
    cellularRadio = new CellularRadio(4);
    cellularRadio.DebugPrintEnabled = true;
    cellularRadio.PowerOn(5);

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

    // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
    Debug.Print("Program Started");
}

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

void cellularRadio_SMSReady(CellularRadio sender, CellularRadio.Sms message)
{
    if (message != null)
    {
        Debug.Print("RETRIEVED");
        Debug.Print("FROM: " + message.TelephoneNumber);
        Debug.Print("MSG: " + message.TextMessage);
        Debug.Print("WHEN: " + message.Timestamp);
        Debug.Print("STATUS: " + message.Status);
        Debug.Print("POS:" + message.Index);
    }
}

void cellularRadio_NewSMSEvent(CellularRadio sender, CellularRadio.Sms message)
{
    if (message != null)
    {
        Debug.Print("NEW SMS");
        Debug.Print("FROM: " + message.TelephoneNumber);
        Debug.Print("MSG: " + message.TextMessage);
        Debug.Print("WHEN: " + message.Timestamp);
        Debug.Print("STATUS: " + message.Status);
        Debug.Print("POS:" + message.Index);
    }
}

When I start the program, I can see the following messages in the output Window of Visual Studio:


CellularRadio : Turning ON
CellularRadio : Turning module on
CellularRadio : <
RDY
>
CellularRadio : <
+CFUN: 1

+CPIN: READY
>
CellularRadio : <AT

OK
>
CellularRadio : SENT: AT

CellularRadio : SENT: AT+CMGF=1

CellularRadio : <AT+CMGF=1

OK
>
CellularRadio : SENT: AT+CSDH=0

CellularRadio : SENT: AT+CPBS="SM"

CellularRadio : <AT+CSDH=0

OK
AT+CPBS="SM"

OK
>
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

OK
>
CellularRadio : SENT: AT+COLP=1

CellularRadio : SENT: AT+CGREG=1

CellularRadio : <AT+COLP=1

OK
AT+CGREG=1

OK
>
CellularRadio : SENT: AT+CREG=1

CellularRadio : <AT+CREG=1

OK
>
CellularRadio : <
+CREG: 0
>
CellularRadio : <
+CREG: 2
>
CellularRadio : <
+CREG: 1

+CGREG: 0
>

After that, If I try to send a SMS to the number of the SIM that I habe inserted in the module, nothing happens. I’m using an Italian telephone operator, if this matters.

Must I do some other initialization before using the module?

Thanks for the attention.

Why are you manually adding code instead of using the drivers thought eh designer?

Because I’m using the last stable version of .NET Gadgeteer SDK available at Support – GHI Electronics, dated Apr. 23, 2012, that doesn’t include the Cellular Radio module driver. In this post: http://www.tinyclr.com/forum/topic?id=7966 it has been told me that, if I want to use the new Gadgeteer package available at CodePlex, I need to install .NET Micro Framework 4.2 for my Spider, that is currently in beta.

I don’t want to install this beta, I would like to wait for the stable version. But, in the mean time, I would like to try the Cellular Radio module, so I have manually added the driver code to my project.

4.1 already have everything

4.2 release coming this week will include all modules

I’m currently using the package avaiable at Support – GHI Electronics, dated Apr. 23, 2012, and in the Visual Studio Designer I can’t see the Cellular Radio module.

I see. Please install 4.2 but keep on using 4.1. The beta SDK has both

OK, I’ll give it a try.

Thank you for the help, I’ll keep you informed about the issue.

Marco, out of interest do you need a PIN for your SIM card? There was another thread last week about when that was required and I don’t think the driver did that.

Edit: here’s the post http://www.tinyclr.com/forum/topic?id=7838&page=1 and it goes full circle since it talks about your blog posting on Mike’s website :slight_smile:

Hi Brett!

No PIN is need for my SIM card.

I also put this in the other thread … I downloaded the drivers from the Seeed site directly and was able to send/receive SMS messages in a very plug/play manner.

Thank you, I’m downloading the driver, tonight I will try it!