From 41fd41b59b75843e5303b2bc29a605853aec95c3 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Sun, 17 Nov 2019 14:13:48 +0100 Subject: [PATCH] wifiscan.cpp: fix wifi on/off --- platformio.ini | 6 +++--- src/wifiscan.cpp | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index eac7d350..9022031c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -7,11 +7,11 @@ ; ---> SELECT THE TARGET PLATFORM HERE! <--- [board] -;halfile = generic.h +halfile = generic.h ;halfile = ebox.h ;halfile = eboxtube.h ;halfile = ecopower.h -halfile = heltec.h +;halfile = heltec.h ;halfile = heltecv2.h ;halfile = ttgov1.h ;halfile = ttgov2.h @@ -43,7 +43,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.9.8 +release_version = 1.9.81 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose debug_level = 3 diff --git a/src/wifiscan.cpp b/src/wifiscan.cpp index 3839bf06..cdfcc8b0 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); @@ -85,14 +86,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