Professional Documents
Culture Documents
With SerialPort1
.Write("AT")
Threading.Thread.Sleep(1000)
.Write("AT+CMGF=1")
Threading.Thread.Sleep(1000)
.Write("AT+CPMS=""SM""" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write("AT+CMGD=1,4")
Threading.Thread.Sleep(1000)
MsgBox(at_status.ToString)
End With
But the at_status throws me "ERROR" always.
AT+CMGD=1,4 as what I've read on the documentation is the right command but it throws
me an "ERROR" always.
What do you think is wrong with my code? All other command works, except this.
Answers
I figured it out, I only need to put some linebreaks & vbCrLf after every AT
Commands.
With SerialPort1
.Write("AT" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write("AT+CMGF=1" & vbCrLf)
Threading.Thread.Sleep(1000)
.Write(TextBox3.Text & vbCrLf)
Threading.Thread.Sleep(1000)
.Write("AT+CMGD=1,4" & vbCrLf)
Threading.Thread.Sleep(1000)
MsgBox(at_status.ToString)
End With
shareimprove this answer
Hope this helps.
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Label11.Text = ListView1.Items.Count
Label9.Text = ""
End If
End With
Catch ex As Exception
End Try
End Sub
shareimprove this answer
//Script: at_cmgd.at
//Use this script to AT+cmgd AT command
//Get the command support
AT+cmgd=?
WAIT=2
//Delete SMS message at index 1
AT+cmgd=1
WAIT=1
//Delete SMS message at index 2
AT+cmgd=2
WAIT=1
//Delete SMS message at index 3
AT+cmgd=3
WAIT=1
//Delete all read messages SMS messages, leave unread
//messages and stored MO messages untouched
AT+cmgd=,1
WAIT=1
//Delete all read messages SMS messages and sent Mobile
//originated messages, leave unread messages and unsent MO
//messages untouched
AT+cmgd=,2
WAIT=1
//Delete all read messages SMS messages. sent and unsent
//Mobile originated messages, leave unread messages untouched
AT+cmgd=,3
WAIT=1
//Delete all messages including unread messages
AT+cmgd=,4
WAIT=1
AT+cmgd=?
+CMGD: (0,1,2),(0-4)
OK
AT+cmgd=1
OK
AT+cmgd=2
OK
AT+cmgd=3
OK
AT+cmgd=,1
OK
AT+cmgd=,2
OK
AT+cmgd=,3
OK
AT+cmgd=,4
OK
Perintah AT COMMAND mengirim dan menerima SMS
1. Misal kalo alat kita support SMS text mode, maka saya mau HP/GSM modem
saya beroperasi dalam SMS text mode = AT+CMGF=1
2. Nah, baru kita Menulis Nomor yang akan kita kirim dan Pesan ke Message
Storage di HP/GSM modem (SIM card) kita = AT+CMGW=”nomor telepon yg
dituju”
(Enter)…PESAN YG INGIN DIKIRIM…..(Ctrl-Z untuk mengakhiri pesan)…
kemudian muncul info nomor index dimana pesan kita tadi disimpan dalam message
storage.
3. Kita kirimkan pesan kita di index message storage tadi AT+CMSS =
nomorindexpesankita
Selesai…sebagai contoh AT commands dan respons-nya di bawah ini:
AT
OK
AT+CMGF=1
OK
AT+CMGW=”+85291234567″
> A simple demo of SMS text messaging.
+CMGW:1
OK
AT+CMSS=1
+CMSS:20
OK
=======================================================
=======================================================
BERIKUT PENULISAN DALAM PROGRAM KITA
=======================================================
Mode yang paling mudah digunakan yaitu mode teks (kode ASCII). tapi mode
PDU(kode hexa) lebih powerful.
Parameter
<mode> 0 =Mode PDU, 1 = Mode text
Contoh Set GSM modem ke Text Mode SMS dan kirim sms ke No :
+6285695341050.
AT+CMGF?
Parameter
<stat>: Status , antara lain:
Contoh :
Settinglah modem GSM ke Mode SMS text, lihat semua sms yg ada
kemudian hapus sms dari modem GSM.
AT+CMGF=1 < tekan enter(CR) >
OK
AT+CMGL="ALL" //(pada mode PDU(CMGF=0) gunakan AT+CMGL=4)
+CMGL: 1,"REC UNREAD","+6285695341050",,"11/01/09,10:26:26+04" pesan
pertama
+CMGL: 2,"REC UNREAD","+6285695341050",,"11/01/09,10:26:49+04" pesan kedua
OK
AT+CMGD=1 //hapus pesan pertama
OK
AT+CMGD=2 //hapus pesan kedua
OK
Contoh
Menseting modem GSM ke Mode SMS text dan menngirim sms ke
+6285695341050.
AT+CMGF=1
OK //jawaban modem
AT+CMGS="+6285695341050" <akhiri dgn enter bukan>
> halo pc control <akhiri dgn CTRL-Z>
+CMGS: 123 //parameter jawaban dari modem
OK //jawaban dari modem