Solved

Developing an API to send SMS through the PC

Posted on 2004-04-08
19
34,112 Views
Last Modified: 2013-12-09
dear all
i have started a project where i have to develop and API to send and receive SMS through a pc. i will be using a NOKIA 3310 mobile phone and will be connecting it through the COMM port. But still i have a very little idea in starting the project. i know that the phones communicate using the AT commands. can any one give guide me ? please let me know where i can find the nessasary information.
thank you,
best regards,
hasitha007
0
Comment
Question by:hasitha007
  • 5
  • 3
  • 3
  • +8
19 Comments
 
LVL 8

Expert Comment

by:Meff
ID: 10800032
0
 
LVL 2

Accepted Solution

by:
anupvijay earned 200 total points
ID: 10813022
Hi Hasitha,
Meff has given some very good links.
One thing that you might like to find out before starting out with AT commands on any phone is that whether the phones
support the AT commands needed by you.
Although ETSI standards lays out the standard AT commands that should be present I have seen mobile which do not
have all the AT commands incorporated.
It simply means that an AT command   which works with one phone should not necessarily work with others.
So be careful if you want your APIs to be generic for different phones.

Coming to your project.....I can give you pointers.
Use a hyperterminal to connect to your COM port and fire AT commands to check everything is working fine.

Now for your APIs......(assuming you are on windows). You need to use the win32 APIs to open/write/read/close COM ports
What you will be writing would be mostly your AT commands. And what you will be reading would be responses to the  AT
commands.

I think a good starting point would be to get your api to communicate with a COM port initially and then advance step by step
towards your ultimate goal.
A link that could help you.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp

Keep posting about your progress and we here will try to help you out.

Cheers,
Anup
0
 
LVL 3

Expert Comment

by:virenderpratap
ID: 10821032
3310 , 3350 doesn't support AT command and ALSO offically Nokia  haven't lauched the Serrial cable too for it.
8210 , 8250 are the cheepest model which Supports AT commands But they DO NOT the Communicate Via  Serial Port , U can use IRDA port to communicate and run ur AT commands on them.
Minimum Nokia Model to use Serial port and AT commands is Nokia 3100 , better ask Nokia Service Center.
0
 

Expert Comment

by:f_rodriguez
ID: 10842353
What language are you developing in? I wrote this VB6 module once to take care of sending/receiving SMS's from my VB6 projects using a GSM modem connected to the serial port. I use the MSComm control for the actual comms. Note that the functions require a reference to an MSComm control as the first argument.



Option Explicit

Public Function RemoveInternationalDiallingCode(ByVal tTelNumber As String) As String
    RemoveInternationalDiallingCode = "0" & Mid(tTelNumber, 4)
End Function

Public Function GetSMSNum(ByVal tSMSNotification As String) As String
    Dim lCRPos As Long
   
    lCRPos = InStrRev(tSMSNotification, vbCr)
    If lCRPos > 0 Then GetSMSNum = Mid(tSMSNotification, lCRPos - 2, 2)
    If Left(GetSMSNum, 1) = "," Then GetSMSNum = Right(GetSMSNum, 1)
End Function

Public Function ReadSMS(comms As MSComm, ByVal tSMSNum As String, tMessage As String, tSender As String, tDate As String, tTime As String, bRead As Boolean) As Boolean
    Dim tChar As String * 1
    Dim i As Long
    Dim tRead As String
    Dim lQuoteNum As Long
    Dim tDateTime As String
    Dim tData As String
   
    Const TIMEOUT = 10000
   
    On Error GoTo ErrHandler
   
    tData = "AT+CMGR=" & tSMSNum & vbCr
    comms.InBufferCount = 0
    comms.Output = tData
    tData = ""
   
    i = timeGetTime
    Do While timeGetTime - i <= TIMEOUT And InStr(tData, "OK" & vbCrLf) = 0 And InStr(tData, "ERROR" & vbCrLf) = 0
        DoEvents
        If comms.InBufferCount > 0 Then
            tChar = comms.Input
            tData = tData & tChar
        End If
    Loop
           
    If InStr(tData, "ERROR") = 0 And tData <> "" Then
        For i = 1 To Len(tData)
            tChar = Mid(tData, i, 1)
            If tChar = """" Then lQuoteNum = lQuoteNum + 1
            If lQuoteNum = 1 And tChar <> """" Then tRead = tRead & tChar
            If lQuoteNum = 3 And tChar <> """" Then tSender = tSender & tChar
            If lQuoteNum = 5 And tChar <> """" Then tDateTime = tDateTime & tChar
            If lQuoteNum = 6 And tChar <> """" Then tMessage = tMessage & tChar
        Next i
       
        bRead = (tRead = "REC READ")
        tDate = Left(tDateTime, 8)
        tTime = Mid(tDateTime, 10, 8)
        tMessage = Mid(tMessage, 3)
        tMessage = Mid(tMessage, 1, InStr(tMessage, vbCr) - 1)
        ReadSMS = True
    End If
    Exit Function
   
ErrHandler:
    ReadSMS = False
End Function

Public Function DeleteAllSMSes(comms As MSComm) As Boolean
    Dim i As Long
   
    For i = 1 To 15
        DeleteAllSMSes = InStr(TransmitAndReceiveData(comms, "AT+CMGD=" & i & vbCr), "OK")
    Next i
End Function

Public Function DeleteSMS(comms As MSComm, ByVal lSMSNum As Long) As Boolean
    DeleteSMS = InStr(TransmitAndReceiveData(comms, "AT+CMGD=" & lSMSNum & vbCr), "OK")
End Function

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

Public Function TestModem(comms As MSComm) As String
    TestModem = TransmitAndReceiveData(comms, "AT")
End Function

Public Function ManufacturerInfo(comms As MSComm) As String
    ManufacturerInfo = TransmitAndReceiveData(comms, "AT+CGMI")
   
End Function

Public Function ModelInfo(comms As MSComm) As String
    ModelInfo = TransmitAndReceiveData(comms, "AT+CGMM")
End Function

Public Function FirmwareInfo(comms As MSComm) As String
    FirmwareInfo = TransmitAndReceiveData(comms, "AT+CGMR")
End Function

Public Function IMEIInfo(comms As MSComm) As String
    IMEIInfo = TransmitAndReceiveData(comms, "AT+CGSN")
End Function

Public Function IMSIInfo(comms As MSComm) As String
    IMSIInfo = TransmitAndReceiveData(comms, "AT+CIMI")
End Function

Public Function EF_CCIDInfo(comms As MSComm) As String
    EF_CCIDInfo = TransmitAndReceiveData(comms, "AT+CCID")
End Function

Public Function NetworkRegStatus(comms As MSComm) As String
    NetworkRegStatus = TransmitAndReceiveData(comms, "AT+CREG?")
End Function

Public Function AvailablePLMNs(comms As MSComm) As String
    AvailablePLMNs = TransmitAndReceiveData(comms, "AT+COPS?")
End Function

Public Function NetworkFieldStrength(comms As MSComm) As String
    NetworkFieldStrength = TransmitAndReceiveData(comms, "AT+CSQ")
End Function

Public Function MainCellMainParams(comms As MSComm) As String
    MainCellMainParams = TransmitAndReceiveData(comms, "AT+CCED=0")
End Function

Public Function TransmitAndReceiveData(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, "OK") = 0 And InStr(tData, "ERROR" & vbCrLf) = 0
            DoEvents
            If .InBufferCount > 0 Then tData = tData & .Input
        Loop
    End With
           
    TransmitAndReceiveData = tData
End Function
0
 

Expert Comment

by:digitalconvict
ID: 10971262
If you manage to find a phone that supports the serial port interface, you could try the Whisperstream SerialComm GSM SDK, you can get it from http://www.whisperstream.com/software/serialcomm/

It has source code and examples.......I used it for a project I did a while ago and you can extend it if you want.......it's written in C# .NET though, dunno if that will work for you.
0
 
LVL 5

Expert Comment

by:amit1978
ID: 10985343
thanks for help.......
0
 

Author Comment

by:hasitha007
ID: 11038608
hi

i tried to send an SMS through the Hyperterminal but i faild. i connected the NOKIA 3310 phone to the COM port by using a data cable . at the hyperterminal editor i could not type any thing .  so i could not type the AT commands. could u pls tell me the steps to send an SMS by using the hyperterminal.
thank you  
0
 
LVL 3

Expert Comment

by:virenderpratap
ID: 11038701
Please See my pervious comment....
3310 , 3350 doesn't support AT command and ALSO offically Nokia  haven't lauched the Serial cable for them. you can't communicate with thru hyperterminal with these mobiles....
0
 

Author Comment

by:hasitha007
ID: 11046785
hi virenderpratap
thanks for the info. then i think i need to buy a NOKIA 8250.
i will be using c/c++ language to develop my API . can anyone tell me how to start cording. at the morment i really have no idea in starting the project.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:virenderpratap
ID: 11046944
If you are palnning to buy 8250 then it will work on IRDA only,
So, to work with IRDA use IRCOMM to communicate with mobile phone..
IRCOMM is nothing but a virtual com port, so you just need to open IR com port simiral to actual com port , and write the AT commands on it,  f_rodriguez has already posted the code for you in VB, for VC++ just use CreateFile and WriteFile ReadFile Fucntions to Open , IR com(Generally COM4 in Win98) , write data and read data. See the Answered posts in this section you will found your anwser how to start as well as how to code it in C/C++

You may face problem in Other versions of Windwos (Like 2000, NT) becos they don't have direct support for IRComm. But if you buy phone which can have AT command AND Serial Cabel Support then your work will be more easy...

Call to nokia service center they will tell the cheepest model which support AT as well as Serial communication.

0
 

Author Comment

by:hasitha007
ID: 11141545
hi,
I tried with a  nokia 5110 and when i used the hyperterminal and typed  "AT" the charactor that was displayed was " } a " and it replied with " mk ". could u pls tell me whether i can use the Nokia 5110 phone or whether i  have to go for nokia 6110 for serial communication ? which phones supports serial communication and the AT commands ? i have a NOKIA 6120 . does it support serial communication ?
and why did i receive "mk" insted of the "ok". is it a problem with the operating system. i used windows 2000.
thank you,
0
 

Expert Comment

by:lanxi
ID: 11172344
You can try this tool called EasiSMS from http://www.inspire-tech.com

It supports command line so you don't need to use AT commands. It can support both serial cable, USB cable and even infrared.
0
 

Expert Comment

by:ctsttom
ID: 11215780
You guys dont even read what the question was that hasitha007 asked. hasitha007 is trying to program a c app to send SMS's with not find one to send sms's with.
0
 

Expert Comment

by:digitalconvict
ID: 11216994
Well the whisperstream solution has source code with it, that might aid hasitha007 in the coding of the app.

Granted it's C#, but I'll often look at other languages to get an idea how to code something.  Do you not agree?
0
 

Author Comment

by:hasitha007
ID: 11230010
dear all,
now i am facing a big problem. that is which phone to select for AT commands serial communication.
now i have recognized that only some phones supports the AT commands ,serial communication. i tried with nokia 3310,5110,6120, but neither one supported the serial communication of AT commands.  
After that i tried to work with IRDA. Then I faced another problem. That is the IRDA adapter has only the USB ports and then i cannot communicate with the serial port.
So can any one tell me which are the cheapest phones that supports serial communication of the AT commands.

Thank you.
0
 

Expert Comment

by:digitalconvict
ID: 11230084
A Nokia 6210, will definately work (you'll need a dlr-3 serial cable, about 5GBP on ebay).....that's the one supported in the whisperstream sdk and it's what I use.  I'm pretty sure a nokia 6110 will also work.

Anyway hope that helps
0
 

Author Comment

by:hasitha007
ID: 11231083
dear  digitalconvict
thanks for the information. i will try to get one over the weekend and let u know.
thanks.
0
 

Expert Comment

by:uckermark-girl
ID: 13883658
Hello please help.
For my diploma thesis i have to write an apllication what send automatically after an error ocurs an sms over serial cable to my siemens tc35 and then to the mobilphone of the pc administrator.
On this homepage i found some code for sending one at command to the com port but doesn´t know how i can use it for sending an sms and an question is can i send sms in textformat or i have to change the sms text into pduformat? Can someone help my?
I using Windows 2000, a siemens tc25 gsm modem and visual studio 6.0 with the programmlanguage  c++. How i have to start? With Hyperterminal the creation and sending of an sms with the at commands works. In my apllication i want to use the at+cpin, at commands for sending an sms.

Thanks for help and an answer and sorry for my english.
0
 

Expert Comment

by:abd9090
ID: 14004912
hi man go to
http://www.forum.nokia.com/main.html
download sdk 3.0 and start developing
sdk3.0 full of example for vb6 developer
have a nice day
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Join & Write a Comment

DECT technology has become a popular standard for wireless voice communication. DECT devices are not likely to be affected by other electronic devices and signals because they operate in a separate frequency-band.
This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now