Drone. Adapters. Crazyflie. Platform
(ex_drone v0.3.0)
View Source
Platform / link-control packets for protocol identity.
Connection sequence (documented CRTP connection procedure):
- Probe link with a LINKCTRL source packet.
- Request protocol version on PLATFORM channel 1.
- Parse the reply and call
check_compatibility/1.
Examples
probe = Drone.Adapters.Crazyflie.Platform.link_probe()
req = Drone.Adapters.Crazyflie.Platform.get_protocol_version()
{:ok, 8} = Drone.Adapters.Crazyflie.Platform.parse_protocol_version(<<0, 8>>)
:ok = Drone.Adapters.Crazyflie.Platform.check_compatibility(8)
Summary
Functions
Returns :ok when version is in the supported range.
PLATFORM request for the CRTP protocol version.
LINKCTRL probe packet used during connection.
Maximum accepted CRTP protocol version for this adapter.
Minimum accepted CRTP protocol version for this adapter.
Parses a protocol-version response payload.
Functions
Returns :ok when version is in the supported range.
Parameters
version(integer()) — protocol version fromparse_protocol_version/1
Returns
:ok— version betweenmin_supported/0andmax_supported/0inclusive{:error, {:unsupported_protocol, version}}— out of range or non-integer
Examples
:ok = Drone.Adapters.Crazyflie.Platform.check_compatibility(8)
{:error, {:unsupported_protocol, 99}} =
Drone.Adapters.Crazyflie.Platform.check_compatibility(99)
@spec get_protocol_version() :: Drone.Adapters.Crazyflie.CRTP.packet()
PLATFORM request for the CRTP protocol version.
Returns
Drone.Adapters.Crazyflie.CRTP.packet() on port :platform, channel 1,
payload <<0>> (VERSION_GET_PROTOCOL).
Examples
%{port: 13, channel: 1, payload: <<0>>} =
Drone.Adapters.Crazyflie.Platform.get_protocol_version()
@spec link_probe() :: Drone.Adapters.Crazyflie.CRTP.packet()
LINKCTRL probe packet used during connection.
Returns
Drone.Adapters.Crazyflie.CRTP.packet() on port :linkctrl, channel 1,
payload <<0>>.
Examples
%{port: 15, channel: 1, payload: <<0>>} =
Drone.Adapters.Crazyflie.Platform.link_probe()
@spec max_supported() :: pos_integer()
Maximum accepted CRTP protocol version for this adapter.
Returns
pos_integer() (currently 12).
Examples
12 = Drone.Adapters.Crazyflie.Platform.max_supported()
@spec min_supported() :: pos_integer()
Minimum accepted CRTP protocol version for this adapter.
Returns
pos_integer() (currently 4).
Examples
4 = Drone.Adapters.Crazyflie.Platform.min_supported()
@spec parse_protocol_version(binary()) :: {:ok, non_neg_integer()} | {:error, :invalid_version_response}
Parses a protocol-version response payload.
Expected shape: <<0, version>> where the first byte echoes
VERSION_GET_PROTOCOL.
Parameters
payload(binary()) — ACK payload from the version request
Returns
{:ok, non_neg_integer()}— protocol version byte{:error, :invalid_version_response}— unexpected shape
Examples
{:ok, 8} = Drone.Adapters.Crazyflie.Platform.parse_protocol_version(<<0, 8>>)
{:error, :invalid_version_response} =
Drone.Adapters.Crazyflie.Platform.parse_protocol_version(<<1, 8>>)