BLE low power mode and settings optimization (#902)
* BLE low power mode and settings optimization -low power mode settings example -take into account parameters following #891 -add esp32dev-ble-cont for door/window sensor listening * Disable WDT during scan * update esp32 arduino framework
This commit is contained in:
1 parent
863a56b389
commit
b9151bb6ac
3 files changed
+47
-7
No files matched your search
+6
-5
@@ -617,19 +617,20 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
||||
* BLEscan used to retrieve BLE advertized data from devices without connection
|
||||
*/
|
||||
void BLEscan() {
|
||||
TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
|
||||
TIMERG0.wdt_feed = 1;
|
||||
TIMERG0.wdt_wprotect = 0;
|
||||
disableCore0WDT();
|
||||
Log.notice(F("Scan begin" CR));
|
||||
BLEDevice::init("");
|
||||
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
|
||||
BLEScan* pBLEScan = BLEDevice::getScan();
|
||||
MyAdvertisedDeviceCallbacks myCallbacks;
|
||||
pBLEScan->setAdvertisedDeviceCallbacks(&myCallbacks);
|
||||
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
||||
pBLEScan->setActiveScan(ActiveBLEScan);
|
||||
pBLEScan->setInterval(BLEScanInterval);
|
||||
pBLEScan->setWindow(BLEScanWindow);
|
||||
BLEScanResults foundDevices = pBLEScan->start(Scan_duration / 1000, false);
|
||||
scanCount++;
|
||||
Log.notice(F("Found %d devices, scan number %d end deinit controller" CR), foundDevices.getCount(), scanCount);
|
||||
BLEDevice::deinit(true);
|
||||
enableCore0WDT();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+10
-1
@@ -48,7 +48,16 @@ bool bleConnect = AttemptBLECOnnect;
|
||||
#define MinimumRSSI -100 //default minimum rssi value, all the devices below -90 will not be reported
|
||||
|
||||
#ifndef Scan_duration
|
||||
# define Scan_duration 10000 //define the time for a scan --WARNING-- changing this value can lead to instability on ESP32
|
||||
# define Scan_duration 10000 //define the time for a scan
|
||||
#endif
|
||||
#ifndef BLEScanInterval
|
||||
# define BLEScanInterval 52 // How often the scan occurs / switches channels; in milliseconds,
|
||||
#endif
|
||||
#ifndef BLEScanWindow
|
||||
# define BLEScanWindow 30 // How long to scan during the interval; in milliseconds.
|
||||
#endif
|
||||
#ifndef ActiveBLEScan
|
||||
# define ActiveBLEScan true // Set active scanning, this will get more data from the advertiser.
|
||||
#endif
|
||||
#ifndef ScanBeforeConnect
|
||||
# define ScanBeforeConnect 10 //define number of scans before connecting to BLE devices (ESP32 only, minimum 1)
|
||||
|
||||
Reference in new issue
Block a user