bledev.deviceinfo

Device Information Service (0x180A): tell a phone or laptop what this device is.

Pass only the fields you have; each one becomes a read-only characteristic:

from bledev.deviceinfo import DeviceInformation

info = DeviceInformation(manufacturer="PyDevices", model="rack-1", firmware="0.3.0")
ble.register_services(info.service)

ble.register_services() replaces whatever was registered before, so pass this service together with the others. Text fields are UTF-8. Keep each short: MicroPython answers a read with at most mtu - 1 bytes (22 until the central asks for more), and a longer value is cut off.

Any peripheral backend serves it: MicroPython (bledev.mpble), CircuitPython (bledev.cpble) and the fake one for tests.

bledev.deviceinfo.SOURCE_BLUETOOTH_SIG = 1

the company number is a Bluetooth SIG one.

Type:

Vendor ID source for pnp_id

bledev.deviceinfo.SOURCE_USB = 2

the vendor is a USB Implementers Forum one.

Type:

Vendor ID source for pnp_id

class bledev.deviceinfo.DeviceInformation(manufacturer=None, model=None, serial=None, hardware=None, firmware=None, software=None, system_id=None, pnp_id=None)[source]

Bases: object

A Device Information Service with the fields you give it.

Parameters:
  • manufacturer – Manufacturer name, a string.

  • model – Model number, a string.

  • serial – Serial number, a string.

  • hardware – Hardware revision, a string.

  • firmware – Firmware revision, a string.

  • software – Software revision, a string.

  • system_id – Eight bytes: a 40-bit manufacturer-defined ID, then a 24-bit organisationally unique identifier.

  • pnp_id – (vendor_id_source, vendor_id, product_id, product_version); the source is SOURCE_BLUETOOTH_SIG or SOURCE_USB.