Sub Process_Globals
Private udp As WiFiUDP
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
udp.Initialize(4102,"udp_PacketArrived")
DoConnect ' connects fine, and i can see the Bootp/DHCP request
End Sub
Sub timer1_tick
If wifi.IsConnected = True Then
Log("MyIP ",wifi.LocalIp )
'this does not seem to work?
udp.BeginPacket("255.255.255.255",4101)
udp.Write("test".GetBytes)
udp.SendPacket
Else
Log("Wifi not connected")
End If
End Sub
Sub udp_PacketArrived (Data() As Byte, Ip() As Byte, Port As UInt)
Log("PacketArrived from:")
PrintIp(Ip)
log(Data.Length)
End Sub
Sub PrintIp(ip() As Byte)
Log(ip(0),".", ip(1),".", ip(2),".", ip(3))
End Sub
Sub DoConnect
Log("Wifi trying to connect")
If WifiConnect Then '(use Connect2 if a password is required).
Log("Connected to wireless network.")
Else
Log("Failed to connect.")
End If
End Sub
Sub WifiConnect() As Boolean
Dim l As Int
Log("Wifi ssid: digger ")
If wifi.Connect2("digger","apassword") Then Return True
Return False 'can not connect
End Sub