Skip to content
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

[Feature] Hub name #52

Closed
GianCann opened this issue Jun 17, 2020 · 7 comments
Closed

[Feature] Hub name #52

GianCann opened this issue Jun 17, 2020 · 7 comments
Assignees
Labels
enhancement New feature or request platform: Powered Up Issues related to LEGO Powered Up software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) software: pybricksdev Issues related to the pybrickdev Python package topic: bluetooth Issues involving bluetooth

Comments

@GianCann
Copy link

Add a method/property to the hub class to set/get the name of the hub.
This name is useful to identify the hub when searched by BLE scan.

@GianCann GianCann added enhancement New feature or request triage Issues that have not been triaged yet labels Jun 17, 2020
@dlech dlech added platform: Powered Up Issues related to LEGO Powered Up topic: bluetooth Issues involving bluetooth and removed triage Issues that have not been triaged yet labels Jun 17, 2020
@Nelvarion
Copy link

@dlech @laurensvalk
Is this on the roadmap?
If not, do we have another method of identifying the hub? I'm trying to reuse a script with different behavior according to the hub it's running on.

@laurensvalk
Copy link
Member

Yes, see #173 for an option to choose the name when you install the firmware. Would that work?

In terms of self-identification, we can probably also make its own Bluetooth address readable.

@Nelvarion
Copy link

+1000 for naming the hubs!
So right now there's no way to identify the hub from within a script?

@laurensvalk
Copy link
Member

laurensvalk commented Jan 8, 2021

Are they both the same type? If they're different, you could try/except to import MoveHub or CityHub.

Two other different options:

  • Build from source and change "Pybricks Hub" in lib/pbio/drv/city_hub/bluetooth.c to something else
  • Take the last and second to last firmware version, and read the firmware version (pybricks.version) to tell them apart 😄

@Nelvarion
Copy link

Working with CityHubs, so can't use the type.
I'd use the second option but I need the experimental class and it was added in the last version 😉
I'll work around it for now until you add naming.

@laurensvalk
Copy link
Member

There have been a lot of builds since then.

@dlech dlech added software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) software: pybricks-code Issues with https://code.pybricks.com application software: pybricksdev Issues related to the pybrickdev Python package labels Jun 15, 2021
dlech added a commit to pybricks/pybricks-micropython that referenced this issue Jun 15, 2021
This modifies the advertising data and device name characteristics to
use the hub name from a special place in the firmware flash memory.
The offset and size of this location is stored in the firmware metadata
json file to allow modifying the hub name before flashing the firmware.
The name must be zero-terminated since we are using strlen(), so the
max size in the metadata includes the zero-termination byte.

Issue: pybricks/support#52
dlech added a commit to pybricks/pybricks-micropython that referenced this issue Jun 15, 2021
This modifies the advertising data and device name characteristics to
use the hub name from a special place in the firmware flash memory.
The offset and size of this location is stored in the firmware metadata
json file to allow modifying the hub name before flashing the firmware.
The name must be zero-terminated since we are using strlen(), so the
max size in the metadata includes the zero-termination byte.

Issue: pybricks/support#52
dlech added a commit to pybricks/pybricks-micropython that referenced this issue Jun 15, 2021
This modifies the advertising data and device name characteristics to
use the hub name from a special place in the firmware flash memory.
The offset and size of this location is stored in the firmware metadata
json file to allow modifying the hub name before flashing the firmware.
The name must be zero-terminated since we are using strlen(), so the
max size in the metadata includes the zero-termination byte.

Issue: pybricks/support#52
dlech added a commit to pybricks/pybricks-micropython that referenced this issue Jun 15, 2021
This modifies the advertising data and device name characteristics to
use the hub name from a special place in the firmware flash memory.
The offset and size of this location is stored in the firmware metadata
json file to allow modifying the hub name before flashing the firmware.
The name must be zero-terminated since we are using strlen(), so the
max size in the metadata includes the zero-termination byte.

Issue: pybricks/support#52
@dlech
Copy link
Member

dlech commented Jun 26, 2021

Setting hub name is now possible with https://github.com/pybricks/pybricksdev/releases/tag/v1.0.0-alpha.10 and firmware >= v3.1.0a1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform: Powered Up Issues related to LEGO Powered Up software: pybricks-code Issues with https://code.pybricks.com application software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) software: pybricksdev Issues related to the pybrickdev Python package topic: bluetooth Issues involving bluetooth
Projects
None yet
Development

No branches or pull requests

4 participants