-
Bulk SMS using MSCOMM
I am developing a SMS based application using VB 6.0. In a particular module I have send a single message to several persons using GSM Modem, I am using the following code:
mscomm1.output = AT+CMGS='9880699876' & chr$(13)
mscomm1.output=AT+CMGS='Message' & chr$(26) ' Ctrl+Z character
the message is received by the receipent 10 out of 10 times
However if I am sending the same thing to many users like this
do while not adorsd.eof ' recordset getting mobile number from database
mscomm1.output = AT+CMGS=adorsd.fields(i).value & chr$(13) ' getting stored numbers from a database.
mscomm1.output=AT+CMGS='Message' & chr$(26) ' Ctrl+Z character
adorsd.movenext
loop
ONly the first recepient is getting the message
somebody suggested Sleep API but I don't have 100% success although inbetween some of the receipients are getting the message.
Can somebody suggest some way.
thanks!!!
venkat
-
First you need an OnComm event handler. This captures incomming replys from the mscomm control. After sending the first line you should wait for a response of the '>' character or some other response like an 'Error', or if no response comes after say 50 seconds, then consider it a timeout.
If you do get the '>' character then send the second part, the message. For this part you should be waiting for the text 'OK' rather than the '>' character. Otherwise it was not successful. You should always be checking for timeout on every send.
Once you have the 'OK' response then you can start over with the next message.
In your OnComm event code you should keep capturing input so long as the mscomm controls InBufferCount is >0. As you capture the input and add it to your input buffer string, check for special characters vbCr, vbLf, and '>'. These you do not want to add to the input buffer string. you can set a flag if the character is '>' so your send routine can check the flag, to see when it becomes True. And Once you hit a vbCr you have a processable line of text that you can check for the 'OK' string or scan it for the 'error' string to see if you got any errors or anything else unexpected.
-
How to send bulk SMS?
thanks ron weller !!!
I solved it like this.
do while not adorsd.eof ' recordset getting mobile number from database
mscomm1.output = AT+CMGS=adorsd.fields(i).value & chr$(13)
' getting stored numbers from a database.
mscomm1.output=AT+CMGS='Message' & chr$(26) ' Ctrl+Z character
adorsd.movenext
loop
do
do events
rcvBuffer=rcvBuffer+MSCOMM1.input
loop until Instr(rcvBuffer,"+CMGS:") or inster(rcvBuffer,"ERROR")
Is it oK? On yesterday's test (05/15/07) I had 100% success on 5 mobile numbers. I will try today with more numbers like 25, 50 etc. and come back to you.
bye
have nice day!!!
-
Bulk SMS
I solved the problem by waiting for +CMGS: in the buffer and It is very successfull. I have tested several times and all the messages are sent. But, the average time is 5 secs for each SMS.
Shall I try waiting for the second ">" character (after the first one) and then come out of the loop like
MSCOMM1.output= "AT+CMGS=" & Mobile Number & chr$(13)
do
do events
rcvbuffer=rcvbuffer+mscomm1.input
loop until instr(rcvbuffer,">")
position=instr(rcvbuffer,">")
do
do events
rcvbuffer=rcvbuffer+mscomm1.input
loop until instr(position+1,rcvbuffer,">")
Can this be taken as confirmation isntead of "+cmgs:"
Will the duration be reduced say by 1 or 2 seconds. Pl. clarify
reg
venkat
-
More like this:
Code:
Private bGr As Boolean
Private bOK As Boolean
Private bErr As Boolean
Private bRing As Boolean
Private Sub mscomm1_OnComm()
Static stEvent As String
Dim stComChar As String * 1
Select Case MSComm1.CommEvent
Case comEvReceive
Do
stComChar = MSComm1.Input
Select Case stComChar
Case ">"
bGr = True
Case vbLf 'ignore linefeeds
Case vbCr
'Carriage Return so process incoming string
If Len(stEvent) > 0 Then
Select Case Left(stEvent, 5)
Case "OK", "+CMTI"
bOK = True
Case "ERROR"
bError = True
Case "RING"
'MsgBox "Incoming Call Alert", vbInformation
bRing = True
End Select
stEvent = ""
End If
Case Else
stEvent = stEvent + stComChar
End Select
Loop While MSComm1.InBufferCount
Case comEvCTS
MsgBox "Modem Unplugged", vbInformation
End Select
End Sub
-
Thanx weller. Nice answer. But what about the time saving factor will it reduce one or two seconds as compared to 5 secs avg.
reg
venkat
-
I have absolutly no idea if it will or not. I don't know if it is a bad communications line, i.e. a hardware issue, or if it is because you are causing the delay by not responding correctly to each message that you send. The thing is that if you process all of the inbound responses as they come in, it should reduce any delays that might be caused by ignoring the inbound response's. All communications are a two way street. You send a message you get back a response. If you don't at least empty the input buffer, even if you ignore what's in it, their could be delays as you wait for the incomming message to timeout, so that you can send the next message.
One thing you can do is log everything to a log file, run a bunch of tests and see what you get. Everytime you send a message write what you sent to the log file, also every time you get a response back write it to the log file. When you write to the log file include the current date and time this way you can see what you sent, what the response was, and how long it took between each step. If there is a big delay, then maybe it is because the response that you got before you sent the next message, required a specific message back and because you did not send it, it kept waiting until it timed out. Look for situations like this and you can reduce the delay between each message.
-
SMS software
Hello every one
my name is harlove
i have the related code implemantation of SMS server which send , receive,store or interact with database ,respond in response to an incoming msg , i want to sale this software ,i am also have lots of idea like How we use SMS application with different different way and different field ,
thanks
harlove
-
-
Bulk Sms
Thanks once again! weller.
Client is not worried about the time. I want to freeze the software. I will proceed like this
SendMessageUsers:
MScomm1.output="AT+CMGS=" & Mobile Number & Chr$(13)
do
do events
rcvBuffer=rcvBuffer+mscomm1.input
loop until instr(rcvbuffer,">")
MScomm1.output="AT+CMGS=" & Message & Chr$(26)
do
do events
rcvBuffer=rcvBuffer+mscomm1.input
loop until instr(rcvbuffer,"+cmgs:") or instr(rcvbuffer,"ERROR")
' I have come across only these two above situations.
if instr(rcvbuffer,"ERROR") then
HintLabel="Message not Sent" ' Hint label shows activities
GOTO SendMessageUsers ' Call Routine Again for next user
end if
Anything else should i add.
regards
venkat
-
You might also want to check the InBufferCount, which will indicate if there is any thing else in the input buffer. You can also clear the input buffer by setting this to Zero or just by reading the data with Input.
-
thanks weller. This module is working OK.
Now one more problem. I had created a datareport (5 reports) using DataEnivornment designer which was working fine. However, now I am getting the message "Invalid Data Source". After analysis I found that DataEnvironment designer is not working even while accessing records with the database using the connection.
Any suggestions please.
Thanx!
-
Save Me from a life of stupidity
Hi, I'm a spammer. I'm too stupid to get a real job, so I spam forums to make my 47 rubles per week. Impressive, eh?
edit by admin: Feel stupid now Mr. Spammer? Go with the feeling!
-
Problems with package and deployment of Project
Hai Wuller
I have finished the project and I want to make EXE file now. I made a exe file and using package and deployment wizard. It is working fine in the same machine. However, when I installed in another machine I could not install and it hanged and could never install.
I could however work with the EXE when copying all the required files in the directory. I found out that Only reports created by data reports were not working (Runtime error recd) I had not copied three report files (will try today) and the related DataEnviornment designer.
My question is:
1. why messages where not received while running the SetUP file when there was a failure in installation so that these could be set right.
2. I also found that Data Access Components Installed. Is it required?
Throw some light.
reg
venkat
Similar Threads
-
By Pankil in forum Mobile
Replies: 6
Last Post: 05-30-2009, 10:15 AM
-
By hpnasik in forum Mobile
Replies: 3
Last Post: 02-12-2007, 04:23 AM
-
By jatanr in forum Mobile
Replies: 3
Last Post: 08-03-2006, 02:15 PM
-
By murtuja_oracle in forum Database
Replies: 0
Last Post: 04-25-2006, 04:40 AM
-
By Tony Fountain in forum Database
Replies: 4
Last Post: 02-04-2003, 05:30 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|