#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private astream As AsyncStreams
Public WiFi As ESP8266WiFi
Private bc As ByteConverter
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
ConnectToNetwork
End Sub
Sub Connect
Dim sock As WiFiSocket
sock.ConnectIP(Array As Byte(192, 168, 0, 83), 17178)
If sock.Connected Then
astream.InitializePrefix(sock.Stream,False, "astream_NewData", "astream_Error")
astream.Write(bc.StringToBytes("ABCDEFG"))
End If
sock.Close
End Sub
Sub astream_Error
Log("Error")
End Sub
Sub astream_NewData (Buffer() As Byte)
End Sub
Public Sub ConnectToNetwork
WiFi.Disconnect
If WiFi.Connect2("xxxx", "xxx") Then
Log("ConnectToNetwork Local IP: ", WiFi.LocalIp)
Connect
Else
Log("ConnectToNetwork Failed to connect.")
End If
End Sub