AutoApi.SetCommand.to_bin
You're seeing just the function
to_bin
, go back to AutoApi.SetCommand module for more information.
Specs
Transforms a SetCommand struct into binary format.
If the command is somehow invalid, it returns an error.
Examples
iex> # Request to unlock the doors of the vehicle
iex> locks_state = %AutoApi.Property{data: :unlocked}
iex> state = AutoApi.State.put(%AutoApi.DoorsState{}, :locks_state, locks_state)
iex> command = %Elixir.AutoApi.SetCommand{capability: AutoApi.DoorsCapability, state: state}
iex> Elixir.AutoApi.SetCommand.to_bin(command)
<<13, 0, 32, 1, 6, 0, 4, 1, 0, 1, 0>>
iex> # Request to honk the horn for 2.5 seconds
iex> capability = AutoApi.HonkHornFlashLightsCapability
iex> honk_time = %{value: 2.5, unit: :seconds}
iex> state = AutoApi.State.put(capability.state().base(), :honk_time, data: honk_time)
iex> command = %Elixir.AutoApi.SetCommand{capability: capability, state: state}
iex> Elixir.AutoApi.SetCommand.to_bin(command)
<<13, 0, 38, 1, 5, 0, 13, 1, 0, 10, 7, 0, 64, 4, 0, 0, 0, 0, 0, 0>>