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, 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.

send_report(report: Dict) None

Send a report to the peers

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.

property report: Dict

The HID OUT report

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.hid_server import HIDServer

hid = HIDServer()
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).