Drone. Adapters. Crazyflie. Session
(ex_drone v0.3.0)
View Source
CRTP session helpers over a transport.
Owns connection handshake (link probe + protocol version), optional CRTP logging subscription for battery / estimator readiness, and convenience send wrappers used by the Crazyflie adapter.
Lifecycle
{:ok, mod} = Drone.Adapters.Crazyflie.Transport.resolve(uri: "mock://ready")
{:ok, session} = Drone.Adapters.Crazyflie.Session.connect(mod, uri: "mock://ready")
{:ok, _ack, session} =
Drone.Adapters.Crazyflie.Session.send_packet(
session,
Drone.Adapters.Crazyflie.CRTP.null_packet()
)
:ok = Drone.Adapters.Crazyflie.Session.close(session)Handshake failures close the transport and return {:error, reason}
(for example {:unsupported_protocol, version} or :link_lost).
Logging setup failures close the transport with
{:error, {:logging_setup_failed, reason}}.
poll/1 is a thin null-packet helper kept for tests; production code should
use send_packet/2 with an explicit CRTP packet.
Summary
Functions
Closes the underlying transport.
Opens a transport, verifies protocol compatibility, and subscribes to logging.
Sends a CRTP packet through the session transport.
Types
@type t() :: %{ transport_module: module(), transport_state: term(), protocol_version: non_neg_integer() | nil, log_layout: [Drone.Adapters.Crazyflie.Logging.layout_entry()] | nil }
Open CRTP session bound to a transport module and its opaque state.
| Field | Type | Meaning |
|---|---|---|
:transport_module | module() | Module implementing Drone.Adapters.Crazyflie.Transport |
:transport_state | term() | Opaque state returned by open / send |
:protocol_version | non_neg_integer() | nil | Negotiated CRTP protocol version after handshake |
:log_layout | [map()] | nil | Active logging decode layout when subscribed |
Example
%{
transport_module: Drone.Adapters.Crazyflie.Transport.Mock,
transport_state: %Drone.Adapters.Crazyflie.Transport.Mock{profile: :ready},
protocol_version: 8,
log_layout: nil
}
Functions
@spec close(t()) :: :ok
Closes the underlying transport.
Opens a transport, verifies protocol compatibility, and subscribes to logging.
Sequence:
transport_module.open(opts)(SafeLink enable happens here when requested)- Send
Platform.link_probe/0 - Send
Platform.get_protocol_version/0and parse the reply Platform.check_compatibility/1- Reset logging, download TOC, create/start a battery + canfly block
@spec send_packet(t(), Drone.Adapters.Crazyflie.CRTP.packet()) :: {:ok, map(), t()} | {:error, term(), t()}
Sends a CRTP packet through the session transport.