BlueHeron.ATT.Client (blue_heron v0.2.1) View Source

Linked connection to a BLE device

Events

Recieved when a connection is established with the device. This value should be treated as opaque. It should be used as a "handle" to the BLE device. See write/3 for more info.

{BlueHeron.ATT.Client, pid, %BlueHeron.HCI.Event.LEMeta.ConnectionComplete{}}

Recieved when a connection is established with the device. Should invalidate a previous connection established.

{BlueHeron.ATT.Client, pid, %BlueHeron.HCI.Event.DisconnectComplete{}}

Link to this section Summary

Functions

Attempt to create a connection with a device Args should be a keyword list of fields that get passed to BlueHeron.HCI.Command.LEController.CreateConnection

See the Events portion of the moduledoc to see events that will be delivered to the calling processes mailbox

Write a value to a handle on a BLE device

Link to this section Types

Specs

client() :: GenServer.server()

Specs

handle() ::
  %BlueHeron.ATT.ReadByGroupTypeResponse.AttributeData{
    end_group_handle: term(),
    handle: term(),
    uuid: term()
  }
  | %BlueHeron.ATT.ReadByTypeResponse.AttributeData{
      characteristic_properties: term(),
      characteristic_value_handle: term(),
      handle: term(),
      uuid: term()
    }
  | 0..4095

Link to this section Functions

Link to this function

create_connection(pid, args)

View Source

Specs

create_connection(client(), Keyword.t()) :: :ok | {:error, any()}

Attempt to create a connection with a device Args should be a keyword list of fields that get passed to BlueHeron.HCI.Command.LEController.CreateConnection

iex> ATT.Client.create_connection(pid, peer_address: 0xabcdefg) :ok

Link to this function

start_link(context, opts \\ [])

View Source

Specs

See the Events portion of the moduledoc to see events that will be delivered to the calling processes mailbox

Link to this function

write(pid, handle, value)

View Source

Specs

write(client(), handle(), binary()) :: :ok | {:error, term()}

Write a value to a handle on a BLE device

iex> ATT.Client.write(pid, %ATT.ReadByTypeResponse.AttributeData{handle: 0x15}, <<1, 2, 3, 4>>) :ok

iex> ATT.Client.write(pid, %ATT.ReadByGroupTypeRequest.AttributeData{handle: <<uuid::binary-128>>}, <<1, 2, 3, 4>>) :ok

iex> ATT.Client.write(pid, 0x15, <<1, 2, 3, 4>>) :ok