Skip to content

Allow the user to set a custom bluetooth name using the cli - #3754

Open
netrunnereve wants to merge 1 commit into
meshcore-dev:devfrom
netrunnereve:bluetooth-name
Open

netrunnereve wants to merge 1 commit into
meshcore-dev:devfrom
netrunnereve:bluetooth-name

Conversation

@netrunnereve

@netrunnereve netrunnereve commented Nov 3, 2026 •

Copy link
Copy Markdown

This fixes #1243 by letting the user set their own bluetooth name using the cli. If there's no custom name set it'll automatically use the node name instead.

Note that this doesn't let them change the "Meshcore-" prefix as that apparently breaks some apps. If someone really wants to change that they'll have to build the firmware manually with a different BLE_NAME_PREFIX.

This acts as a workaround for #1769 as well since you now can just set a shorter name manually. I tested this on my Heltec v4 companion and it's working fine with a custom name set.

@daneatthrive

Copy link
Copy Markdown

They should implement this and move the default Meshcore - into this method. I think that would solve everything.

@netrunnereve

Copy link
Copy Markdown
Author

They should implement this and move the default Meshcore - into this method. I think that would solve everything.

From the way the backend code is written it looks like the Bluetooth name is intended to have a separate prefix (which can be changed at compile time) followed by the node name. I mean I could add another command to change the prefix as well but let's see what the maintainers think about this first.

Comment thread examples/companion_radio/MyMesh.cpp Resolved
sprintf(reply, "> pin is now %06d", _prefs.ble_pin);
return true;
}
if (memcmp(command, "set ble_name ", 13) == 0) {

Copy link
Copy Markdown
Member

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_name to set ble.name. This will keep is consistent with all the other commands we have, that use dot notation, instead of underscores.

sprintf(reply, "> %s", _prefs.ble_name[0] ? _prefs.ble_name : _prefs.node_name);
return true;
}
if (strcmp(command, "set ble_name_default") == 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 set ble.name is empty. In that case, reset it to default, as it shouldn't be allowed to have an empty name, so we can use that state to revert to default.

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));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Underscore is fine here, just recommend updating the command strings themselves.

@liamcottle

Copy link
Copy Markdown
Member

Hey, thanks for the PR @netrunnereve, I've left some comments in the review above.

I mean I could add another command to change the prefix as well but let's see what the maintainers think about this first.

We could possibly check if a custom name was set. If so, don't add the prefix. If a custom name is not set, add the prefix by default. That way users that want to hide that it's a MeshCore device, don't see the MeshCore- prefix, unless they manually set it in the custom name.

This could probably be done by passing in an empty string as prefix in bluetooth_interface.begin(...) and fallback to passing in BLE_NAME_PREFIX if no custom name is configured.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants