#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#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 usocket As WiFiUDP
Private wifi As ESP8266WiFi
Private ip() As Byte = Array As Byte(192, 168, 4, 2)
Private port As UInt = 5000
Private AStream As AsyncStreams
Public msg As String
Public data1(4) As Byte
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Select wifi.StartAccessPoint2("MyESP","live1234")
Case 1
Log("Access Point Initialisation Successful")
Log("SSID: ","MyESP")
Log("ip: ", wifi.AccessPointIp)
usocket.Initialize(5000, "usocket_PacketArrived")
AStream.Initialize(Serial1.Stream, "Astream_NewData", "Astream_Error")
Case 0
Log("Something Went wrong!")
wifi.Disconnect
End Select
End Sub
Private Sub usocket_PacketArrived (data() As Byte, ip1() As Byte, port1 As UInt)
Log(data)
End Sub
'Sub send_data
'usocket.BeginPacket(ip,port)
'usocket.Write("Msg Arrived".GetBytes)
'usocket.SendPacket
'End Sub
Sub Astream_NewData (Buffer() As Byte)
usocket.BeginPacket(ip,port)
usocket.Write(Buffer)
usocket.SendPacket
End Sub
Sub AStream_Error
Log("error")
End Sub