Daniel Brunner 01ce3a22a3 Merge pull request #1 from CommanderRedYT/patch-1
Fix deadlock when sending and receiving udp
2024-10-09 15:58:38 +02:00
2023-04-27 14:29:42 +02:00
2021-04-15 23:17:22 +02:00
2021-04-15 21:39:51 +02:00
2021-10-14 23:43:59 +02:00

espasyncudplistener

ESP32 async udp listener

Example usage

#include <esp_log.h>
#include <espwifiutils.h>

#include <asyncudplistener.h>

namespace {
constexpr const char * const TAG = "MYAPP";
} // namespace

AsyncUdpListener udpListener;

void setup()
{
    constexpr const uint16_t listeningPort = 1234;
    if (!udpListener.listen(listeningPort))
        ESP_LOGE(TAG, "could not start listening on udp (port=%i)", listeningPort);
}

void handleUdpPacket(const UdpPacketWrapper &packet)
{
    ESP_LOGI(TAG, "udp response from %s : \"%.*s\"",
             wifi_stack::toString(packet.remoteAddr()).c_str(),
             packet.data().size(), packet.data().data());
    // TODO: further processing of packet
}

void handleUdpPackets()
{
    while (const auto &packet = udpListener.poll())
        handleUdpPacket(*packet);
}
Description
Easy ESP32 async udp listener
Readme GPL-3.0 65 KiB
Languages
C++ 95.5%
CMake 4.5%