Repository navigation
Allow the user to set a custom bluetooth name using the cli #3754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2154,6 +2154,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 : _prefs.node_name); | ||
| return true; | ||
| } | ||
| if (strcmp(command, "set ble_name_default") == 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could probably avoid having this extra command, by checking if the name passed to |
||
| _prefs.ble_name[0] = 0; | ||
| savePrefs(); | ||
| sprintf(reply, "> BLE name reset to %s (reboot to apply)", _prefs.node_name); | ||
| return true; | ||
| } | ||
|
|
||
| #ifdef ENABLE_WIFI_INTERFACE | ||
| if (memcmp(command, "set wifi.ssid ", 14) == 0) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,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; | ||
|
|
@@ -216,6 +217,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)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Underscore is fine here, just recommend updating the command strings themselves. |
||
| def("buzz_q", _parent->buzzer_quiet); | ||
| def("vibe_q", _parent->vibe_quiet); | ||
| def("auto_add", _parent->autoadd_config); // bitmask for auto-add contacts config | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please change all the commands from
set ble_nametoset ble.name. This will keep is consistent with all the other commands we have, that use dot notation, instead of underscores.