is the callback function in esp_wifi_set_promiscuous_rx_cb thread safe?

emaayan
Posts: 13
Joined: Sun Mar 05, 2023 6:16 pm

is the callback function in esp_wifi_set_promiscuous_rx_cb thread safe?

Postby emaayan » Wed Jul 19, 2023 6:25 am

let's say that in the callback function i use with esp_wifi_set_promiscuous_rx_cb
i'd like to write to a tcp socket, would i need to use some sort of locks on the handler to prevent it from being called concurrently?

Code: Select all

void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type)
{
    wifi_promiscuous_pkt_t *pkt = (wifi_promiscuous_pkt_t *)buff;

    wifi_mgmt_hdr *mgmt = (wifi_mgmt_hdr *)pkt->payload;
    
    const bool filter = filter_packet(mgmt);
    if (filter)
    {
        ESP_LOGD(TAG, "ADDR2=" MACSTR " , RSSI=%d ,Channel=%d ,seq=%d", MAC2STR(mgmt->sa), pkt->rx_ctrl.rssi, pkt->rx_ctrl.channel, mgmt->seqctl & 0xFF);
        if (_wifiPacketHandler)
        {
            _wifiPacketHandler(type, pkt, mgmt);
        }
    }
}

Who is online

Users browsing this forum: Google [Bot] and 198 guests