Refresh nRF52 Companion BLE name without reboot
This commit is contained in:
1 parent
a569f55dc7
commit
960936183c
4 files changed
+86
-16
No files matched your search
@@ -6663,11 +6663,19 @@ bool MyMesh::applyAndSaveBluetoothName(const char* value, char* reply,
|
||||
|
||||
if (use_default) {
|
||||
snprintf(reply, reply_size,
|
||||
#if defined(NRF52_PLATFORM)
|
||||
"OK - Bluetooth name follows %s<node name>; advertising refreshes after disconnect",
|
||||
#else
|
||||
"OK - Bluetooth name follows %s<node name>; reboot required",
|
||||
#endif
|
||||
BLE_NAME_PREFIX);
|
||||
} else {
|
||||
snprintf(reply, reply_size,
|
||||
#if defined(NRF52_PLATFORM)
|
||||
"OK - Bluetooth name saved as '%s'; advertising refreshes after disconnect", value);
|
||||
#else
|
||||
"OK - Bluetooth name saved as '%s'; reboot required", value);
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2323,6 +2323,24 @@ void halt() {
|
||||
startCompanionBluetooth();
|
||||
}
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
static void serviceCompanionBluetoothName() {
|
||||
if (!companion_bluetooth_initialized) return;
|
||||
static uint32_t last_check = 0;
|
||||
const uint32_t now = millis();
|
||||
if ((uint32_t)(now - last_check) < 250) return;
|
||||
last_check = now;
|
||||
|
||||
const CompanionNodePrefs* prefs = the_mesh.getNodePrefs();
|
||||
if (prefs == nullptr) return;
|
||||
const bool custom =
|
||||
mesh::companion::hasCustomBluetoothName(prefs->bluetooth_name);
|
||||
bluetooth_interface.refreshName(custom ? "" : BLE_NAME_PREFIX,
|
||||
custom ? prefs->bluetooth_name
|
||||
: prefs->node_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void serviceCompanionBluetoothIdentity() {
|
||||
if (!companion_bluetooth_initialized) return;
|
||||
|
||||
@@ -3472,5 +3490,8 @@ void loop() {
|
||||
#endif
|
||||
serviceCompanionBluetoothIdentity();
|
||||
serviceCompanionBluetoothControl();
|
||||
#if defined(NRF52_PLATFORM)
|
||||
serviceCompanionBluetoothName();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user