Pages

Thursday, 9 July 2015

INTEGRATED EMBEDDED SYSTEM WITH Vb.Net- Chapter 4

GSM INTERFACE






There are many different kinds of applications SMS applications in the market today, and many others are being developed. Applications in which SMS messaging can be utilized are virtually unlimited. Some common examples of these are given below:
  • Person-to-person text messaging is the most commonly used SMS application, and it is what the SMS technology was originally designed for.
  • Many content providers make use of SMS text messages to send information such as news, weather report, and financial data to their subscribers.
  • SMS messages can carry binary data, and so SMS can be used as the transport medium of wireless downloads. Objects such as ringtones, wallpapers, pictures, and operator logos can be encoded in SMS messages.
  • SMS is a very suitable technology for delivering alerts and notifications of important events.
  • SMS messaging can be used as a marketing tool.
In general, there are two ways to send SMS messages from a computer / PC to a mobile phone:
  1. Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to send SMS messages.
  2. Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless carrier or SMS service provider. Then send SMS messages using a protocol / interface supported by the SMSC or SMS gateway

AT Commands

AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. Every command line starts with "AT" or "at". That's why modem commands are called AT commands. There are two types of AT commands:
1.       Basic commands are AT commands that do not start with a "+". For example, D (Dial), A (Answer), H (Hook control), and O (Return to online data state) are the basic commands.
2.       Extended commands are AT commands that start with a "+". All GSM AT commands are extended commands. For example, +CMGS (Send SMS message), +CMGL (List SMS messages), and +CMGR (Read SMS messages) are extended commands.

The FORM DESIGN as show below, Here we using combo box for port selection  and textbox for entering mobile number to send sms,and message field to type message and send button.




The complete code as given below, Here we have to create two class 1)sms ,2)program
The class sms will set all pre-requirements in order to send sms,and port values and program class will load the forms and this will initiate the application.

Imports System.Data.SqlClient
Imports System.Net.Sockets
Imports System.Text
 Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        If SerialPort1.IsOpen Then
            SerialPort1.Close()
        End If

        Try
            With SerialPort1
                .PortName = "COM11"
                .BaudRate = 9600
                .Parity = IO.Ports.Parity.None
                .DataBits = 8
                .StopBits = IO.Ports.StopBits.One
                .Handshake = IO.Ports.Handshake.None
                .NewLine = vbCrLf
                .RtsEnable = True
                .RtsEnable = True
            End With
            SerialPort1.Open()
            SerialPort1.WriteLine("at+cmgf=1" & vbCrLf)
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try



    End Sub


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim Num as Integer
Dim Msg as String
Num=TexBox1.text
Msg=TexBox2.text
Send_sms(Num,Msg)

End Sub

Sub send_sms(ByVal Cont_no As String, ByVal acc_details As String)
        Dim Mobile = Cont_no
        Dim message = acc_details
        SerialPort1.WriteLine("at+cmgd=1" & vbCrLf)
        Sleep(1000)
        Dim a As String
        a = "at+cmgs=""+91" & Mobile & """"
        SerialPort1.WriteLine(a & vbCrLf)
        Sleep(1000)
        SerialPort1.WriteLine(message & Chr(26))
    End Sub

End Class