mCore™ .NET SMS Library 1.2

mCore.SMS.BatteryLevel Property

Description:

The BatteryLevel property gets a integer value indicating the battery charge level remaining as percentage.

Returns the value -1 if there is no battery detected or if there is a power fault.

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 ModemInformation()
      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(" MODEM INFORMATION")
         Console.WriteLine("******************************")
         Console.WriteLine(" Manufacturer: " & objSMS.Manufacturer)
         Console.WriteLine(" Model: " & objSMS.Model)
         Console.WriteLine(" Firmare Rev: " & objSMS.Revision)
         Console.WriteLine(" IMEI: " & objSMS.IMEI)
         Console.WriteLine(" IMSI: " & objSMS.IMSI)
         Console.WriteLine(" Battery Level: " & objSMS.BatteryLevel.ToString())
         Console.WriteLine(" Phone No.: " & objSMS.OwnNumber)

      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 ModemInformation()
   {
      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(" MODEM INFORMATION");
         Console.WriteLine("******************************");
         Console.WriteLine(" Manufacturer: " + objSMS.Manufacturer);
         Console.WriteLine(" Model: " + objSMS.Model);
         Console.WriteLine(" Firmare Rev: " + objSMS.Revision);
         Console.WriteLine(" IMEI: " + objSMS.IMEI);
         Console.WriteLine(" IMSI: " + objSMS.IMSI);
         Console.WriteLine(" Battery Level: " + objSMS.BatteryLevel.ToString());
         Console.WriteLine(" Phone No.: " + objSMS.OwnNumber);
      }

      catch (mCore.GeneralException e)
      {
         Console.WriteLine(e);
      }
      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.Manufacturer Property
mCore.SMS.Model Property
mCore.SMS.IMEI Property
mCore.SMS.Revision Property
mCore.SMS.OwnNumber Property
mCore.SMS.IMSI Property

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved