I wish have the possibility to redirect the LOG message on UDP
Thanks
Thanks
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private udp As WiFiUDP
Private timer1 As Timer
Private ip() As Byte = Array As Byte(192, 168, 0, 104)
Private port As UInt = 51042
Private serializator As B4RSerializator
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
If wifi.Connect2("TP-LINK_D577", "xxx") = False Then
Log("Failed to connect")
Return
End If
Log("connected")
If udp.Initialize(54329, "udp_PacketArrived") = False Then
Log("Failed to create UDP socket")
Return
End If
timer1.Initialize("timer1_Tick", 1000)
timer1.Enabled = True
End Sub
Sub MyLog(Message() As Object)
udp.BeginPacket(ip, port)
udp.Write(serializator.ConvertArrayToBytes(Message))
udp.SendPacket
End Sub
Sub Timer1_Tick
MyLog(Array("Time here is: ", Millis))
End Sub
Sub udp_PacketArrived (Data() As Byte, ip1() As Byte, port1 As UInt)
End Sub
Sub Process_Globals
Private socket As UDPSocket
Private ser As B4RSerializator
Private buffer1 As B4XBytesBuilder
End Sub
Sub AppStart (Args() As String)
socket.Initialize("socket", 51042, 8192)
ser.Initialize
buffer1.Initialize
StartMessageLoop
End Sub
Sub socket_PacketArrived (Packet As UDPPacket)
buffer1.Clear
buffer1.Append(Packet.Data)
Dim data() As Object = ser.ConvertBytesToArray(buffer1.SubArray2(0, Packet.Length))
Dim sb As StringBuilder
sb.Initialize
For Each o As Object In data
sb.Append(o)
Next
Log(sb.ToString)
End Sub