Merge pull request #3754 from netrunnereve/bluetooth-name
Allow the user to set a custom bluetooth name using the cli
This commit is contained in:
commit
04afba03ba
4 files changed
+45
-1
No files matched your search
@@ -413,6 +413,18 @@ Radio parameters are common to all roles and handled by `CommonRadioPrefs`.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
#### Change BLE name
|
||||||
|
**Usage:**
|
||||||
|
- `get ble.name`
|
||||||
|
- `set ble.name <name>`
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `name`: New BLE name
|
||||||
|
|
||||||
|
**Note:** By default the BLE name is `Meshcore-` followed by the node name. If `<name>` is empty the BLE name will be reset to the aforementioned default. These commands require a reboot to take effect.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Wifi
|
### Wifi
|
||||||
|
|
||||||
#### Get status
|
#### Get status
|
||||||
|
|||||||
@@ -2154,6 +2154,30 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
|
|||||||
sprintf(reply, "> pin is now %06d", _prefs.ble_pin);
|
sprintf(reply, "> pin is now %06d", _prefs.ble_pin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (strcmp(command, "set ble.name") == 0) {
|
||||||
|
_prefs.ble_name[0] = 0;
|
||||||
|
savePrefs();
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
if (_prefs.ble_name[0]) {
|
||||||
|
sprintf(reply, "> %s", _prefs.ble_name);
|
||||||
|
} else {
|
||||||
|
sprintf(reply, "> %s%s", BLE_NAME_PREFIX, _prefs.node_name);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WIFI_INTERFACE
|
#ifdef ENABLE_WIFI_INTERFACE
|
||||||
if (memcmp(command, "set wifi.ssid ", 14) == 0) {
|
if (memcmp(command, "set wifi.ssid ", 14) == 0) {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
float tx_delay_factor = 0;
|
float tx_delay_factor = 0;
|
||||||
float direct_tx_delay_factor = 0;
|
float direct_tx_delay_factor = 0;
|
||||||
uint32_t ble_pin = 0;
|
uint32_t ble_pin = 0;
|
||||||
|
char ble_name[32] = {0};
|
||||||
uint8_t advert_loc_policy = 0;
|
uint8_t advert_loc_policy = 0;
|
||||||
uint8_t buzzer_quiet = 0;
|
uint8_t buzzer_quiet = 0;
|
||||||
uint8_t vibe_quiet = 0;
|
uint8_t vibe_quiet = 0;
|
||||||
@@ -224,6 +225,7 @@ private:
|
|||||||
def("defs_nm", _parent->default_scope_name, sizeof(_parent->default_scope_name));
|
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("defs_key", (void *) _parent->default_scope_key, sizeof(_parent->default_scope_key));
|
||||||
def("pin", _parent->ble_pin);
|
def("pin", _parent->ble_pin);
|
||||||
|
def("ble_name", _parent->ble_name, sizeof(_parent->ble_name));
|
||||||
def("buzz_q", _parent->buzzer_quiet);
|
def("buzz_q", _parent->buzzer_quiet);
|
||||||
def("vibe_q", _parent->vibe_quiet);
|
def("vibe_q", _parent->vibe_quiet);
|
||||||
def("auto_add", _parent->autoadd_config); // bitmask for auto-add contacts config
|
def("auto_add", _parent->autoadd_config); // bitmask for auto-add contacts config
|
||||||
|
|||||||
@@ -215,7 +215,13 @@ void setup() {
|
|||||||
|
|
||||||
// add bluetooth interface
|
// add bluetooth interface
|
||||||
#if defined(BLE_PIN_CODE)
|
#if defined(BLE_PIN_CODE)
|
||||||
bluetooth_interface.begin(BLE_NAME_PREFIX, 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);
|
interface_manager.addInterface(InterfaceType::Bluetooth, &bluetooth_interface);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user