BLE install logic changed (issue #612)
This commit is contained in:
parent
2a9469422c
commit
f2b6e12bc9
@ -79,7 +79,7 @@ Some <b>3D printable cases</b> can be found (and, if wanted so, ordered) on Thin
|
||||
for example.<br>
|
||||
|
||||
<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
|
||||
|
||||
|
@ -29,8 +29,8 @@ void defaultConfig() {
|
||||
cfg.blescantime =
|
||||
BLESCANINTERVAL /
|
||||
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
|
||||
cfg.blescan = BLECOUNTER; // 0=disabled, 1=enabled
|
||||
cfg.wifiscan = WIFICOUNTER; // 0=disabled, 1=enabled
|
||||
cfg.blescan = 1; // 0=disabled, 1=enabled
|
||||
cfg.wifiscan = 1; // 0=disabled, 1=enabled
|
||||
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
|
||||
cfg.vendorfilter = VENDORFILTER; // 0=disabled, 1=enabled
|
||||
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
|
||||
|
11
src/main.cpp
11
src/main.cpp
@ -315,8 +315,8 @@ void setup() {
|
||||
#if (HAS_SENSOR_1)
|
||||
#if (COUNT_ENS)
|
||||
ESP_LOGI(TAG, "init CWA-counter");
|
||||
if ( cwa_init() )
|
||||
strcat_P(features, " CWA");
|
||||
if (cwa_init())
|
||||
strcat_P(features, " CWA");
|
||||
#else
|
||||
strcat_P(features, " SENS(1)");
|
||||
sensor_init();
|
||||
@ -402,8 +402,13 @@ void setup() {
|
||||
#if (WIFICOUNTER)
|
||||
strcat_P(features, " WIFI");
|
||||
// start wifi in monitor mode and start channel rotation timer
|
||||
ESP_LOGI(TAG, "Starting Wifi...");
|
||||
|
||||
wifi_sniffer_init();
|
||||
if (cfg.blescan) {
|
||||
ESP_LOGI(TAG, "Starting Wifi...");
|
||||
switch_wifi_sniffer(1);
|
||||
} else
|
||||
switch_wifi_sniffer(0);
|
||||
#else
|
||||
// switch off wifi
|
||||
esp_wifi_deinit();
|
||||
|
@ -7,17 +7,17 @@
|
||||
// Note: After editing, before "build", use "clean" button in PlatformIO!
|
||||
|
||||
// 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
|
||||
#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 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
|
||||
#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 WIFICOUNTER 1 // set it to 0 if you want to switch off WIFI count
|
||||
#define BLECOUNTER 0 // set to 0 if you do not want to install the BLE sniffer
|
||||
#define WIFICOUNTER 1 // set to 0 if you do not want to install the WIFI sniffer
|
||||
|
||||
// BLE scan parameters
|
||||
#define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below
|
||||
|
@ -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_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
|
||||
WifiChanTimer =
|
||||
xTimerCreate("WifiChannelTimer", pdMS_TO_TICKS(cfg.wifichancycle * 10),
|
||||
pdTRUE, (void *)0, switchWifiChannel);
|
||||
switch_wifi_sniffer(1);
|
||||
}
|
||||
|
||||
void switch_wifi_sniffer(uint8_t state) {
|
||||
|
Loading…
Reference in New Issue
Block a user