CellularRadio is not orking

Hi there,

After creating a project with FEZ Spider and copying all the code in the CellularRadio example at the modules site:

void ProgramStarted()
{
NetworkChange.NetworkAvailabilityChanged += (a, b) => Debug.Print("Network availability changed: " + b.IsAvailable.ToString());
NetworkChange.NetworkAddressChanged += (a, b) => Debug.Print(“Network address changed”);

        this.cellularRadio.ModuleInitialized += this.cellularRadio_ModuleInitialized;

        this.cellularRadio.PowerOn(30);

}

I got an DHCP IP, but after that the following message appears:

Network address changed
Network availability changed: True
186.168.99.233
#### Exception System.NotSupportedException - 0x00000000 (26) ####
#### Message:
#### System.Net.InputNetworkStreamWrapper::get_Position [IP: 0003] ####
Uncaught exception

Can somebody help me?.

Thanks.

I know nothing about this module, but to diagnose it I would suspect you need to show us the code in cellularRadio_ModuleInitialized(). Can you make sure you add a debug.print in the top of that so you know it gets hit, and it’s probably worth putting a breakpoint there and stepping into it - I am assuming that this is the code that’s generating the exception rather than the driver, but that obviously could be wrong.

Hi Brett,

Here is the complete code:

using Gadgeteer.Modules.GHIElectronics;
using GHI.Networking;
using Microsoft.SPOT;
using Microsoft.SPOT.Net.NetworkInformation;
using System.Net;
using System.Text;
using System.Threading;
using Gadgeteer.Modules.GHIElectronics;


namespace SampleCellRadio
{
    public partial class Program
    {
        void ProgramStarted()
        {
            NetworkChange.NetworkAvailabilityChanged += (a, b) => Debug.Print("Network availability changed: " + b.IsAvailable.ToString());
            NetworkChange.NetworkAddressChanged += (a, b) => Debug.Print("Network address changed");

            this.cellularRadio.ModuleInitialized += this.cellularRadio_ModuleInitialized;

            this.cellularRadio.PowerOn(30);
        }

        void cellularRadio_ModuleInitialized(CellularRadio sender)
        {
            new Thread(() =>
            {
                Thread.Sleep(15000);

                this.cellularRadio.UseThisNetworkInterface("internet.movistar.com.co", "movistar", "movistar", PPPSerialModem.AuthenticationType.Pap);

                while (this.cellularRadio.NetworkInterface.IPAddress == "0.0.0.0")
                {
                    Debug.Print("Waiting on DHCP");
                    Thread.Sleep(250);
                }

                Debug.Print(cellularRadio.NetworkInterface.IPAddress);

                using (var req = HttpWebRequest.Create("http://www.ghielectronics.com/") as HttpWebRequest)
                {
                    req.KeepAlive = false;
                    req.ContentLength = 0;

                    using (var res = req.GetResponse() as HttpWebResponse)
                    {
                        using (var stream = res.GetResponseStream())
                        {
                            int read = 0, total = 0;
                            var buffer = new byte[1024];

                            do
                            {
                                read = stream.Read(buffer, 0, buffer.Length);
                                total += read;

                                Thread.Sleep(20);
                            } while (read != 0);

                            Debug.Print(new string(Encoding.UTF8.GetChars(buffer)));
                        }
                    }
                }
            }).Start();
        }
    }
}

Actually it was published at the CellRadio GHIElectronics site.

Thanks and I really apreciate any help!

@ r.ricardog.
You can test with my code https://www.ghielectronics.com/community/forum/topic?id=17217&page=3#msg172260

@ r.ricardog.
To have your C# code readable you must select it and click on the icon “101010”

2 Likes