Skip to content

Commit

Permalink
Stop BLE processing when immeditate command sent.
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Jan 20, 2022
1 parent 1638ab8 commit 5a8e273
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -974,9 +974,16 @@ void MQTTtoBTAction(JsonObject& BTdata) {
// If the request is to be performed immediately, stop the scan
// so the loop will process connections.
if (BTdata.containsKey("immediate") && BTdata["immediate"].as<bool>()) {
// Move this command to the front to process first
stopProcessing();
NimBLEScan* pScan = NimBLEDevice::getScan();
// Move this command to the front to process first
std::reverse(BLEactions.begin(), BLEactions.end());
NimBLEDevice::getScan()->stop();
if (pScan->isScanning()) {
pScan->stop();
} else {
BLEconnect();
}
startProcessing();
}
# endif
}
Expand Down

0 comments on commit 5a8e273

Please sign in to comment.