enhanced BLE scan parameters

This commit is contained in:
Klaus K Wilting 2018-04-06 21:34:25 +02:00
parent 9acdd1d575
commit f9ba346c68
2 changed files with 25 additions and 8 deletions

View File

@ -105,6 +105,8 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
http://www.libelium.com/products/meshlium/smartphone-detection/ http://www.libelium.com/products/meshlium/smartphone-detection/
http://dev.ti.com/tirex/content/simplelink_academy_cc2640r2sdk_1_12_01_16/modules/ble_scan_adv_basic/ble_scan_adv_basic.html
"The Class of Device (CoD) in case of Bluetooth which allows us to differentiate the type of "The Class of Device (CoD) in case of Bluetooth which allows us to differentiate the type of
device (smartphone, handsfree, computer, LAN/network AP). With this parameter we can device (smartphone, handsfree, computer, LAN/network AP). With this parameter we can
differentiate among pedestrians and vehicles." differentiate among pedestrians and vehicles."
@ -133,6 +135,8 @@ void BLECount() {
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(false); // An active scan would mean that we will wish a scan response. pBLEScan->setActiveScan(false); // An active scan would mean that we will wish a scan response.
pBLEScan->setWindow(BLESCANWINDOW);
pBLEScan->setInterval(BLESCANINTERVAL);
BLEScanResults foundDevices = pBLEScan->start(cfg.blescantime); // note: this is a blocking call BLEScanResults foundDevices = pBLEScan->start(cfg.blescantime); // note: this is a blocking call
int blenum=foundDevices.getCount(); int blenum=foundDevices.getCount();
ESP_LOGI(TAG, "BLE scan done, seen %d device(s)", blenum); ESP_LOGI(TAG, "BLE scan done, seen %d device(s)", blenum);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
// program version - note: increment version after modifications to configData_t struct!! // program version - note: increment version after modifications to configData_t struct!!
#define PROGVERSION "1.2.94" // use max 10 chars here! #define PROGVERSION "1.2.95" // use max 10 chars here!
#define PROGNAME "PAXCNT" #define PROGNAME "PAXCNT"
// Verbose enables serial output // Verbose enables serial output
@ -11,20 +11,33 @@
#define VENDORFILTER 1 // comment out if you want to count things, not people #define VENDORFILTER 1 // comment out if you want to count things, not people
#define BLECOUNTER 1 // comment out if you don't want BLE count #define BLECOUNTER 1 // comment out if you don't want BLE count
// BLE scan time // BLE scan parameters
#define BLESCANTIME 10 // [seconds]
#define BLESCANCYCLE 2 // BLE scan once after each <BLECYCLE> wifi scans #define BLESCANCYCLE 2 // BLE scan once after each <BLECYCLE> wifi scans
#define BLESCANTIME 11 // [seconds] scan duration, see above
#define BLESCANWINDOW 100 // [milliseconds] scan window, see above, 25 .. 10240
#define BLESCANINTERVAL 100 // [milliseconds] how long to wait between scans, 25 .. 10240
/*
*
* |< Scan Window > |< Scan Window > |< Scan Window > |
* |< Scan Interval >|< Scan Interval >|< Scan Interval >|
* |< Scan duration >|
*
* Scan duration sets how long scanning should be going on, interrupting a wifi scan cycle.
* Scan window sets how much of the interval should be occupied by scanning.
* Scan interval is how long scanning should be done on each channel. BLE uses 3 channels for advertising.
* -> Adjust these values with power consumption in mind if power is limited.
*/
// WiFi Sniffer cycle interval // WiFi scan parameters
#define SEND_SECS 120 // [seconds/2] -> 240 sec.
//#define SEND_SECS 30 // [seconds/2] -> 60 sec.
// WiFi sniffer config
#define WIFI_CHANNEL_MIN 1 // start channel number where scan begings #define WIFI_CHANNEL_MIN 1 // start channel number where scan begings
#define WIFI_CHANNEL_MAX 13 // total channel number to scan #define WIFI_CHANNEL_MAX 13 // total channel number to scan
#define WIFI_MY_COUNTRY "EU" // select locale for Wifi RF settings #define WIFI_MY_COUNTRY "EU" // select locale for Wifi RF settings
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec. #define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
// LoRa payload send cycle
#define SEND_SECS 120 // [seconds/2] -> 240 sec.
//#define SEND_SECS 30 // [seconds/2] -> 60 sec.
// Default LoRa Spreadfactor // Default LoRa Spreadfactor
#define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs #define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy #define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy