Solved

GSM Send SMS

Posted on 2004-10-07
11
1,955 Views
Last Modified: 2013-12-09
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
Comment
Question by:omarmf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 13

Expert Comment

by:imarshad
ID: 12252640
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
 

Author Comment

by:omarmf
ID: 12258446
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
 
LVL 13

Expert Comment

by:imarshad
ID: 12261983
.............................................................................................
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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:omarmf
ID: 12262221
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
 
LVL 13

Expert Comment

by:imarshad
ID: 12262550
>>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
 

Author Comment

by:omarmf
ID: 12262823
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
 

Author Comment

by:omarmf
ID: 12262844
By the way do have the complete list of at command for this modem ??

thank you in advance

Omar
0
 
LVL 13

Expert Comment

by:imarshad
ID: 12263400
>>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
 

Author Comment

by:omarmf
ID: 12263464
ok and where i can find all AT commands

thank you

omar
0
 
LVL 13

Accepted Solution

by:
imarshad earned 500 total points
ID: 12263514
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
 

Author Comment

by:omarmf
ID: 12264046
i will check the modem and refere to my problem with new quistion

thanks Imran
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Need WiFi? Often, there are perfectly good networks that don't have WiFi capability - and there's a need to add it.  - Perhaps you have an Ethernet port into a network but no WiFi nearby. - Perhaps you have a powerline extender and no WiFi at the…
Using in-flight Wi-Fi when you travel? Business travelers beware! In-flight Wi-Fi networks could rip the door right off your digital privacy portal. That’s no joke either, as it might also provide a convenient entrance for bad threat actors.
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question