Skip to content

Conversation

@virtualabs
Copy link
Collaborator

WHAD's BLE device model has been refactored to avoid having different classes to model a GATT characteristic or service and access attributes once a connection has been established with a remote GATT server. Many unexpected bugs have been identified and fixed during this refactoring, and more unit and integration tests have been added to detect as much regressions as possible.

This refactoring introduces:

  • a unified implementation of classes used to represent GATT characteristics, services and descriptors (backward compatible with the previous implementation, no change required)
  • new methods to enumerate and access services, characteristics and descriptors with better names that tell what these methods actually do
  • a new model for standard services that acts as a high-level abstraction between a user application and a GATT server (see StandardService and PeripheralDevice.query() to get an idea)

Documentation has been updated accordingly, as well as unit and integration tests.

…ic `CharacteristicDescriptor` implementation.
…TT services, characteristics and descriptors.

Instead of duplicating a lot of code as done previously, we opted out another architecture. Our previous implementation
provided new classes to access a device's GATT server's services, characteristics and descriptors that differed from
the ones defined in `whad.ble.profile.characteristic` and `whad.ble.profile.service`, causing some inconsistencies and
more bugs due to duplicated code. Instead, we decided to implement each specific type of attribute (service,
characteristic, characteristic value, descriptor) as a class that derives indirectly from our base `Attribute` class,
allowing them to be managed by our `GenericProfile` class as generic attributes. These classes, however, also inherit
from a new `RemoteAttribute` class that acts as an interface between the *model* (our base classes for the different
types of attributes) and an existing *GATT* connection, allowing to read and write from/into the remote GATT server's
attributes by simply calling standardized method exposed by the `RemoteAttribute` class. These methods drive the underlying
BLE stack to initiate a corresponding GATT procedure.

Doing so keeps our classes consistent: user can query these classes as if they were standard classes representing a service,
a characteristic or a descriptor, and by the way use them directly as a transparent way to interact with the remote
server.
…ovide an easier way to access services and characteristics.

- New method `service()` in `PeripheralDevice` retrieves a `PeripheralService` object from its UUID
- New method `char()` in `PeripheralService` retrieves a `PeripheralCharacteristic` object from its UUID
- `PeripheralService` and `PeripheralDevice` now supports the `in` operator to check for supported service or characteristic
- Integration tests for BLE central have been updated to test these new accessors
- Documentation has been updated to reflect these changes.
…or `UUID` objects. Added more integration tests. Updated doc.
…TT profile, services and characteristics classes.
…se a Read request instead of a ReadBlob request)
… new method to discover characteristic by uuid and fixed service discovery by uuid.
…haracteristic read from UUID and service discovery from UUID.
@virtualabs virtualabs added this to the version 1.3.0 milestone Dec 19, 2025
@virtualabs virtualabs added enhancement New feature or request BLE Bluetooth Low Energy labels Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BLE Bluetooth Low Energy enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants