AutoApi.GetAvailabilityCommand (auto_api v13.2.0) View Source
Abstraction for a get_availability
command in AutoApi (id 0x02
).
The struct
contains two fields:
capability
specifies the capability of the command as a Capability moduleproperties
specifies which properties for which the availability is requested. An empty list indicates all properties.
Link to this section Summary
Functions
Parses a command binary and returns a GetAvailabilityCommand struct
Returns the identifier of the command.
Returns the name of the command.
Creates a new GetAvailabilityCommand structure with the given capability
and properties
.
Returns the properties set in the command.
Transforms a GetAvailabilityCommand struct into a binary format.
Link to this section Types
Specs
properties() :: [AutoApi.Capability.property()]
Specs
t() :: %AutoApi.GetAvailabilityCommand{ capability: AutoApi.Capability.t(), properties: properties(), version: AutoApi.version() }
Link to this section Functions
Specs
Parses a command binary and returns a GetAvailabilityCommand struct
Examples
iex> Elixir.AutoApi.GetAvailabilityCommand.from_bin(<<0x0D, 0x00, 0x33, 0x02, 0x01, 0x04>>)
%Elixir.AutoApi.GetAvailabilityCommand{capability: AutoApi.DiagnosticsCapability, properties: [:mileage, :engine_rpm], version: 13}
Specs
identifier() :: byte()
Returns the identifier of the command.
Example
iex> Elixir.AutoApi.GetAvailabilityCommand.identifier() 0x02
Specs
name() :: AutoApi.Command.name()
Returns the name of the command.
Example
iex> Elixir.AutoApi.GetAvailabilityCommand.name() :get_availability
Specs
new(AutoApi.Capability.t(), properties()) :: t()
Creates a new GetAvailabilityCommand structure with the given capability
and properties
.
Example
iex> capability = AutoApi.SeatsCapability
iex> properties = [:persons_detected]
iex> Elixir.AutoApi.GetAvailabilityCommand.new(capability, properties)
%Elixir.AutoApi.GetAvailabilityCommand{capability: AutoApi.SeatsCapability, properties: [:persons_detected], version: 13}
Specs
properties(t()) :: [AutoApi.Capability.property()]
Returns the properties set in the command.
If the command specifies all properties (that is, it is an empty list) it will return a list of the state properties as by the specifications of the capability.
Examples
iex> command = Elixir.AutoApi.GetAvailabilityCommand.new(AutoApi.RaceCapability, [:vehicle_moving, :gear_mode])
iex> Elixir.AutoApi.GetAvailabilityCommand.properties(command)
[:vehicle_moving, :gear_mode]
iex> command = Elixir.AutoApi.GetAvailabilityCommand.new(AutoApi.HoodCapability, [])
iex> Elixir.AutoApi.GetAvailabilityCommand.properties(command)
[:position, :lock, :lock_safety, :nonce, :vehicle_signature, :timestamp, :vin, :brand]
Specs
Transforms a GetAvailabilityCommand struct into a binary format.
If the command is somehow invalid, it returns an error.
Examples
iex> # Request the door locks state availability iex> command = %Elixir.AutoApi.GetAvailabilityCommand{capability: AutoApi.DoorsCapability, properties: [:locks_state]} iex> Elixir.AutoApi.GetAvailabilityCommand.to_bin(command) <<13, 0, 32, 2, 6>>
iex> # Request all properties availability for race state iex> command = %Elixir.AutoApi.GetAvailabilityCommand{capability: AutoApi.RaceCapability, properties: []} iex> Elixir.AutoApi.GetAvailabilityCommand.to_bin(command) <<13, 0, 87, 2>>