diff --git a/lib/blue_heron/att.ex b/lib/blue_heron/att.ex index 1c4945a..5e976c3 100644 --- a/lib/blue_heron/att.ex +++ b/lib/blue_heron/att.ex @@ -16,6 +16,8 @@ defmodule BlueHeron.ATT do FindByTypeValueResponse, FindInformationRequest, FindInformationResponse, + HandleValueIndication, + HandleValueConfirmation, PrepareWriteRequest, PrepareWriteResponse, ReadBlobRequest, @@ -99,6 +101,12 @@ defmodule BlueHeron.ATT do def deserialize(base, <<0x1B, _::binary>> = read_by_group_type_request), do: %{base | data: HandleValueNotification.deserialize(read_by_group_type_request)} + def deserialize(base, <<0x1D, _::binary>> = handle_value_indication), + do: %{base | data: HandleValueIndication.deserialize(handle_value_indication)} + + def deserialize(base, <<0x1E, _::binary>> = handle_value_confirmation), + do: %{base | data: HandleValueConfirmation.deserialize(handle_value_confirmation)} + def deserialize(base, <<0x52, _::binary>> = read_by_group_type_request), do: %{base | data: WriteCommand.deserialize(read_by_group_type_request)} diff --git a/lib/blue_heron/att/confirmations/handle_value_confirmation.ex b/lib/blue_heron/att/confirmations/handle_value_confirmation.ex new file mode 100644 index 0000000..dfd2fb4 --- /dev/null +++ b/lib/blue_heron/att/confirmations/handle_value_confirmation.ex @@ -0,0 +1,11 @@ +defmodule BlueHeron.ATT.HandleValueConfirmation do + defstruct [:opcode] + + def serialize(%{}) do + <<0x1E>> + end + + def deserialize(<<0x1E>>) do + %__MODULE__{opcode: 0x1E} + end +end diff --git a/lib/blue_heron/att/indications/handle_value_indication.ex b/lib/blue_heron/att/indications/handle_value_indication.ex new file mode 100644 index 0000000..d19480e --- /dev/null +++ b/lib/blue_heron/att/indications/handle_value_indication.ex @@ -0,0 +1,15 @@ +defmodule BlueHeron.ATT.HandleValueIndication do + defstruct [:opcode, :handle, :value] + + def serialize(%{handle: handle, value: value}) do + <<0x1D, handle::little-16, value::binary>> + end + + def deserialize(<<0x1D, handle::little-16, value::binary>>) do + %__MODULE__{ + opcode: 0x1D, + handle: handle, + value: value + } + end +end