auto_api v0.1.0 AutoApi.Command behaviour View Source
Link to this section Summary
Functions
Extracts commands meta data including the capability that the command is using and exact command that is issued
Link to this section Types
Link to this type
capability_name()
View Source
capability_name() :: :door_locks | :charging | :diagnostics | :engine | :maintenance | :rooftop | :trunk_access | :vehicle_location
Link to this type
execute_return_atom()
View Source
execute_return_atom() :: :state | :state_changed
Link to this section Functions
Link to this function
execute(struct, command, binary_command)
View Source
execute(map(), atom(), binary()) :: map()
Extracts commands meta data including the capability that the command is using and exact command that is issued
iex> AutoApi.Command.meta_data(<<0, 0x33, 0x00>>)
%{message_id: :diagnostics, message_type: :get_diagnostics_state, module: AutoApi.DiagnosticsCapability}
ie> binary_command = <<0x00, 0x20, 0x1, 0x01, 0x00, 0x00, 0x00>>
ie> %{module: cap} = AutoApi.Command.meta_data(binary_command)
ie> base_state = cap.state.base
%AutoApi.DoorLocksState{}
ie> AutoApi.Command.execute(base_state, cap.command, binary_command)
{:state_changed, %AutoApi.DoorLocksState{}}
ie> AutoApi.Command.to_bin(:door_locks, :get_lock_state, [])
<<0x0, 0x20, 0x0>>
ie> AutoApi.Command.to_bin(:door_locks, :lock_unlock_doors, [:lock])
<<0x0, 0x20, 0x02, 0x01>>
Link to this function
to_bin(capability_name, action, args)
View Source
to_bin(capability_name(), atom(), [any()]) :: binary()
Link to this section Callbacks
Link to this callback
execute(struct, binary)
View Source
execute(struct(), binary()) :: {execute_return_atom(), struct()}