B4R Question [SOLVED] WifiUDP does not work

Discussion in 'B4R Questions' started by JanG, Nov 4, 2018.

  1. JanG

    JanG Member Licensed 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.

    Code:
    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
     
  2. JanG

    JanG Member Licensed User

    Solved! The IP has to be in this format:

    Code:
    Private ip() As Byte = Array As Byte(192168, x, y)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice