I've made the code pretty verbose in my last update.
Updated main function:
Code: Select all
void app_main(void) {
printf("Starting packet Detection...\n");
esp_log_level_set("*", ESP_LOG_VERBOSE);
ESP_LOGI(TAG, "Before WiFi Initialization");
// 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);
// Debug info after NVS initialization
ESP_LOGI(TAG, "NVS Initialized");
// Initialize Wi-Fi
printf("WiFi Init in progress...\n");
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
esp_err_t wifi_init_result = esp_wifi_init(&cfg);
if (wifi_init_result != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize Wi-Fi: %d", wifi_init_result);
} else {
ESP_LOGI(TAG, "Wi-Fi Successfully initialized");
}
esp_err_t wifi_storage_result = esp_wifi_set_storage(WIFI_STORAGE_RAM);
if (wifi_storage_result != ESP_OK) {
ESP_LOGE(TAG, "Failed to set Wi-Fi storage: %d", wifi_storage_result);
} else {
ESP_LOGI(TAG, "Wi-Fi RAM storage set");
}
esp_err_t wifi_mode_result = esp_wifi_set_mode(WIFI_MODE_NULL);
if (wifi_mode_result != ESP_OK) {
ESP_LOGE(TAG, "Failed to set Wi-Fi mode to NULL: %d", wifi_mode_result);
} else {
ESP_LOGI(TAG, "Wi-Fi Mode set to NULL");
}
esp_err_t wifi_start_result = esp_wifi_start();
if (wifi_start_result != ESP_OK) {
ESP_LOGE(TAG, "Failed to start WiFi: %s", esp_err_to_name(wifi_start_result));
} else {
ESP_LOGI(TAG, "Started WiFi!");
}
ESP_LOGI(TAG, "After WiFi Initialization");
// Set Wi-Fi mode to promiscuous
printf("Setting Wi-Fi 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");
}
Here is the output.
Code: Select all
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7172
load:0x40078000,len:15540
load:0x40080400,len:4
ho 8 tail 4 room 4
load:0x40080404,len:3904
entry 0x40080640
I (30) boot: ESP-IDF v5.2.1-dirty 2nd stage bootloader
I (30) boot: compile time Mar 22 2024 12:31:46
I (30) boot: Multicore bootloader
I (35) boot: chip revision: v1.0
I (39) boot.esp32: SPI Speed : 40MHz
I (43) boot.esp32: SPI Mode : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I (91) boot: End of partition table
I (95) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1d424h (119844) map
I (129) esp_image: segment 1: paddr=0002d44c vaddr=3ffb0000 size=02bcch ( 11212) load
I (131) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=6a94ch (436556) map
I (224) esp_image: segment 3: paddr=0009a974 vaddr=3ffb2bcc size=01010h ( 4112) load
I (226) esp_image: segment 4: paddr=0009b98c vaddr=40080000 size=166cch ( 91852) load
I (265) boot: Loaded app from partition at offset 0x10000
I (265) boot: Disabling RNG early entropy source...
I (276) cpu_start: Multicore app
I (285) cpu_start: Pro cpu start user code
I (285) cpu_start: cpu freq: 160000000 Hz
I (285) cpu_start: Application information:
I (288) cpu_start: Project name: deauth_detect
I (294) cpu_start: App version: fc0bda0-dirty
I (299) cpu_start: Compile time: Mar 23 2024 08:25:36
I (305) cpu_start: ELF file SHA256: 2e0eda11a...
I (311) cpu_start: ESP-IDF: v5.2.1-dirty
I (316) cpu_start: Min chip rev: v0.0
I (321) cpu_start: Max chip rev: v3.99
I (325) cpu_start: Chip rev: v1.0
I (330) heap_init: Initializing. RAM available for dynamic allocation:
I (338) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (343) heap_init: At 3FFB72F8 len 00028D08 (163 KiB): DRAM
I (350) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (356) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (362) heap_init: At 400966CC len 00009934 (38 KiB): IRAM
I (370) spi_flash: detected chip: generic
I (373) spi_flash: flash io: dio
I (378) main_task: Started on CPU0
I (388) main_task: Calling app_main()
Starting packet Detection...
I (388) deauth_sniffer: Before WiFi Initialization
I (408) deauth_sniffer: NVS Initialized
WiFi Init in progress...
I (418) wifi:wifi driver task: 3ffbcbf0, prio:23, stack:6656, core=0
I (418) wifi:wifi firmware version: a9f5b59
I (418) wifi:wifi certification version: v7.0
I (418) wifi:config NVS flash: enabled
I (418) wifi:config nano formating: disabled
I (428) wifi:Init data frame dynamic rx buffer num: 32
I (428) wifi:Init static rx mgmt buffer num: 5
I (438) wifi:Init management short buffer num: 32
I (438) wifi:Init dynamic tx buffer num: 32
I (448) wifi:Init static rx buffer size: 1600
I (448) wifi:Init static rx buffer num: 10
I (448) wifi:Init dynamic rx buffer num: 32
I (458) wifi_init: rx ba win: 6
I (458) wifi_init: tcpip mbox: 32
I (468) wifi_init: udp mbox: 6
I (468) wifi_init: tcp mbox: 6
I (468) wifi_init: tcp tx win: 5760
I (478) wifi_init: tcp rx win: 5760
I (478) wifi_init: tcp mss: 1440
I (478) wifi_init: WiFi IRAM OP enabled
I (488) wifi_init: WiFi RX IRAM OP enabled
I (488) deauth_sniffer: Wi-Fi Successfully initialized
I (498) deauth_sniffer: Wi-Fi RAM storage set
I (508) deauth_sniffer: Wi-Fi Mode set to NULL
I (508) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06
E (598) wifi:failed to post WiFi event=40 ret=259
I (608) wifi:mode : null
I (608) deauth_sniffer: Started WiFi!
I (608) deauth_sniffer: After WiFi Initialization
Setting Wi-Fi to promiscuous mode...
I (608) wifi:ic_enable_sniffer
I (618) deauth_sniffer: Wi-Fi initialized
Setup Complete.