standard
This module provides Service classes for BLE defined standard services.
- class AppearanceCharacteristic(**kwargs)
What type of device it is
- class GenericAccess(*, service: Service | None = None, secondary: bool = False, **initial_values)
Required service that provides basic device information
- class GenericAttribute(*, service: Service | None = None, secondary: bool = False, **initial_values)
Required service that provides notifications when Services change
- class BatteryService(*, service: Service | None = None, secondary: bool = False, **initial_values)
Provides battery level information
- class CurrentTimeService(*, service: Service | None = None, secondary: bool = False, **initial_values)
Provides the current time.
- current_time
A tuple describing the current time: (year, month, day, hour, minute, second, weekday, subsecond, adjust_reason)
- local_time_info
(timezone, dst_offset)
- Type:
A tuple of location information
- property struct_time: struct_time
The current time as a
time.struct_time. Day of year and whether DST is in effect are always -1.
device_info
- class DeviceInfoService(*, manufacturer: str | None = None, software_revision: str | None = None, model_number: str | None = None, serial_number: str | None = None, firmware_revision: str | None = None, hardware_revision: str | None = None, pnp_id: Iterable | None = None, service: _bleio.Service | None = None)
Device information
hid
BLE Human Interface Device (HID)
Author(s): Dan Halbert for Adafruit Industries
- DEFAULT_HID_DESCRIPTOR = b'\x05\x01\t\x06\xa1\x01\x85\x01\x05\x07\x19\xe0)\xe7\x15\x00%\x01u\x01\x95\x08\x81\x02\x81\x01\x19\x00)\x89\x15\x00%\x89u\x08\x95\x06\x81\x00\x05\x08\x19\x01)\x05\x15\x00%\x01u\x01\x95\x05\x91\x02\x95\x03\x91\x01\xc0\x05\x01\t\x02\xa1\x01\t\x01\xa1\x00\x85\x02\x05\t\x19\x01)\x05\x15\x00%\x01\x95\x05u\x01\x81\x02\x95\x01u\x03\x81\x01\x05\x01\t0\t1\x15\x81%\x7fu\x08\x95\x02\x81\x06\t8\x15\x81%\x7fu\x08\x95\x01\x81\x06\xc0\xc0\x05\x0c\t\x01\xa1\x01\x85\x03u\x10\x95\x01\x15\x01&\x8c\x02\x19\x01*\x8c\x02\x81\x00\xc0'
provides mouse, keyboard, and consumer control devices.
- Type:
Default HID descriptor
- class ReportIn(service: Service, report_id: int, usage_page: bytes, usage: bytes, *, max_length: int)
A single HID report that transmits HID data into a client.
- class ReportOut(service: Service, report_id: int, usage_page: bytes, usage: bytes, *, max_length: int)
A single HID report that receives HID data from a client.
- class Device(usage_page, usage)
Container that groups multiple ReportIn and ReportOut objects for a given usage_page/usage.
Each device may have multiple report IDs. This class keeps mappings from report_id -> ReportIn/ReportOut and provides convenience methods that use the first-added report_id when none is specified.
- add_report_in(report_id: int, report_in: ReportIn) None
Register a ReportIn instance for a report_id.
- class HIDService(hid_descriptor: bytes = b'\x05\x01\t\x06\xa1\x01\x85\x01\x05\x07\x19\xe0)\xe7\x15\x00%\x01u\x01\x95\x08\x81\x02\x81\x01\x19\x00)\x89\x15\x00%\x89u\x08\x95\x06\x81\x00\x05\x08\x19\x01)\x05\x15\x00%\x01u\x01\x95\x05\x91\x02\x95\x03\x91\x01\xc0\x05\x01\t\x02\xa1\x01\t\x01\xa1\x00\x85\x02\x05\t\x19\x01)\x05\x15\x00%\x01\x95\x05u\x01\x81\x02\x95\x01u\x03\x81\x01\x05\x01\t0\t1\x15\x81%\x7fu\x08\x95\x02\x81\x06\t8\x15\x81%\x7fu\x08\x95\x01\x81\x06\xc0\xc0\x05\x0c\t\x01\xa1\x01\x85\x03u\x10\x95\x01\x15\x01&\x8c\x02\x19\x01*\x8c\x02\x81\x00\xc0', service: Service | None = None)
Provide devices for HID over BLE.
- Parameters:
hid_descriptor (str) – USB HID descriptor that describes the structure of the reports. Known as the report map in BLE HID.
Example:
from adafruit_ble.services.standard.hid import HIDService hid = HIDService()
- protocol_mode
boot (0) or report (1)
- Type:
Protocol mode
- hid_information
Hid information including version, country code and flags.
- report_map
This is the USB HID descriptor (not to be confused with a BLE Descriptor). It describes which report characteristic are what.
- suspended
Controls whether the device should be suspended (0) or not (1).