diff --git a/docs/companion_cli.md b/docs/companion_cli.md index d861b81e9..212eb905c 100644 --- a/docs/companion_cli.md +++ b/docs/companion_cli.md @@ -421,7 +421,7 @@ Radio parameters are common to all roles and handled by `CommonRadioPrefs`. **Parameters:** - `name`: New BLE name -**Note:** By default the node name will be used as the BLE name. If `` is empty the BLE name will be reset to the aforementioned default. These commands require a reboot to take effect. +**Note:** By default the BLE name is `Meshcore-` followed by the node name. If `` is empty the BLE name will be reset to the aforementioned default. These commands require a reboot to take effect. --- diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 91a9c8ab5..cd6966e8a 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -2157,7 +2157,7 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char* if (strcmp(command, "set ble.name") == 0) { _prefs.ble_name[0] = 0; savePrefs(); - sprintf(reply, "> BLE name reset to %s (reboot to apply)", _prefs.node_name); + sprintf(reply, "> BLE name reset to %s%s (reboot to apply)", BLE_NAME_PREFIX, _prefs.node_name); return true; } if (memcmp(command, "set ble.name ", 13) == 0) { @@ -2171,7 +2171,11 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char* return true; } if (strcmp(command, "get ble.name") == 0) { - sprintf(reply, "> %s", _prefs.ble_name[0] ? _prefs.ble_name : _prefs.node_name); + if (_prefs.ble_name[0]) { + sprintf(reply, "> %s", _prefs.ble_name); + } else { + sprintf(reply, "> %s%s", BLE_NAME_PREFIX, _prefs.node_name); + } return true; } diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 82f2b2364..3e7ec6dcf 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -215,7 +215,13 @@ void setup() { // add bluetooth interface #if defined(BLE_PIN_CODE) - 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()); + char *prefix = BLE_NAME_PREFIX; + char *ble_name = the_mesh.getNodePrefs()->node_name; + if (the_mesh.getNodePrefs()->ble_name[0]) { + prefix = ""; + ble_name = the_mesh.getNodePrefs()->ble_name; + } + bluetooth_interface.begin((const char *) prefix, ble_name, the_mesh.getBLEPin()); interface_manager.addInterface(InterfaceType::Bluetooth, &bluetooth_interface); #endif