BLE install logic changed (issue #612)

This commit is contained in:
Klaus K Wilting 2020-09-12 19:11:13 +02:00
parent 2a9469422c
commit f2b6e12bc9
5 changed files with 16 additions and 13 deletions

View File

@ -79,7 +79,7 @@ Some <b>3D printable cases</b> can be found (and, if wanted so, ordered) on Thin
for example.<br> for example.<br>
<b>Power consumption</b> was metered at around 450 - 1000mW, depending on board and user settings in paxcounter.conf. <b>Power consumption</b> was metered at around 450 - 1000mW, depending on board and user settings in paxcounter.conf.
By default bluetooth sniffing is disabled (#define *BLECOUNTER* 0 in paxcounter.conf). Enabling bluetooth costs 30% more power + 30% flash storage for the software stack. Proof of concept showed that for passenger flow metering wifi sniffing shows better results than bluetooth sniffing. If you enable bluetooth be aware that this goes on expense of wifi sniffing results, because then wifi and bt stack must share the 2,4 GHz RF ressources of ESP32. If you need to sniff wifi and bt in parallel and need best possible results, use two boards - one for wifi only and one for bt only - and add counted results. By default bluetooth sniffing not installed (#define *BLECOUNTER* 0 in paxcounter.conf). Installing and enabling bluetooth costs 30% more power + 30% flash storage for the software stack. If you enable bluetooth be aware that this goes on expense of wifi sniffing results, because then wifi and bt stack must share the 2,4 GHz RF ressources of ESP32. If you need to sniff wifi and bt in parallel and need best possible results, use two boards - one for wifi only and one for bt only - and add counted results.
# Preparing # Preparing

View File

@ -29,8 +29,8 @@ void defaultConfig() {
cfg.blescantime = cfg.blescantime =
BLESCANINTERVAL / BLESCANINTERVAL /
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms) 10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
cfg.blescan = BLECOUNTER; // 0=disabled, 1=enabled cfg.blescan = 1; // 0=disabled, 1=enabled
cfg.wifiscan = WIFICOUNTER; // 0=disabled, 1=enabled cfg.wifiscan = 1; // 0=disabled, 1=enabled
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4) cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
cfg.vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled cfg.vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%) cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)

View File

@ -315,9 +315,9 @@ void setup() {
#if (HAS_SENSOR_1) #if (HAS_SENSOR_1)
#if (COUNT_ENS) #if (COUNT_ENS)
ESP_LOGI(TAG, "init CWA-counter"); ESP_LOGI(TAG, "init CWA-counter");
if ( cwa_init() ) if (cwa_init())
strcat_P(features, " CWA"); strcat_P(features, " CWA");
#else #else
strcat_P(features, " SENS(1)"); strcat_P(features, " SENS(1)");
sensor_init(); sensor_init();
#endif #endif
@ -402,8 +402,13 @@ void setup() {
#if (WIFICOUNTER) #if (WIFICOUNTER)
strcat_P(features, " WIFI"); strcat_P(features, " WIFI");
// start wifi in monitor mode and start channel rotation timer // start wifi in monitor mode and start channel rotation timer
ESP_LOGI(TAG, "Starting Wifi...");
wifi_sniffer_init(); wifi_sniffer_init();
if (cfg.blescan) {
ESP_LOGI(TAG, "Starting Wifi...");
switch_wifi_sniffer(1);
} else
switch_wifi_sniffer(0);
#else #else
// switch off wifi // switch off wifi
esp_wifi_deinit(); esp_wifi_deinit();

View File

@ -7,17 +7,17 @@
// Note: After editing, before "build", use "clean" button in PlatformIO! // Note: After editing, before "build", use "clean" button in PlatformIO!
// Verbose enables additional serial debug output // Verbose enables additional serial debug output
#define VERBOSE 0 // set to 0 to silence the device, for mute use build option #define VERBOSE 1 // set to 0 to silence the device, for mute use build option
// Payload send cycle and encoding // Payload send cycle and encoding
#define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255 #define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255
#define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed #define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed
#define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed #define COUNTERMODE 1 // 0=cyclic, 1=cumulative, 2=cyclic confirmed
// Set this to include BLE counting and vendor filter functions, or to switch off WIFI counting // Set this to include BLE counting and vendor filter functions, or to switch off WIFI counting
#define VENDORFILTER 0 // set to 0 if you want to scan all devices, not filtering smartphone OUIs #define VENDORFILTER 0 // set to 0 if you want to scan all devices, not filtering smartphone OUIs
#define BLECOUNTER 0 // set it to 1 if you want to use BLE count, at expense of power & memory #define BLECOUNTER 0 // set to 0 if you do not want to install the BLE sniffer
#define WIFICOUNTER 1 // set it to 0 if you want to switch off WIFI count #define WIFICOUNTER 1 // set to 0 if you do not want to install the WIFI sniffer
// BLE scan parameters // BLE scan parameters
#define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below #define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below

View File

@ -73,14 +73,12 @@ 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_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_filter(&filter)); // set frame filter
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler)); 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 ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode
// setup wifi channel rotation timer // setup wifi channel rotation timer
WifiChanTimer = WifiChanTimer =
xTimerCreate("WifiChannelTimer", pdMS_TO_TICKS(cfg.wifichancycle * 10), xTimerCreate("WifiChannelTimer", pdMS_TO_TICKS(cfg.wifichancycle * 10),
pdTRUE, (void *)0, switchWifiChannel); pdTRUE, (void *)0, switchWifiChannel);
switch_wifi_sniffer(1);
} }
void switch_wifi_sniffer(uint8_t state) { void switch_wifi_sniffer(uint8_t state) {