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

Add PNP ID designation to DeviceInfoService #202

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

ktnyt
Copy link
Contributor

@ktnyt ktnyt commented Oct 15, 2024

This PR introduces the PnP ID characteristic from the Device Information Service specification to DeviceInfoService.
Currently, there is no way to specify the Vendor ID and Product ID of the Bluetooth device using CircuitPython which can cause inconveniences when trying to make certain operating systems recognize the Bluetooth peripheral device as a specific product (e.g. an Xbox One S Wireless Controller in macOS).
The changes introduced by this PR will allow a developer to set a 8-bit value and three 16-bit values as illustrated below:

device_info = DeviceInfoService(
    software_revision=adafruit_ble.__version__,
    pnp_id=(0x02, 0x045E, 0x02E0, 0x0100),
)

The four values being the Vendor ID source field (8-bits), Vendor ID field (16-bits), Product ID field (16-bits), and Product Version field (16-bits) respectively.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you! I'd love to see a write up on adafruit-playground.com about mimicking an xbox controller.

@tannewt tannewt merged commit 1a16cf4 into adafruit:main Oct 15, 2024
1 check passed
@dhalbert
Copy link
Collaborator

@ktnyt While working on #204 I also discovered that if pnp_id is not supplied, an exception is raised because the value is None, and that doesn't unpack into the StructCharacteristic. What should be the default value pnp_id when it's not needed. Should all the fields be zeros, or something else?

@ktnyt
Copy link
Contributor Author

ktnyt commented Oct 19, 2024

@dhalbert I'm sorry I couldn't catch that. I believe that zeros should be fine since the specification doesn't elaborate on what values are valid.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 22, 2024
Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 10.0.9 from 10.0.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#203 from dhalbert/nus-buffers-at-least-mtu
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#206 from dhalbert/pnp_id-defaults
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#204 from adafruit/dhalbert-patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#202 from ktnyt/device-info-pnp-id

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_USB_Host_Mass_Storage, Adafruit_CircuitPython_USB_Host_MIDI

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
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.

3 participants