mCore™ .NET SMS Library 1.2

mCore.SMS.Network Property

Description:

The Network property gets a string value containing the identification of the operator in whose network the the modem (SIM) is currently registered.

The network identification string is returned in one of the following formats (depending on which format is available/supported by the modem and/or network, in order of sequence given below):


Namespace: mCore
Assembly: mCoreLib (in mCoreLib.dll)

Exceptions:

mCore.GeneralException

Usage Example:

Visual Basic

Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
   Public Sub NetworkInformation()
      Try
         SetCommParameters()

         ' It is not necessary to execute the 'Connect' method.
         ' Connection state is detected internally by mCore and
         ' the 'Connect' method is executed accordingly.
         objSMS.Connect()

         Console.WriteLine("******************************")
         Console.WriteLine(" NETWORK INFORMATION")
         Console.WriteLine("******************************")
         Console.WriteLine(" Network: " & objSMS.Network)
         Console.WriteLine(" Signal Strength: " & objSMS.SignalStrength.ToString() & "%")
         Console.WriteLine(" Signal Strength (dB): " & objSMS.SignalStrengthDB.ToString() & "dB")

      Catch ex As mCore.GeneralException
         Console.WriteLine(ex.Message)
      Catch ex As Exception
      End Try
   End Sub

   Public Sub SetCommParameters()
      Try
         objSMS.Port = "COM1"
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200
         objSMS.DataBits = mCore.DataBits.Eight
         objSMS.StopBits = mCore.StopBits.One
         objSMS.Parity = mCore.Parity.None
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS

      Catch ex As mCore.GeneralException
         Console.WriteLine(ex.Message)
      Catch ex As Exception
      End Try
   End Function
End Class

 
C#

class MyClass
{
   public mCore.SMS objSMS = new mCore.SMS();
   public static void NetworkInformation()
   {
      try
      {

         SetCommParameters();

         // It is not necessary to execute the 'Connect' method.
         // Connection state is detected internally by mCore and
         // the 'Connect' method is executed accordingly.
         objSMS.Connect();

         Console.WriteLine("******************************");
         Console.WriteLine(" NETWORK INFORMATION");
         Console.WriteLine("******************************");
         Console.WriteLine(" Network: " + objSMS.Network);
         Console.WriteLine(" Signal Strength: " + objSMS.SignalStrength.ToString() + "%");
         Console.WriteLine(" Signal Strength (dB): " + objSMS.SignalStrengthDB.ToString() + "dB");
      }

      catch (mCore.GeneralException e)
      {
         Console.WriteLine(e.ToString());
      }
      catch (Exception e)
      {
      }
   }

   public static void SetCommParameters()
   {
      try
      {
         objSMS.Port = "COM1";
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200;
         objSMS.DataBits = mCore.DataBits.Eight;
         objSMS.StopBits = mCore.StopBits.One;
         objSMS.Parity = mCore.Parity.None;
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS;
      }

      catch (mCore.GeneralException e)
      {
         Console.WriteLine(e.ToString());
      }
      catch (Exception e)
      {
      }
   }
}

See Also:

mCore.SMS.SignalStrength Property
mCore.SMS.SignalStrengthDB Property

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved