Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private client As WiFiSocket
Private astream As AsyncStreams
Private serverIp() As Byte = Array As Byte(192, 168, 0, xxx)
Private ServerPort As UInt = xxxxx
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
If wifi.Connect2("xxxxxx","xxxxxxxxxx") Then ' fill in the correct data
Log("Connected to wireless network.")
Log(wifi.LocalIp)
Else
Log("Failed to connect.")
Return
End If
Connect(0)
End Sub
Private Sub Connect(u As Byte)
If client.ConnectIP(serverIp, ServerPort) Then
Log("Connected to server.")
astream.Initialize(client.Stream, "astream_NewData", "astream_Error")
Else
Log("Failed to connect to server")
CallSubPlus("Connect", 1000, 0)
End If
End Sub
Sub AStream_NewData (Buffer() As Byte)
Log("Received: ", Buffer)
End Sub
Sub AStream_Error
Log("Error")
CallSubPlus("Connect", 1000, 0)
End Sub