'Non-UI application (console application)
#Region Project Attributes
' #CommandLineArgs: TEST
#End Region
Sub Process_Globals
Dim TcpStreams As AsyncStreams
Dim Socket1 As Socket
Dim StringToSend As String
End Sub
Sub AppStart (Args() As String)
If Args.Length = 0 Then
Log("Arguments missing")
ExitApplication2(1)
End If
'socket for connecting to 'Raspberry Pi-gateway on port 32340
Socket1.Initialize("Socket1")
Socket1.Connect("192.168.1.4",32340,5000)
StringToSend = Args(0)
StartMessageLoop
End Sub
Sub Socket1_Connected(Connected As Boolean)As Boolean
If Connected = True Then
TcpStreams.Initialize(Socket1.InputStream,Socket1.OutputStream,"tcpStreams")
Try
SendData(StringToSend)
Catch
Log("Send Error")
End Try
End If
End Sub
Sub SendData(Msg As String)'to Pi Gateway (port 32340)
Dim Buffer() As Byte
If Socket1.Connected = True Then
Try
Buffer = Msg.GetBytes("UTF8")
TcpStreams.Write(Buffer)
Log("Data sent")
ExitApplication2(1)
Catch
Log("TcpStreams.Write Error")
End Try
Else
Log("Connection lost")
End If
End Sub