UDP on ESP8266 in C

  1. We need to send data from Fanstel gateway which has ESP8266 via WIFI to our QT application via UDP
  2. i tried using https://github.com/cesanta/mongoose/blob/master/examples/udp_client/udp_client.c
  3. Build is failed
  4. From https://github.com/mongoose-os-apps here i can directly flash in ESP8266 but there is no project for UDP in mongoose OS apps can you please share app for UDP

Thanks,
Krupashankar

Something like this should work:

  // client=udp://IP:PORT
  if ((client != NULL) && (client[0] != '\0')) {
    struct mg_connection *udp = mg_connect(mgos_get_mgr(), client, NULL, NULL);
    if (udp != NULL) {
      // LOG(LL_INFO, ("udp: %p", udp));
      mg_printf(udp, "%s uptime: %.2lf, free_heap: %lu, min_free_heap: %lu\n",
                (s_tick_tock ? "Tick" : "Tock"), mgos_uptime(),
                (unsigned long) mgos_get_free_heap_size(),
                (unsigned long) mgos_get_min_free_heap_size());
      udp->flags |= MG_F_SEND_AND_CLOSE;
    } else {
      LOG(LL_ERROR, ("Failed to connect to %s", client));
    }
  }

Hi Nliviu,
Now we are able to build without any errors, but the udp connection is not established.
can you please share us the complete udp client project code.

Thanks,
Krupashankar