Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1966
  • Last Modified:

GSM Send SMS

Dear Sir

i tested the code in the link

http://www.experts-exchange.com/Programming/Wireless_Programming/GSM/Q_20948621.html

everything works except

Public Function SendSMS(comms As MSComm, ByVal tSMSNum As String, ByVal tMessage As String) As Boolean
    SendSMS = InStr(TransmitAndReceiveData(comms, "AT+CMGS=" & """" & tSMSNum & """" & vbCr & tMessage & Chr(26)), "OK")
End Function

So Please advice

OmarMF
0
omarmf
Asked:
omarmf
  • 6
  • 5
1 Solution
 
imarshadCommented:
What error do you get ?
Does it return "ERROR" or "OK" or "" in SendSMS variable? You can insert a breakpoint and/or print the value returned from the Function......

If it is "OK" and still message is not delivered(you donot receive it at intended No.) then you need to check your value in tSMSNum variable maybe the format is not correct.......

If it is "Error" then check the tSMSNum value as well as the Message.......

If it is "" then check your modem settings.......

and in which mode are you working ?
Text Mode ----> AT+CMGF=1  'Default mode.......
PDU Mode-----> AT+CMGF=0

Imran
0
 
omarmfAuthor Commented:
the function is:

SendSMS1(comModem, "0507751116", "Hello There")

Public Function SendSMS1(comms As MSComm, ByVal tSMSNum As String, ByVal tMessage As String) As String
    SendSMS1 = TransmitAndReceiveData(comms, "AT+CMGS=" & """" & tSMSNum & """" & vbCr & tMessage & Chr(26))
End Function

the returned message by the modem is:

 AT+CMGS="0507751116"
hello there
>

ERROR
0
 
imarshadCommented:
.............................................................................................
the returned message by the modem is:

 AT+CMGS="0507751116"
hello there
>

ERROR

.............................................................................................

This one actually should have been something like this......

AT+CMGS="0507751116"

>hello there

OK

Probable reasons for such behaviour is that your modem is operating maybe in PDU Mode.......Try to convert it into Text mode by issuing the following command.......

TransmitAndReceiveData(comms, "AT+CMGF=1" & vbCr)

But the main problem is that Modem is not given enough time to react after the AT+CMGS="0507751116" command......
i.e you need to wait for some time after issuing this command while in the TransmitAndReceive function that you are using the modem is not given that space........

You can use the following alteration.....In this technique you will need to call 2 functions......

Public Function TransmitAndReceiveData1(comms As MSComm, ByVal tData As String) As String
    Dim lTime As Long
   
    Const TIMEOUT = 10000
   
    tData = tData & vbCr
   
    With comms
        .InBufferCount = 0
        .Output = tData
        tData = ""
   
        lTime = timeGetTime
        tData = ""
        Do While timeGetTime - lTime <= TIMEOUT And InStr(tData, ">") = 0
            DoEvents
            If .InBufferCount > 0 Then tData = tData & .Input
        Loop
    End With
           
    TransmitAndReceiveData1 = tData
End Function


Now you will use the following SendSMS function

Public Function SendSMS(comms As MSComm, ByVal tSMSNum As String, ByVal tMessage As String) As Boolean
      call TransmitAndReceiveData1(comms, "AT+CMGS=" & """" & tSMSNum & """" & vbCr
      SendSMS = InStr(TransmitAndReceiveData(comms, tMessage & Chr(26)), "OK")
End Function

I am at home now so I couldnot test the code.....Please do tell if some error occurs........

Imran
0
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
omarmfAuthor Commented:
nice  i did exactly what you recomend because i expect this reson

i modify (TransmitAndReceiveData)

Public Function TransmitAndReceiveData(comms As MSComm, ByVal tData As String) As String
    Dim lTime As Long
   
    Const TIMEOUT = 100000
   
    tData = tData & vbCr
   
    With comms
        .InBufferCount = 0
        .Output = tData
        tData = ""
   
        lTime = timeGetTime
        tData = ""
        Do While timeGetTime - lTime <= TIMEOUT And InStr(tData, "OK") = 0 And InStr(tData, "ERROR" & vbCrLf) = 0 And InStr(tData, ">") = 0
            DoEvents
            If .InBufferCount > 0 Then tData = tData & .Input
        Loop
    End With
           
    TransmitAndReceiveData = tData
End Function

then i devide send into:

 MsgBox TransmitAndReceiveData(comModem, "AT+CMGS=""+971507751116""")
result:
AT+CMGS="0507751116"

>

 MsgBox TransmitAndReceiveData(comModem, "Hello .. " & Chr(26))

ERROR

i got ok using hyper terminal put no message was received

put now i tryeid to call the number of the sim in the modem. the modem is not ringing ... it should ring right ??

it is giving that it is swiched of or out of caverage,  please suggest some thing

thank you
0
 
imarshadCommented:
>>put now i tryeid to call the number of the sim in the modem. the modem is not ringing ... it should ring right ??
Yes it should ring.......provided that it has been given power......SO if the SIM is in the Modem and the Modem is given power then there should be a ring and you can check this with hyper terminal where you will see

RING

RING

RING
.
.
.

Coming back to your problem......

I dont think your code will transmit the SMS either.....Just try my code with the following line commented......In the function TransmitAndReceiveData1

' tData = tData & vbCr                           'in my code........You donot need to embedd a Carriage Return at the end

This is maybe causing the error......

Imarn

0
 
omarmfAuthor Commented:
So first i should solve rin ring :)

the power is on ... the simcard is there and the test AT returning ok i even can read the messages from the SIM put when i cal
it is giving that it is swiched of or out of caverage,  the modem is wavecom fastrack M1203A-ON.

it may need something to work or it is spoild

please advice

Omar
0
 
omarmfAuthor Commented:
By the way do have the complete list of at command for this modem ??

thank you in advance

Omar
0
 
imarshadCommented:
>>By the way do have the complete list of at command for this modem ??

It suports all standard AT commands....
Try this page.....
http://www.wavecom.com/Products_V2/product.php?prs_id=31&prg_id=13

Imran
0
 
omarmfAuthor Commented:
ok and where i can find all AT commands

thank you

omar
0
 
imarshadCommented:
This is one of the many hundred present on the net........Though it is not intended specifically for your Modem but you will find most of the commands working for you as well(Standard)......

http://www.multitech.com/DOCUMENTS/Collateral/manuals/S000293B.pdf

Imran Arshad
0
 
omarmfAuthor Commented:
i will check the modem and refere to my problem with new quistion

thanks Imran
0

Featured Post

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now