Raxol.Sensor.Feed (Raxol v2.3.0)

View Source

GenServer managing a single sensor's polling lifecycle.

Connects to a sensor module, polls at the configured sample rate, buffers readings in a CircularBuffer, and forwards each reading to the fusion process.

Summary

Types

status()

@type status() :: :connecting | :running | :error | :stopped

t()

@type t() :: %Raxol.Sensor.Feed{
  backoff_ref: reference() | nil,
  buffer: CircularBuffer.t(),
  buffer_size: pos_integer(),
  connect_opts: keyword(),
  error_count: non_neg_integer(),
  fusion_pid: pid() | nil,
  max_errors: pos_integer(),
  module: module(),
  poll_ref: reference() | nil,
  sample_rate_ms: pos_integer(),
  sensor_id: atom(),
  sensor_state: term(),
  status: status()
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_history(server, count \\ 10)

@spec get_history(GenServer.server(), pos_integer()) :: [map()]

get_latest(server)

@spec get_latest(GenServer.server()) :: {:ok, map()} | {:error, :empty}

get_status(server)

@spec get_status(GenServer.server()) :: status()

reconnect(server)

@spec reconnect(GenServer.server()) :: :ok

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()