| Author |
Message |
potetojb
Joined: 25 Feb 2006 Posts: 63 Helped: 1 Location: Johor,Malaysia
|
22 Mar 2006 7:43 send at command using Vb |
|
|
|
hello
i want to send at command using vb to mobile phone. can someone help me
thankQ for help
|
|
| Back to top |
|
 |
thedesolatesoul
Joined: 06 Jul 2004 Posts: 26 Helped: 2
|
22 Mar 2006 22:32 Re: send at command using Vb |
|
|
|
This depends on how you connect the phone to the computer.
If your fone connects through a serial cable OR you have drivers so that the cell phone is detected as a modem then you can use the MSComm control in VB to connect to the required COM port and send AT commands.
|
|
| Back to top |
|
 |
potetojb
Joined: 25 Feb 2006 Posts: 63 Helped: 1 Location: Johor,Malaysia
|
27 Mar 2006 9:31 Re: send at command using Vb |
|
|
|
| i use sony ericsson data cable but the cable is USB. i down know i can link the phone to vb or not because i think vb just support serial communicatian. usb is perallel..
|
|
| Back to top |
|
 |
seadolphine2000
Joined: 12 Apr 2005 Posts: 563 Helped: 31
|
28 Mar 2006 20:43 send at command using Vb |
|
|
|
I have a Samsung E730 and I connect it to the PC using USB cable, The can be detected as a modem.
Hoiw can I send the AT-Commands to it using VB.???
Thanks.
|
|
| Back to top |
|
 |
thedesolatesoul
Joined: 06 Jul 2004 Posts: 26 Helped: 2
|
28 Mar 2006 22:25 Re: send at command using Vb |
|
|
|
If the device is detected as a modem, you need to know which COM port it is attached to.
Go to Device Propeties and check the properties of the detected modem and check which port it connects to.
Then in VB add the MS Comm control, and set the properties.
I suppose you should use the slowest speed and use hardware flow control.
Now send the AT commands like normal ASCII data like MSComm1.Output = "AT"
Hope this helps.
|
|
| Back to top |
|
 |
potetojb
Joined: 25 Feb 2006 Posts: 63 Helped: 1 Location: Johor,Malaysia
|
28 Mar 2006 22:36 Re: send at command using Vb |
|
|
|
hello
thank
thedesolatesoul
i use sony ericsson T610. i want read the msg using vb
i find serial data cable
i try to send the at command using vb.. that my program.
but i have problem i dont know why the msg cant display in text.. i thing have some problem.
this program dont error bit just not display the output
can u check the program for me.
i realy new in vb6
Private Sub Command1_Click()
Dim sms As String
Dim buffer$
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.Handshaking = comNone
MSComm1.PortOpen = True
'echo off
MSComm1.Output = "ATE0" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
buffer$ = ""
'Report Mobile Equipment Error ( enable )
MSComm1.Output = "AT+CMEE=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
buffer$ = ""
'Received read message
MSComm1.Output = "AT+CMGR=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "+CMGR: 1,,159")
buffer$ = ""
sms = MSComm1.Input
Text1.Text = sms
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
MSComm1.PortOpen = False
End Sub
if i use hyperterminal the output like this
'if use hyperterminal the command output like below
'AT CMGR = 1
'+CMGR: 1,,159
'07910621000010F5240B910621671663F1000060104222334423A0C2E030088232834E19C8049A06
'9BC2AAF3B87482905569D5E8CC06750A625A0F0AB7C32037B90E62D7D761103B3C4F83C46190B8EE '9E87D7207A1A5E9683CEE97619E41E8741F2F43A4D0785C5F3FA18949E97C96190FBBC0E83DCE230
'485C77CFCB20F739CC9E97C9A0B0FB3C07A5C5F575BB0C729FCB6A50985E6783D2F3B03B0D72A75D
'E8301A1446875D
i dont know how to display mscomm1.input and check the mscomm1.input or output function or not
thank
|
|
| Back to top |
|
 |
thedesolatesoul
Joined: 06 Jul 2004 Posts: 26 Helped: 2
|
28 Mar 2006 23:05 Re: send at command using Vb |
|
|
|
have you checked what value you are getting in buffer$?
try single stepping to debug and check what o/p u are getting on each line
|
|
| Back to top |
|
 |
thedesolatesoul
Joined: 06 Jul 2004 Posts: 26 Helped: 2
|
29 Mar 2006 21:37 Re: send at command using Vb |
|
|
|
Okay potetojb, I've checked your program and there are a few things to modify although its a very well written program.
When you set the InputLen to Zero, that means that the MSComm control will read the whole line at once so you dont need to worry about buffer sizes.
You dont need to send ATE0 i.e. the echo off command.
You also need to send an SMS message format command
i.e. AT+CMGF=1 to see the text messages
When you want to reveive the message using AT+CMGR dont use AT+CMGR=1
because the message numbers dont always start from 1. They could be anything like 800,860 etc.
So first you need to download the whole list of SMS messages using the AT+CMGL command.
Then you need to process the list and get the message number you want from it and then read it.
I've used a Motorola C975 to check this and been able to successfully download the message.
Here's the code. I suppose you only need to change the COM port.
Private Sub Command1_Click()
Dim sms As String
Dim buffer$
Dim MsgNumber(100) As Integer
With MSComm1
.CommPort = 4
.Settings = "9600,N,8,1"
.InputLen = 0
.Handshaking = comNone
.PortOpen = True
End With
'Report Mobile Equipment Error ( enable )
MSComm1.Output = "AT+CMEE=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
Text1.Text = Text1.Text & vbCr & buffer$
buffer$ = ""
'Set SMS format to Text
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
Text1.Text = Text1.Text & vbCr & buffer$
buffer$ = ""
'Receive List from Mobile
MSComm1.Output = "AT+CMGL" & Chr$(13)
Do
DoEvents
buffer$ = MSComm1.Input
If buffer$ <> "" Then
Text1.Text = Text1.Text & vbCr & buffer$
List1.AddItem Replace(buffer$, Chr(13) & Chr(10), " ") 'remove all the carriage returns before adding to the listbox
End If
Loop Until InStr(buffer$, "OK")
buffer$ = ""
'Now we have to parse the received list of messages
'This contains messages from the inbox, outbox, etc etc
'My motorola was giving "REC READ" for inbox messages
'For eg: +CMGL: 843, "REC READ", "+923452914470"
J = 0
For I = 0 To List1.ListCount - 1
If InStr(List1.List(I), "REC READ") Then 'This is from the Inbox
MsgNumber(J) = Val(Mid(List1.List(I), 9, InStr(List1.List(I), ",") - 9))
J = J + 1
End If
Next
'Now getting the highest number which will hopefully be the newest SMS
SMSNumber = 0
For I = 0 To J - 1
If MsgNumber(I) > SMSNumber Then
SMSNumber = MsgNumber(I)
End If
Next
'Received read message
MSComm1.Output = "AT+CMGR=" & SMSNumber & Chr$(13)
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, "OK")
Text1.Text = Text1.Text & vbCr & buffer$
Text2.Text = buffer$
buffer$ = ""
MSComm1.PortOpen = False
End Sub
Also check out these sites.
http://www.windclimber.net/linux/motorola/L-AT.pcgi
http://www.etsi.org/ for standards 300 642
[/url]
|
|
| Back to top |
|
 |
potetojb
Joined: 25 Feb 2006 Posts: 63 Helped: 1 Location: Johor,Malaysia
|
01 Apr 2006 18:04 Re: send at command using Vb |
|
|
|
hello
thedesolatesoul
thank for your code.
1) i use your program but still problem.have error in
For I = 0 To List1.ListCount - 1
why?..
u use
Dim sms As String
for what. i cant understand.
in the program u dont use sms.
2) i use hyperterminal for test the program i send the
AT+CMGL
OK (the output only OK. u thing this true or not.)
3) i use hyperterminal for read the msg. i send this command.
AT (for check the hypeterminal link on my modem cell phone or not)
OK
AT+CMGF=1 (change to text mode)
OK
AT+CMGR=1 ( read the msg stay in bank 1)
.............
..........
.........
the output have time msg send,the sender phone number and the msg.
i want separate the msg. how can i do..
i realy nead help.
sorry for my bad english
|
|
| Back to top |
|
 |
thedesolatesoul
Joined: 06 Jul 2004 Posts: 26 Helped: 2
|
05 Apr 2006 12:15 Re: send at command using Vb |
|
|
|
1) Please add a ListBox to your form. I used it simply so that I could list all the messages in the phone.
Also make Text1 multline (in the properties) and add scrollbars too.
2)When I send AT+CMGL, the result is not OK. Infact, the phone sends a list of all the messages stored in the phone.
3)When I send AT+CMGF=1, I get an error. But when I have the list of messages and I know the numbers of each message then I use AT+CMGF=xxx where xxx is the message number.
In order to separate the message you will have to parse the text. Use INSTR function to find the location of some identifier and then use Left,Mid or Right function to select a part of the text.
|
|
| Back to top |
|
 |