diff --git a/platformio.ini b/platformio.ini index bc46b135..fd7a8ca3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -7,7 +7,7 @@ ; ---> SELECT THE TARGET PLATFORM HERE! <--- [board] -;halfile = generic.h +halfile = generic.h ;halfile = ebox.h ;halfile = eboxtube.h ;halfile = ecopower.h diff --git a/src/wifiscan.cpp b/src/wifiscan.cpp index 3839bf06..dc2fd29d 100644 --- a/src/wifiscan.cpp +++ b/src/wifiscan.cpp @@ -47,6 +47,7 @@ wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type) { // Software-timer driven Wifi channel rotation callback function void switchWifiChannel(TimerHandle_t xTimer) { + configASSERT(xTimer); channel = (channel % WIFI_CHANNEL_MAX) + 1; // rotate channel 1..WIFI_CHANNEL_MAX esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE); @@ -74,6 +75,7 @@ void wifi_sniffer_init(void) { ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); // no modem power saving ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set frame filter ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler)); + ESP_ERROR_CHECK(esp_wifi_start()); //for esp_wifi v3.3 ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode // setup wifi channel rotation timer @@ -85,14 +87,16 @@ void wifi_sniffer_init(void) { void switch_wifi_sniffer(uint8_t state) { assert(WifiChanTimer); - if ((state ? 1 : 0) == 1) { + if (state) { // switch wifi sniffer on + ESP_ERROR_CHECK(esp_wifi_start()); xTimerStart(WifiChanTimer, 0); esp_wifi_set_promiscuous(true); } else { // switch wifi sniffer off xTimerStop(WifiChanTimer, 0); esp_wifi_set_promiscuous(false); + ESP_ERROR_CHECK(esp_wifi_stop()); macs_wifi = 0; // clear WIFI counter } } \ No newline at end of file