mCore™ .NET SMS Library 1.2

mCore.SMS.Command Method

Description:

The Command method sends a AT command string to the GSM Modem/Phone connected to the serial port and returns the response as a string.

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

Remarks:

The Command method can be particularly useful for:

Exceptions:

mCore.GeneralException

Usage Example:

Visual Basic

Public Class MyClass

   Public WithEvents objSMS As New mCore.SMS

   Public Sub SendCommand()
      Dim strCmdResult As String
      Try
         SetCommParameters()
         strCmdResult = objSMS.Command("AT+CPBR=1")
         MsgBox(strCmdResult)
      Catch ex As mCore.GeneralException
         MsgBox(ex.Message, MsgBoxStyle.Critical, "mCore Demo")
      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
         MsgBox(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 SendCommand()
   {
      try
      {

         SetCommParameters();
         string strCmdResult = objSMS.Command("AT+CPBR=1");
         MessageBox.Show(strCmdResult);
      }

      catch (mCore.GeneralException e)
      {
         MessageBox.Show(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)
      {
         MessageBox.Show(e.ToString());
      }
      catch (Exception e)
      {
      }
   }
}

See Also:

mCore.SMS.Port Property
mCore.SMS.BaudRate Property
mCore.SMS.DataBits Property
mCore.SMS.StopBits Property
mCore.SMS.Parity Property
mCore.SMS.FlowControl Property
mCore.SMS.Timeout Property
mCore.SMS.IsConnected Property
mCore.SMS.Connect Method
mCore.SMS.Disconnect Method

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved