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

Change Bluetooth Advertisement Name of SHA/STH #1

Closed
sanssecours opened this issue Aug 20, 2020 · 0 comments
Closed

Change Bluetooth Advertisement Name of SHA/STH #1

sanssecours opened this issue Aug 20, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@sanssecours
Copy link
Member

Currently we use the last 3 bytes of the MAC address as identifier (e.g. 01:de:81). This part of the address should be unique for a certain OUI (Organizationally Unique Identifier). However, according to the official OUI list, Silicon Laboratories reserved at least 12 OUIs. This means we have to use another identifier to uniquely identify a certain sensory tool holder (STH) or sensory holder assembly (SHA). Since we can only use 8 characters for the name, we decided to store the 6 bytes of the MAC address in Base64 format. The code below shows an example, on how to do that.

from base64 import b64encode

mac = [0x08, 0x6b, 0xd7, 0x01, 0xde, 0x81]
mac_text = ":".join([f"{byte:02x}" for byte in mac])
print(f"MAC: {mac_text}")
name = b64encode(bytes([0x08, 0x6b, 0xd7, 0x01, 0xde, 0x81])).decode()
print(f"Name (Base64): {name}")

This code converts the MAC address 08:6b:d7:01:de:81 into the name CGvXAd6B. We can always convert this name, back into a more readable MAC address, using the code below.

from base64 import b64decode

mac = list(b64decode('CGvXAd6B'))
print(":".join([f"{byte:02x}" for byte in mac]))
@sanssecours sanssecours added the enhancement New feature or request label Aug 20, 2020
@sanssecours sanssecours added this to the 1.0.4 milestone Aug 20, 2020
@sanssecours sanssecours self-assigned this Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant