Go Premium for a chance to win a PS4. Enter to Win

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

code for sms using GSM MODEM

can u provide me the code for sending sms from pc to mobile using GSM modem?
0
pritibang
Asked:
pritibang
  • 3
2 Solutions
 
anupvijayCommented:
pritibang,
Which programming language are you using ?

Assuming that it is VB here is link from a mailing list that might help you.

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=39c0b8fd%240%242390%40reader5&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DSend%2BSMS%2Bcode

Cheers.
0
 
amit1978Commented:
Hi,

What technology (Vb,C....)u r using to send and receive message and type of GSM (Nokia, Sime...)

Amit
0
 
amit1978Commented:
Assumin ur using VB and MSComm control for send and receive SMS.

Thru this code u can send the SMS thru GSM modem. here i am posting the code check this out:

Code to send SMS:
~~~~~~~~~~~~~~

Private Sub SendMsg(strMsg As String, Number$)
    Dim DialString$, FromModem$, dummy

    ' AT is the Hayes compatible ATTENTION command and is required to send commands to the modem.
    ' DT means "Dial Tone." The Dial command uses touch tones, as opposed to pulse (DP = Dial Pulse).
    ' Numbers$ is the phone number being dialed.
    ' A semicolon tells the modem to return to command mode after dialing (important).
    ' A carriage return, vbCr, is required when sending commands to the modem.
    ' box is ctrl+z command

    DialString$ = "AT+CMGS=" & Chr(34) & Number$ & Chr(34) & ",145" & vbCr & strMsg & "" & Chr(27)
   
  'explain later
    Call fnOpenPort
   
   
    ' Flush the input buffer.
    MSComm1.InBufferCount = 0
    Command3.Enabled = False
    Command4.Enabled = True
   
   
    MSComm1.Output = "AT+CMGF=1" & Chr$(13) & Chr(10) 'ok meaage is returened
   
    WaitMs 15000
   
    ' Dial the number.
    MSComm1.Output = DialString$
   
    WaitMs 15000
   
    MSComm1.PortOpen = False
   
    ' Disconnect the modem.
    'MSComm1.Output = "ATH" + vbCr
   
    ' Close the port.
    'MSComm1.PortOpen = False
End Sub

Private Function fnOpenPort()
  MSComm1.CommPort = 2
  MSComm1.Settings = "9600,N,8,1"
  MSComm1.Handshaking = 2
 
  On Error Resume Next
 
  ' Communications port settings.
  ' Assuming mouse is attached to COM1, GSM MODAM is set to 2
  ' Open the communications port.
 
  MSComm1.PortOpen = True
  If Err Then
     MsgBox "COM2: not available. Change the CommPort property to another port."
     Exit Function
  End If
 
End Function
0
 
amit1978Commented:
this code will help u to send sms with the help of VB and MSComm control.

Amit
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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