hieeee
I need a code in java that will send an sms from a pc to a user's mobile phone... Instead of using a gsm modem connected to a pc, to do the above, i want to connect a mobile phone to the pc that will act as a gsm modem...The code should be such that once i say run it sends the sms directly to user's mobile without requiring any other manipulations to be done on--> the mobile which is connected to pc....or anywhere else
(manipulations)
example i have found a code in vb.net that does the similar thing but i want an equivalent code in java for the following code cause i am using java for my project ...its very urgent ....can i please get help?
code in vb.net
Imports System
Imports System.Threading
Imports System.ComponentModel
Imports System.IO.Ports
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Add the COM POrt on Which ur connected here... else it works fine ya
Dim SMSEngine As New SMSCOMMS("COM7")
Dim i As Integer
SMSEngine.Open() 'open the port
SMSEngine.SendSMS() 'send the SMS
'send a signal on serial port so that buzzer rings
Dim com1Port As IO.Ports.SerialPort = Nothing
Try
com1Port = My.Computer.Ports.OpenSerialPort("COM1")
For i = 0 To i = 50
com1Port.WriteLine("1111111111111111") 'sending data
Next
com1Port.Write("serialData")
com1Port.Close()
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
If (com1Port IsNot Nothing) Then com1Port.Dispose()
com1Port = Nothing
End Try
End Sub
End Class
Public Class SMSCOMMS
Private WithEvents SMSPort As SerialPort
Private SMSThread As Thread
Private ReadThread As Thread
Shared _Continue As Boolean = False
Shared _ContSMS As Boolean = False
Private _Wait As Boolean = False
Shared _ReadPort As Boolean = False
Public Event Sending(ByVal Done As Boolean)
Public Event DataReceived(ByVal Message As String)
Public Sub New(ByRef COMMPORT As String)
SMSPort = New SerialPort
With SMSPort
.PortName = COMMPORT
.BaudRate = 19200
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
End Sub
Public Function SendSMS() As Boolean
If SMSPort.IsOpen = True Then
'sending AT commands
SMSPort.WriteLine("AT")
SMSPort.WriteLine("AT+CMGF=1" & vbCrLf)
SMSPort.WriteLine("AT+CSCA="" +919823000040""" & vbCrLf)
SMSPort.WriteLine("AT+CMGS=""+919960920107""" & vbCrLf)
_ContSMS = False
SMSPort.WriteLine("test message!!" & vbCrLf & Chr(26))
MessageBox.Show(":send")
SMSPort.Close()
End If
End Function
Public Sub Open()
If Not (SMSPort.IsOpen = True) Then
SMSPort.Open()
End If
End Sub
Public Sub Close()
If SMSPort.IsOpen = True Then
SMSPort.Close()
End If
End Sub
End Class