6 Replies Latest reply on Feb 4, 2013 6:11 AM by Bo Nielsen

    Getting WWAN network type in a C# application

    Bo Nielsen

      I looking for a way to programmatically retrieve the WWAN (GSM) network type that a device is currently connected to i.e.

      • GPRS
      • EDGE
      • 3G / UMTS
      • HSDPA

       

      Preferably in C#.

       

      I can see the type on the icon at the top of the WM6.5 (MC75a) screen so the OS must know.

       

      I could only find this be searching and it looks quite complicated

      http://social.msdn.microsoft.com/Forums/en/windowsmobiledev/thread/afad3f0f-6d3f-4a50-bc15-13c57803100d

        • Re: Getting WWAN network type in a C# application
          Hayden Eastman

          Yeah,

          It's not simple.  I've only done it via C++ and you have to use the ConnectionManager APIs to do it.  Take a look at the MSDN documentation on Connection Manager here http://msdn.microsoft.com/en-us/library/bb416435.aspx

          • Re: Getting WWAN network type in a C# application

            Hi,

            You can use this code :

             

              var connectionState = new SystemState(SystemProperty.ConnectionsCellularCount);
                    connectionState
            .Changed += (o, s) =>
                       
            {

                 if (SystemState.CellularSystemConnectedUmts)
              
            {
              
            // show 3G Icon
              
            }


                           
            if (SystemState.CellularSystemConnectedHsdpa)
                           
            {
                               
            // show H Icon
                           
            }
                           
            else if (SystemState.CellularSystemConnectedGprs)
                           
            {
                               
            // show GPRS Icon
                           
            }
                           
            else if (SystemState.CellularSystemConnectedEdge)
                           
            {
                               
            // show Edge Icon
                           
            }
                       
            };

              • Re: Getting WWAN network type in a C# application

                Hi,

                Your project must aim at least WM6.0 sdk to have these properties.

                Regards

                • Re: Getting WWAN network type in a C# application
                  Bo Nielsen

                  This seems to do it :-) Thanks!

                   

                  Just one small addition: I needed to add a reference to Microsoft.WindowsMobile.Telephony on top of the reference to Microsoft.WindowsMobile.Status else I get compile errors on SystemState.CellularSystem*

                   

                  I did not need the event based state changes as I'm building a background logger thus I just used it like this:

                   

                              WwanConnectionConnectedType = "Disconnected";

                              if (SystemState.CellularSystemConnectedGprs)

                                  WwanConnectionConnectedType = "GPRS";

                              if (SystemState.CellularSystemConnectedEdge)

                                  WwanConnectionConnectedType = "EDGE";

                              if (SystemState.CellularSystemConnectedUmts)

                                  WwanConnectionConnectedType = "UMTS";

                              if (SystemState.CellularSystemConnectedHsdpa)

                                  WwanConnectionConnectedType = "HSDPA";

                   

                              WwanConnectionAvaliableType = "None";

                              if (SystemState.CellularSystemAvailableGprs)

                                  WwanConnectionAvaliableType = "GPRS";

                              if (SystemState.CellularSystemAvailableEdge)

                                  WwanConnectionAvaliableType = "EDGE";

                              if (SystemState.CellularSystemAvailableUmts)

                                  WwanConnectionAvaliableType = "UMTS";

                              if (SystemState.CellularSystemAvailableHsdpa)

                                  WwanConnectionAvaliableType = "HSDPA";