NRF52 bluetooth cleanup and fix (#3328)

* NRF52 bluetooth cleanup. Fixes BLE not returning after serial PhoneAPI connection

* Use new var name in esp32 arch
This commit is contained in:
Ben Meadors
2024-03-03 13:56:55 -06:00
committed by GitHub
parent e5bf07d4fb
commit 72050530f1
9 changed files with 39 additions and 27 deletions

View File

@@ -210,8 +210,10 @@ void NRF52Bluetooth::shutdown()
{
// Shutdown bluetooth for minimum power draw
LOG_INFO("Disable NRF52 bluetooth\n");
if (connectionHandle != 0) {
Bluefruit.disconnect(connectionHandle);
}
Bluefruit.Advertising.stop();
Bluefruit.setTxPower(0); // Minimum power
}
bool NRF52Bluetooth::isConnected()
@@ -289,6 +291,14 @@ void NRF52Bluetooth::setup()
}
}
void NRF52Bluetooth::resumeAdverising()
{
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0);
}
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level)
{