From fc84425730b278b3dbeae919aebac3c08c3c638f Mon Sep 17 00:00:00 2001 From: Eve <139727413+netrunnereve@users.noreply.github.com> Date: Mon, 2 Nov 2026 18:14:12 -0500 Subject: [PATCH 1/2] add cli option to set custom bluetooth name --- docs/companion_cli.md | 15 ++++++++++++++- examples/companion_radio/MyMesh.cpp | 20 ++++++++++++++++++++ examples/companion_radio/NodePrefs.h | 2 ++ examples/companion_radio/main.cpp | 2 +- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/docs/companion_cli.md b/docs/companion_cli.md index 31a055847b1..297c012c889 100644 --- a/docs/companion_cli.md +++ b/docs/companion_cli.md @@ -320,6 +320,19 @@ Radio parameters are common to all roles and handled by `CommonRadioPrefs`. --- +#### Change BLE name +**Usage:** +- `get ble_name` +- `set ble_name ` +- `set ble_name_clear` + +**Parameters:** +- `name`: New BLE name + +**Note:** If this is unset or cleared the node name will be used as the BLE name. These commands require a reboot to take effect. + +--- + ### Wifi #### Get status @@ -469,4 +482,4 @@ When screen is blanked, the controller is also put into hibernation, which shoul **Default:** 0 (no partial refresh or set by `EINK_MAX_PARTIAL_REFRESH` build flag) **Note:** -Forcing full refresh helps revives the screen when some tearing appears (under certain environmental conditions). If you see some tearing appearing, you can force full refresh on your screen manually by double clicking the backlight button. If tearing reappears often, use this setting to force full refresh every `value` partial refreshes. \ No newline at end of file +Forcing full refresh helps revives the screen when some tearing appears (under certain environmental conditions). If you see some tearing appearing, you can force full refresh on your screen manually by double clicking the backlight button. If tearing reappears often, use this setting to force full refresh every `value` partial refreshes. diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 755c56d14c0..d4488f739b3 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -2147,6 +2147,26 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char* sprintf(reply, "> pin is now %06d", _prefs.ble_pin); return true; } + if (memcmp(command, "set ble_name ", 13) == 0) { + if (AdvertDataParser::isValidName(&command[13])) { + StrHelper::strncpy(_prefs.ble_name, &command[13], sizeof(_prefs.ble_name)); + savePrefs(); + sprintf(reply, "> ble_name is now %s (reboot to apply)", _prefs.ble_name); + } else { + strcpy(reply, "Error, bad chars"); + } + return true; + } + if (strcmp(command, "get ble_name") == 0) { + sprintf(reply, "> %s", _prefs.ble_name[0] ? _prefs.ble_name : "(not set)"); + return true; + } + if (strcmp(command, "set ble_name_clear") == 0) { + _prefs.ble_name[0] = 0; + savePrefs(); + strcpy(reply, "> custom ble name cleared (reboot to apply)"); + return true; + } #ifdef ENABLE_WIFI_INTERFACE if (memcmp(command, "set wifi.ssid ", 14) == 0) { diff --git a/examples/companion_radio/NodePrefs.h b/examples/companion_radio/NodePrefs.h index c5d1df04a42..8a7bc482fca 100644 --- a/examples/companion_radio/NodePrefs.h +++ b/examples/companion_radio/NodePrefs.h @@ -30,6 +30,7 @@ class NodePrefs : public ConfigSerializer { // persisted to file float tx_delay_factor = 0; float direct_tx_delay_factor = 0; uint32_t ble_pin = 0; + char ble_name[32] = {0}; uint8_t advert_loc_policy = 0; uint8_t buzzer_quiet = 0; uint8_t vibe_quiet = 0; @@ -186,6 +187,7 @@ class NodePrefs : public ConfigSerializer { // persisted to file def("defs_nm", _parent->default_scope_name, sizeof(_parent->default_scope_name)); def("defs_key", (void *) _parent->default_scope_key, sizeof(_parent->default_scope_key)); def("pin", _parent->ble_pin); + def("ble_name", _parent->ble_name, sizeof(_parent->ble_name)); def("buzz_q", _parent->buzzer_quiet); def("vibe_q", _parent->vibe_quiet); def("auto_add", _parent->autoadd_config); // bitmask for auto-add contacts config diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 839d4958336..167f6a799ba 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -206,7 +206,7 @@ void setup() { // add bluetooth interface #if defined(BLE_PIN_CODE) - bluetooth_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin()); + bluetooth_interface.begin(BLE_NAME_PREFIX, the_mesh.getNodePrefs()->ble_name[0] ? the_mesh.getNodePrefs()->ble_name : the_mesh.getNodePrefs()->node_name, the_mesh.getBLEPin()); interface_manager.addInterface(InterfaceType::Bluetooth, &bluetooth_interface); #endif From 1cdd9c5b4bfa42a32ccbbe5f25c8b861ac1496de Mon Sep 17 00:00:00 2001 From: Eve <139727413+netrunnereve@users.noreply.github.com> Date: Wed, 4 Nov 2026 16:51:55 -0500 Subject: [PATCH 2/2] change command to set ble_name_default --- docs/companion_cli.md | 6 +++--- examples/companion_radio/MyMesh.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/companion_cli.md b/docs/companion_cli.md index 297c012c889..0dec6a27a01 100644 --- a/docs/companion_cli.md +++ b/docs/companion_cli.md @@ -324,12 +324,12 @@ Radio parameters are common to all roles and handled by `CommonRadioPrefs`. **Usage:** - `get ble_name` - `set ble_name ` -- `set ble_name_clear` +- `set ble_name_default` **Parameters:** - `name`: New BLE name -**Note:** If this is unset or cleared the node name will be used as the BLE name. These commands require a reboot to take effect. +**Note:** By default the node name will be used as the BLE name. These commands require a reboot to take effect. --- @@ -482,4 +482,4 @@ When screen is blanked, the controller is also put into hibernation, which shoul **Default:** 0 (no partial refresh or set by `EINK_MAX_PARTIAL_REFRESH` build flag) **Note:** -Forcing full refresh helps revives the screen when some tearing appears (under certain environmental conditions). If you see some tearing appearing, you can force full refresh on your screen manually by double clicking the backlight button. If tearing reappears often, use this setting to force full refresh every `value` partial refreshes. +Forcing full refresh helps revives the screen when some tearing appears (under certain environmental conditions). If you see some tearing appearing, you can force full refresh on your screen manually by double clicking the backlight button. If tearing reappears often, use this setting to force full refresh every `value` partial refreshes. \ No newline at end of file diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index d4488f739b3..a18d0062e3b 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -2151,20 +2151,20 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char* if (AdvertDataParser::isValidName(&command[13])) { StrHelper::strncpy(_prefs.ble_name, &command[13], sizeof(_prefs.ble_name)); savePrefs(); - sprintf(reply, "> ble_name is now %s (reboot to apply)", _prefs.ble_name); + sprintf(reply, "> BLE name is now %s (reboot to apply)", _prefs.ble_name); } else { strcpy(reply, "Error, bad chars"); } return true; } if (strcmp(command, "get ble_name") == 0) { - sprintf(reply, "> %s", _prefs.ble_name[0] ? _prefs.ble_name : "(not set)"); + sprintf(reply, "> %s", _prefs.ble_name[0] ? _prefs.ble_name : _prefs.node_name); return true; } - if (strcmp(command, "set ble_name_clear") == 0) { + if (strcmp(command, "set ble_name_default") == 0) { _prefs.ble_name[0] = 0; savePrefs(); - strcpy(reply, "> custom ble name cleared (reboot to apply)"); + sprintf(reply, "> BLE name reset to %s (reboot to apply)", _prefs.node_name); return true; }