MatterEx.Transport.BLE (matter_ex v0.4.0)

Copy Markdown View Source

CHIPoBLE transport GenServer.

Manages the BLE connection lifecycle for Matter commissioning. Delegates fragmentation/reassembly to MatterEx.Transport.BTP. Communicates with upper layers via messages:

{:ble_connected, transport_pid}
{:ble_data, transport_pid, complete_message}
{:ble_disconnected, transport_pid}

Hardware access is delegated to a configured adapter module implementing MatterEx.Transport.BLE.Adapter.

Example

{:ok, ble} = MatterEx.Transport.BLE.start_link(
  discriminator: 3840,
  vendor: :test,
  product: :smart_light,
  adapter: SomeAdapter
)

# Adapter sends events, GenServer relays to owner
# Send data back (BTP-fragmented automatically):
MatterEx.Transport.BLE.send(ble, response_data)

Summary

Functions

Returns a specification to start this module under a supervisor.

Send data over the BLE connection. Data is BTP-fragmented automatically.

Start the BLE transport.

Stop BLE advertising.

Functions

additional_data_uuid()

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

gatt_service_uuid()

rx_characteristic_uuid()

send(server, data)

@spec send(GenServer.server(), binary()) :: :ok | {:error, atom()}

Send data over the BLE connection. Data is BTP-fragmented automatically.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Start the BLE transport.

Required options:

  • :discriminator — 12-bit commissioning discriminator (0..4095)
  • :vendor — known vendor alias, or :vendor_id with a 16-bit ID
  • :product — known product alias, or :product_id with a 16-bit ID
  • :adapter — module implementing MatterEx.Transport.BLE.Adapter

Optional:

  • :owner — pid to receive events (default: calling process)
  • :name — GenServer name

stop_advertising(server)

@spec stop_advertising(GenServer.server()) :: :ok

Stop BLE advertising.

tx_characteristic_uuid()