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

Struct that represents a GATT service.

Summary

Functions

Create a service with fields taken from the map args.

Types

id()

@type id() :: term()

read_fn()

@type read_fn() :: (BlueHeron.GATT.Characteristic.id() -> binary())

subscribe_fn()

@type subscribe_fn() :: (BlueHeron.GATT.Characteristic.id() -> any())

t()

@opaque t()

write_fn()

@type write_fn() :: (BlueHeron.GATT.Characteristic.id(), binary() -> any())

Functions

new(args)

@spec 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.
  • read: a 1 arity function called when the value of a characteristic should be read.
  • write: a 2 arity function called when the value of a characteristic should be written.
  • subscribe: a 1 arity function called when the value of a characteristic's value should be indicated.
  • unsubscribe: a 1 arity function called when the value of a characteristic's value should stop indicating.