Binary and anonymous requests to remote nodes: status, telemetry, min/max/avg telemetry, ACL, neighbours, regions, owner info and basic info.
Every *_sync function sends the request, waits for the matching response
and returns {:ok, data} or {:error, event}; they are serialised through
the per-connection mesh request lock (only one request is in flight at a
time, as the radio can only handle one anyway).
The *_async variants return as soon as the request is queued (:msg_sent);
the response then arrives as an event you can Meshcore.subscribe/3 to or
Meshcore.wait_for_event/3 for, filtered by tag: (see the
expected_ack in the returned payload).
Common options for all of them: :timeout and :min_timeout in
milliseconds (by default derived from the device's suggestion).
Summary
Functions
Fetches the complete neighbour table, issuing several requests when needed.
Deprecated alias of req_acl_sync/3.
Requests the access control list. Returns a list of %{key: hex_prefix, perm: integer}.
Requests a node's basic info, i.e. its clock (async variant).
Requests a node's basic info. Returns the :binary_response payload (%{tag:, data: hex}).
Requests min/max/average telemetry between Unix times start_time and
end_time. Returns a list of %{channel:, type:, min:, max:, avg:}.
Requests a node's neighbour table and returns once queued.
Requests a node's neighbour table and waits for it. Returns a map with
:neighbours_count (total), :results_count (received in this answer) and
:neighbours – a list of %{pubkey:, secs_ago:, snr:}. See
fetch_all_neighbours/3 to page through large tables.
Requests a node's name and owner info (async variant).
Requests a node's name and owner info. Returns %{name: String.t(), owner: String.t()}.
Requests the regions configured on a node (async variant).
Requests the regions configured on a node. Returns the region string.
Deprecated alias of req_status_sync/3.
Requests the status of a repeater/room (battery, noise floor, airtime, packet
counters…). Returns the parsed :status_response payload.
Deprecated alias of req_telemetry_sync/3.
Requests the sensor telemetry of a node. Returns the decoded LPP readings,
e.g. [%{channel: 1, type: "temperature", value: 21.5}].
Types
@type mc() :: GenServer.server()
@type result() :: {:ok, Meshcore.Event.t()} | {:error, Meshcore.Event.t()}
Functions
@spec fetch_all_neighbours(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, map()} | {:error, Meshcore.Event.t()}
Fetches the complete neighbour table, issuing several requests when needed.
If a follow-up page fails twice in a row the partial result is returned –
compare :results_count with :neighbours_count.
@spec req_acl(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, list()} | {:error, Meshcore.Event.t()}
Deprecated alias of req_acl_sync/3.
@spec req_acl_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, list()} | {:error, Meshcore.Event.t()}
Requests the access control list. Returns a list of %{key: hex_prefix, perm: integer}.
@spec req_basic_async(mc(), Meshcore.Util.destination(), keyword()) :: result()
Requests a node's basic info, i.e. its clock (async variant).
@spec req_basic_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, map()} | {:error, Meshcore.Event.t()}
Requests a node's basic info. Returns the :binary_response payload (%{tag:, data: hex}).
@spec req_mma_sync( mc(), Meshcore.Util.destination(), non_neg_integer(), non_neg_integer(), keyword() ) :: {:ok, list()} | {:error, Meshcore.Event.t()}
Requests min/max/average telemetry between Unix times start_time and
end_time. Returns a list of %{channel:, type:, min:, max:, avg:}.
@spec req_neighbours_async(mc(), Meshcore.Util.destination(), keyword()) :: result()
Requests a node's neighbour table and returns once queued.
Options: :count (255), :offset (0), :order_by (0), :pubkey_prefix_length (4).
@spec req_neighbours_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, map()} | {:error, Meshcore.Event.t()}
Requests a node's neighbour table and waits for it. Returns a map with
:neighbours_count (total), :results_count (received in this answer) and
:neighbours – a list of %{pubkey:, secs_ago:, snr:}. See
fetch_all_neighbours/3 to page through large tables.
@spec req_owner_async(mc(), Meshcore.Util.destination(), keyword()) :: result()
Requests a node's name and owner info (async variant).
@spec req_owner_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, map()} | {:error, Meshcore.Event.t()}
Requests a node's name and owner info. Returns %{name: String.t(), owner: String.t()}.
@spec req_regions_async(mc(), Meshcore.Util.destination(), keyword()) :: result()
Requests the regions configured on a node (async variant).
@spec req_regions_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, String.t()} | {:error, Meshcore.Event.t()}
Requests the regions configured on a node. Returns the region string.
@spec req_status(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, map()} | {:error, Meshcore.Event.t()}
Deprecated alias of req_status_sync/3.
@spec req_status_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, map()} | {:error, Meshcore.Event.t()}
Requests the status of a repeater/room (battery, noise floor, airtime, packet
counters…). Returns the parsed :status_response payload.
@spec req_telemetry(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, list()} | {:error, Meshcore.Event.t()}
Deprecated alias of req_telemetry_sync/3.
@spec req_telemetry_sync(mc(), Meshcore.Util.destination(), keyword()) :: {:ok, list()} | {:error, Meshcore.Event.t()}
Requests the sensor telemetry of a node. Returns the decoded LPP readings,
e.g. [%{channel: 1, type: "temperature", value: 21.5}].