BlueHeron.GATT.Service (blue_heron v0.4.1) View Source

Struct that represents a GATT service.

Link to this section Summary

Functions

Create a service with fields taken from the map args.

Link to this section Types

Link to this section Functions

Specs

new(args :: map()) :: t()

Create a service with fields taken from the map args.

The following fields are required:

  • id: A user-defined term to identify the service. Must be unique within the device profile. Can be any Erlang term.
  • type: The service type UUID. Can be a 2- or 16-byte byte UUID. Integer.
  • characteristics: A list of characteristics.

Example:

iex> BlueHeron.GATT.Service.new(%{
...>   id: :gap,
...>   type: 0x1800,
...>   characteristics: [
...>     BlueHeron.GATT.Characteristic.new(%{
...>       id: {:gap, :device_name},
...>       type: 0x2A00,
...>       properties: 0b00000010
...>     })
...>   ]
...> })
%BlueHeron.GATT.Service{id: :gap, type: 0x1800, characteristics: [%BlueHeron.GATT.Characteristic{id: {:gap, :device_name}, type: 0x2A00, properties: 2}]}