Skip to content

Commit

Permalink
Added new BLEScan mode: BLEScan2 nn - start a manual scan for nn seco…
Browse files Browse the repository at this point in the history
…nds and publish on tele when at least one device is found
  • Loading branch information
fellev committed Nov 24, 2024
1 parent 3c13d81 commit 1d398e0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tasmota/tasmota_xdrv_driver/xdrv_79_esp32_ble.ino
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
performs a manual scan or set passive/active
*BLEScan0 0 - set passive scan
BLEScan0 1 - set active scan (you may get names)
BLEScan1 nn - start a manula scan for nn seconds
BLEScan1 nn - start a manual scan for nn seconds
BLEScan2 nn - start a manual scan for nn seconds and publish on tele when at least one device is found
BLEAlias
<mac>=<name> <mac>=<name> - set one or more aliases for addresses
BLEName
Expand Down Expand Up @@ -603,6 +604,7 @@ uint8_t BLEMode = BLEModeRegularScan;
uint8_t BLETriggerScan = 0;
uint8_t BLEAdvertMode = BLE_ADV_TELE;
uint8_t BLEdeviceLimitReached = 0;
uint8_t BLEpostWhenFound = 0;

uint8_t BLEStop = 0;
uint64_t BLEStopAt = 0;
Expand Down Expand Up @@ -2347,6 +2349,12 @@ static void BLEEverySecond(bool restart){
BLE_ESP32::BLEPostMQTT(false); // show all operations, not just completed
}

if ((BLEpostWhenFound == 1) && (seenDevices.size() > 0))
{
BLEPublishDevices = 2; // mqtt publish as 'STAT'
BLEpostWhenFound = 0;
}

if (BLEPublishDevices){
BLEPostMQTTSeenDevices(BLEPublishDevices);
BLEShowStats();
Expand Down Expand Up @@ -2725,6 +2733,8 @@ void CmndBLEScan(void){
}
} break;

case 2: // post on tele when at leat one device is found
BLEpostWhenFound = 1;
case 1: // do a manual scan now
switch (BLEMode){
case BLEModeScanByCommand: {
Expand Down

0 comments on commit 1d398e0

Please sign in to comment.