Happy new year
i am trying to build a tool to analyse my wifi with an ESP32. In ESP-IDF there is an example for that:
https://github.com/espressif/esp-idf/tr ... le_sniffer
For that, you have to define a callback (in C) and pass it to esp_wifi_set_promiscuous_rx_cb. It is always called, when a wifi packet is received.
In this callback I want to call a Python-function and pass all arguments:
Code: Select all
static void wifi_sniffer_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type) {
sniffer_packet_info_t packet_info;
wifi_promiscuous_pkt_t *sniffer = (wifi_promiscuous_pkt_t *)recv_buf;
packet_info.seconds = sniffer->rx_ctrl.timestamp / 1000000U;
packet_info.microseconds = sniffer->rx_ctrl.timestamp % 1000000U;
packet_info.length = sniffer->rx_ctrl.sig_len;
if (type != WIFI_PKT_MISC && !sniffer->rx_ctrl.rx_state) {
packet_info.length -= SNIFFER_PAYLOAD_FCS_LEN;
mp_obj_tuple_t *t = mp_obj_new_tuple(3, NULL);
t->items[0] = mp_obj_new_int(packet_info.seconds);
t->items[1] = mp_obj_new_int(packet_info.microseconds);
t->items[2] = mp_obj_new_bytearray(packet_info.length, sniffer->payload);
//gc_lock();
//nlr_buf_t nlr;
//if (nlr_push(&nlr) == 0) {
mp_call_function_1(sniffer_handler, t);
// nlr_pop();
//}
//gc_unlock();
}
}
Code: Select all
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400de3b0 PS : 0x00060e30 A0 : 0x800de95c A1 : 0x3ffd1580
A2 : 0x00000023 A3 : 0x00000000 A4 : 0x00000002 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800de3b0 A9 : 0x3ffd1560
A10 : 0x00000000 A11 : 0x3ffcf6f8 A12 : 0x3ffcfcd8 A13 : 0x3ffcf644
A14 : 0x00000001 A15 : 0xb33fffff SAR : 0x00000000 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x40094c88 LEND : 0x40094ca4 LCOUNT : 0xffffffff
Backtrace:0x400de3ad:0x3ffd1580 0x400de959:0x3ffd15a0 0x400e681c:0x3ffd15c0 0x400e6a1f:0x3ffd15e0 0x40100f77:0x3ffd1600 0x401e8aa6:0x3ffd1680 0x401e73ab:0x3ffd16a0
ELF file SHA256: 6473566a0311aeba
Rebooting...
(I found the commented lines in the codebase, but it didn't work.)
Any Idea what I can do to pass a tuple the Python-function?
Best regards,
Tobias