I'm trying to send sms with my Nokia cell phone (C1-01) using AT Commands and I can successfully send SMS with this vb.net code.
Button_Send_Click:
Dim SMSPort = New SerialPort
With SMSPort
.PortName = "COM2"
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.None
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
SMSPort.Open()
SMSPort.Write("AT+CMGF=1" & vbCrLf)
Threading.Thread.Sleep(200)
SMSPort.Write("AT+CMGS=" & Chr(34) & TextBox1.Text & Chr(34) & vbCrLf) 'TextBox1.text = Recipient mobile number and chr(34) = "
Threading.Thread.Sleep(200)
SMSPort.Write("TEST MESSAGE" & Chr(26)) 'chr(26) = →
Threading.Thread.Sleep(200)
MsgBox(SMSPort.ReadExisting())
SMSPort.Close()
It's working fine for the 1st time, after fire this code I received SMS on my cell phone TEST MESSAGE
(Brilliant) BUT when I press send button in second time I received SMS on my cell phone which contains:
AT+CMGF=1
AT+CMGS=+92XXYYYYYY
TEST MESSAGE
Why in second time it's including "AT Commands i.e AT+CMGF etc.." in SMS?
How can I remove unwanted text from this?
I have also try SMSPort.DiscardInBuffer()
and SMSPort.DiscardOutBuffer()
Properties after opening and before closing my serial port (SMSPort) but my issue is not resolving.
I have googled alot but all is vain, Please help me to resolve this issue.
Platform: Microsoft Visual Basic 2010 with .NET 2.0