diff options
author | uvok | 2025-07-21 12:06:24 +0200 |
---|---|---|
committer | uvok | 2025-07-21 12:06:24 +0200 |
commit | 2780174203b4bd1a554a1186207e62c53400495a (patch) | |
tree | 0919a38176746a6613efe261827a04ce7fb7824f /src/ble.cpp | |
parent | 4c0a48b7ac40b1d89a45efab94890b9588625edd (diff) |
Check BLE connected count before sleep
otherwise we'll get disconnects.
Diffstat (limited to 'src/ble.cpp')
-rw-r--r-- | src/ble.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ble.cpp b/src/ble.cpp index f6f03ab..5cf8b00 100644 --- a/src/ble.cpp +++ b/src/ble.cpp @@ -85,15 +85,14 @@ void de::uvok::badge::ble_init(void) // get pictures auto call = service->createCharacteristic("ca260002-b4bb-46b2-bd06-b7b7a61ea990", NIMBLE_PROPERTY::READ); - // needs to be on heap??? - String *s = new String(); + String s{}; for (int i = 0; i < ARRAY_SIZE(templates); i++) { char tmp[32]; snprintf(tmp, sizeof(tmp), "%d-%s;", i, templates[i]); - s->concat(tmp); + s.concat(tmp); } - call->setValue(s->c_str()); + call->setValue(s.c_str()); service->start(); @@ -103,9 +102,10 @@ void de::uvok::badge::ble_init(void) pAdvertising->setName("NimBLE"); } -bool de::uvok::badge::ble_is_advertising(void) +bool de::uvok::badge::ble_is_active(void) { - return pAdvertising->isAdvertising(); + return pAdvertising->isAdvertising() || server->getConnectedCount() > 0; + // ???? NimBLEDevice::getConnectedClients().size() > 0; } void de::uvok::badge::ble_advertise(void) |