B4R Question [SOLVED] WifiUDP does not work

JanG

Member
Licensed User
Longtime User
Hi,

I made a small example for writing data from my ESP8266 to a PC program via UDP. The PC programm is able to receive UDP messages. I checked it with another PC programm from another PC. But the communication from my ESP8266 to this program does not work.

B4X:
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 wifi As ESP8266WiFi
   Private udp As WiFiUDP
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Delay(3000)
   Log("AppStart")
   
   Log("Connect2: ", wifi.Connect2("MY_SSID","MY_KEY"))

   Delay(1000)
       
   Log("BeginPacket: ", udp.BeginPacket("MY_IP".GetBytes, 8888))
   Log("Write: ", udp.Write("Hallo".GetBytes))
   Log("SendPacket: ", udp.SendPacket)

   Delay(1000)
   
   udp.Close
   Log("Closed!")
End Sub

Any ideas? Bug in WifiUDP?

Bye
Jan
 

JanG

Member
Licensed User
Longtime User
Solved! The IP has to be in this format:

B4X:
    Private ip() As Byte = Array As Byte(192, 168, x, y)
 
Upvote 0
Top