BlePeripheralHal

Low-level BLE Peripheral Hardware Abstraction Layer (HAL) used to back BLE mdoc transports.

All ISO/IEC 18013-5 protocol state machines, continuation management, BLEIdent HKDF calculation, L2CAP PSM 4-byte big-endian encoding, GATT message chunking/reassembly, and L2CAP 4-byte length-prefixed framing are handled by Multipaz's shared BLE peripheral manager. Implementations of this interface perform low-level Bluetooth peripheral operations and forward asynchronous events to Callback.

Types

Link copied to clipboard
interface Callback

Asynchronous callbacks invoked by a BlePeripheralHal implementation.

Functions

Link copied to clipboard
abstract fun close()

Immediately closes the HAL and releases any underlying resources.

Link copied to clipboard
abstract fun closeL2capServer()

Closes any published L2CAP server listener so no new L2CAP client connections are accepted (already-accepted client channels remain open).

Link copied to clipboard
abstract fun notifyCharacteristicChanged(uuid: UUID, value: ByteArray)

Sends a GATT notification with value for characteristic uuid.

Link copied to clipboard
abstract fun publishL2capChannel()

Publishes an insecure L2CAP server channel, reporting its PSM via Callback.onL2capPublished.

Link copied to clipboard
abstract fun sendReadResponse(requestId: Int, statusSuccess: Boolean, value: ByteArray)

Sends a GATT read response for requestId.

Link copied to clipboard
abstract fun setCallback(callback: BlePeripheralHal.Callback)

Registers the Callback receiver for asynchronous BLE peripheral events.

Link copied to clipboard
abstract fun setupGattServerAndAddService(serviceUuid: UUID, stateCharacteristicUuid: UUID, client2ServerCharacteristicUuid: UUID, server2ClientCharacteristicUuid: UUID, identCharacteristicUuid: UUID?, l2capCharacteristicUuid: UUID?, encodedL2capPsm: ByteArray?)

Sets up the GATT server and registers the ISO/IEC 18013-5 service and characteristics.

Link copied to clipboard
open suspend fun shutdown()

Gracefully shuts down active BLE peripheral connections/controllers before close.

Link copied to clipboard
abstract fun startAdvertising(serviceUuid: UUID)

Starts BLE advertising for serviceUuid.

Link copied to clipboard
abstract fun stopAdvertising()

Stops BLE advertising.

Link copied to clipboard
abstract fun waitForPowerOn()

Checks or waits for the BLE peripheral radio/stack to power on, reporting via Callback.onPowerOn.