Behaviour for BLE hardware adapters.
Separates the BTP + GenServer logic from hardware-specific BLE details. Implement this to plug in blue_heron, a raw HCI driver, or a test mock.
The adapter sends events to the owner process (the BLE GenServer):
{:ble_connected, connection_ref}
{:ble_data, connection_ref, binary}
{:ble_disconnected, connection_ref}
Summary
Callbacks
Send data to the connected peer via the TX characteristic indication.
Start the adapter. Returns an opaque handle for subsequent calls.
Begin BLE advertising with the CHIPoBLE service.
Disconnect and clean up.
Stop advertising.
Callbacks
@callback send_data(handle :: term(), connection_ref :: term(), data :: binary()) :: :ok | {:error, term()}
Send data to the connected peer via the TX characteristic indication.
connection_ref is the opaque reference from the {:ble_connected, ref} event.
Start the adapter. Returns an opaque handle for subsequent calls.
opts contains at minimum:
:owner— pid to receive BLE events:discriminator— 12-bit commissioning discriminator:vendor_id— 16-bit vendor ID:product_id— 16-bit product ID
Begin BLE advertising with the CHIPoBLE service.
@callback stop(handle :: term()) :: :ok
Disconnect and clean up.
@callback stop_advertising(handle :: term()) :: :ok
Stop advertising.