+ Reply to Thread
Results 1 to 3 of 3

Thread: SMS application using AT commands

  1. #1
    MetalSitich is offline VB.NET Forum Newbie MetalSitich is on a distinguished programming path ahead
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2009
    Posts
    1
    Reputation
    0

    Default SMS application using AT commands

    Hi all! I need help! I am currently developing an SMS application to read and receive SMS. I run the application and tried to send an SMS and the application indicates that the message is successfully sent. However the recipient did not receive the SMS. I am using Sony Ericsson T610 btw. Greatly appreciate if u guys could help me.


    Code:
    Imports System
    Imports System.Threading
    Imports System.ComponentModel
    Imports System.IO.Ports
    
    Public Class Form1
        'connect your mobile/GSM modem to PC,
        'then go in device manager and check under ports which COM port has been slected
        'if say com1 is there then put com2 in following statement
        Dim SMSEngine As New SMSCOMMS("COM19")
        Dim i As Integer
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            SMSEngine.Open() 'open the port
            SMSEngine.SendSMS() 'send the SMS
    
        End Sub   
    End Class
    
    Public Class SMSCOMMS
        Private WithEvents SMSPort As SerialPort
        Private SMSThread As Thread
        Private ReadThread As Thread
        Shared _Continue As Boolean = False
        Shared _ContSMS As Boolean = False
        Private _Wait As Boolean = False
        Shared _ReadPort As Boolean = False
        Public Event Sending(ByVal Done As Boolean)
        Public Event DataReceived(ByVal Message As String)
    
        Public Sub New(ByRef COMMPORT As String)
            'initialize all values
            SMSPort = New SerialPort
            With SMSPort
                .PortName = COMMPORT
                .BaudRate = 19200
                .Parity = Parity.None
                .DataBits = 8
                .StopBits = StopBits.One
                .Handshake = Handshake.RequestToSend
                .DtrEnable = True
                .RtsEnable = True
                .NewLine = vbCrLf
            End With
        End Sub
    
        Public Function SendSMS() As Boolean
            If SMSPort.IsOpen = True Then
                'sending AT commands
                SMSPort.WriteLine("AT")
                SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) 'set command message format to text mode(1)
                SMSPort.WriteLine("AT+CSCA=""+919822078000""" & vbCrLf) 'set service center address (which varies for service providers (idea, airtel))
                SMSPort.WriteLine("AT+CMGS=  + TextBox1.text + " & vbCrLf) ' enter the mobile number whom you want to send the SMS
                _ContSMS = False
                SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) 'SMS sending
                MessageBox.Show(":send")
                SMSPort.Close()
            End If
        End Function
    
        Public Sub Open()
            If Not (SMSPort.IsOpen = True) Then
                SMSPort.Open()
            End If
        End Sub
    
        Public Sub Close()
            If SMSPort.IsOpen = True Then
                SMSPort.Close()
            End If
        End Sub
    End Class

  2. #2
    InertiaM is offline VB.NET Forum Idol InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame InertiaM puts e.f. hutton to shame
    .NET Framework
    .NET 2.0
    Join Date
    Nov 2007
    Location
    Kent, UK
    Age
    40
    Posts
    569
    Reputation
    176

    Default

    My guess would be that you need to handle the responses for every AT command that you send, and I would also expect you may need to put in a delay between each line that you send.
    Always parameterize your queries - read more here

    "When people discover the center of the universe, a lot of them will be disappointed to find they are not it."

  3. #3
    cjard's Avatar
    cjard is offline VB.NET Forum All-Mighty cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute cjard has a reputation beyond repute
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Apr 2006
    Age
    66
    Posts
    6,771
    Reputation
    937

    Default

    Or that youre getting the AT commands wrong, or that your friend's phone is broken.

    I'd suggest you snoop the serial port traffic and use Sony's app to send a few text just to make sure youre getting it right

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts