Solved

GSM Send SMS

Posted on 2004-10-07
11
1,945 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
  • 6
  • 5
11 Comments
 
LVL 13

Expert Comment

by:imarshad
Comment Utility
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
Comment Utility
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
Comment Utility
.............................................................................................
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
 

Author Comment

by:omarmf
Comment Utility
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
Comment Utility
>>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
New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

 

Author Comment

by:omarmf
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
ok and where i can find all AT commands

thank you

omar
0
 
LVL 13

Accepted Solution

by:
imarshad earned 500 total points
Comment Utility
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
Comment Utility
i will check the modem and refere to my problem with new quistion

thanks Imran
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article is a step by step guide on how to create a basic PTP link using Ubiquiti airOS devices. This guide can be used on the following Ubiquiti AirMAX devices. Nanostation, Bullets, AirBridge, Nanobeam, NanoBridge to name a few. Please review …
Today sees the launch of a new case study, focusing on BYOD technologies we have been working with for some time now.  But with the advent of 802.11ac wireless technologies and the story behind our landmark developments, we would like to share this …
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now