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 | |
parent | 4c0a48b7ac40b1d89a45efab94890b9588625edd (diff) |
Check BLE connected count before sleep
otherwise we'll get disconnects.
Diffstat (limited to 'src')
-rw-r--r-- | src/ble.cpp | 12 | ||||
-rw-r--r-- | src/main.cpp | 2 |
2 files changed, 7 insertions, 7 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) diff --git a/src/main.cpp b/src/main.cpp index 2495c1e..af388bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,7 +90,7 @@ void loop() } } - if (millis() - lastActivity > SLEEP_TIME && !de::uvok::badge::ble_is_advertising()) + if (millis() - lastActivity > SLEEP_TIME && !de::uvok::badge::ble_is_active()) { // RTC watchdog might reset ??? - not sure when/how this happens... // (Happened with CPU@240MHz, not at 80 MHz yet?) |