BLE install logic changed (issue #612)

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

No files matched your search

+2 -2
View File
@@ -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%)
+9 -4
View File
@@ -315,9 +315,9 @@ void setup() {
#if (HAS_SENSOR_1)
#if (COUNT_ENS)
ESP_LOGI(TAG, "init CWA-counter");
if ( cwa_init() )
strcat_P(features, " CWA");
#else
if (cwa_init())
strcat_P(features, " CWA");
#else
strcat_P(features, " SENS(1)");
sensor_init();
#endif
@@ -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();
+4 -4
View File
@@ -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
-2
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_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) {