Hello everyone, first timer here.
I've been working on this problem all day and still can't get it to work.
Situation: I am writing a Windows Service that will communicate with a mobile phone, connected via USB, in order to send a text message.
Problem: I'm using AT commands in order to achieve this, however when I send the chr(26) after the message (ctrl+z to send the message), it doesn't do anything. I have pasted the same code into a windows form and it works fine. Is there a limitation of windows services that I don't know about?
Code: Dim number As String = "+447824123456"
Dim message As String = TextBox1.Text
Dim serialport As New IO.Ports.SerialPort
With serialPort
.PortName = "COM24"
.BaudRate = "9600"
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
.Handshake = IO.Ports.Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
End With
serialPort.Open()
'checks phone status
serialPort.WriteLine("AT" & vbCrLf)
'Configures message as SMS
serialPort.WriteLine("AT+CMGF=1" & vbCrLf)
'Sets message center number
serialPort.WriteLine("AT+CSCA=""+447785016005""" & vbCrLf)
'Sets destination number
serialPort.WriteLine("AT+CMGS=""" & number & """" & vbCrLf)
'Specifies message and sends Ctrl+z
serialPort.WriteLine(message & Chr(26))
'Displays buffer containing output messages
System.Threading.Thread.CurrentThread.Sleep(2000)
MsgBox(serialPort.ReadExisting)
serialPort.Close()
Thanks for your help in advance.
James