(SOLVED)ESP-IDF: E (588) wifi:failed to post WiFi event=40 ret=259
Posted: Fri Mar 22, 2024 6:51 pm
I'm trying something new. I want to detect certain management packets, then trigger an alarm when detected.
The error above comes from the libnet80211.a library.
I was hoping to see the source somewhere to find out what event=40 ret=259 could mean.
The highlighted code is the line that breaks.
I've tried running the code on a ESP32S as well as a ESP WROOM 32 (the one that has the UNO layout)
Full code available at:
https://github.com/CraftyZA/DetectWifiDeauth
The error above comes from the libnet80211.a library.
I was hoping to see the source somewhere to find out what event=40 ret=259 could mean.
The highlighted code is the line that breaks.
I've tried running the code on a ESP32S as well as a ESP WROOM 32 (the one that has the UNO layout)
Code: Select all
void app_main(void) {
printf("Starting packet Detection...\n");
esp_log_level_set("*", ESP_LOG_VERBOSE);
// Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
// Initialize Wi-Fi
printf("Wifi Init in progress...\n");
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL)); // Set Wi-Fi mode to NULL
[b][color=#FF0000]ESP_ERROR_CHECK(esp_wifi_start());[/color][/b] // Start Wi-Fi
esp_wifi_start();
// Set Wi-Fi mode to promiscuous
printf("Setting WIFI to promiscuous mode...\n");
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true));
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler));
ESP_LOGI(TAG, "Wi-Fi initialized");
printf("Setup Complete. \n");
// Example: Setup button GPIO pin and attach interrupt handler to stop the alarm
gpio_set_direction(STOP_BUTTON_GPIO_PIN, GPIO_MODE_INPUT);
gpio_set_intr_type(STOP_BUTTON_GPIO_PIN, GPIO_INTR_NEGEDGE);
gpio_install_isr_service(0);
gpio_isr_handler_add(STOP_BUTTON_GPIO_PIN, stop_alarm, NULL);
// Main loop
while (1) {
// Just keep swimming, just keep swimming
vTaskDelay(1000 / portTICK_PERIOD_MS); // Delay for 1 second
}
// Deinitialize Wi-Fi before application exits
// ESP_ERROR_CHECK(esp_wifi_stop()); // Stop Wi-Fi
// ESP_ERROR_CHECK(esp_wifi_deinit()); // Deinitialize Wi-Fi
// ESP_LOGI(TAG, "Wi-Fi deinitialized");
}
Full code available at:
https://github.com/CraftyZA/DetectWifiDeauth