Talks to the device behind a running server, whichever transport it uses.
Every function takes the id the server was started with, see
NervesMCP.start_server/2.
Requests to one device run one at a time. A request made while another is in flight waits its turn, and its timeout starts counting when it is sent to the device.
Summary
Functions
Sends everything the device prints outside of requests to pid as {:console_data, binary}.
Waits for the device to answer with a firmware UUID, for up to timeout ms.
Evaluates Elixir code on the device and returns the inspected result.
Evaluates Elixir code on the device, capturing what it prints as well.
Reads the UUID of the firmware the device is running.
Probes what is on the other end. Returns
Drops and re-establishes the connection. Only SSH needs this; UART is a no-op.
Writes bytes to the device as they are.
Runs a shell command on a device that offers a shell rather than IEx.
Runs a shell command, capturing stdout, stderr and the exit code.
The transport a server uses: :ssh, :uart, or nil when it is not running.
Checks a :connection option before a server is started with it.
The connection process for a server, if it is running.
Types
Functions
Sends everything the device prints outside of requests to pid as {:console_data, binary}.
@spec await_firmware_uuid(id(), non_neg_integer()) :: result()
Waits for the device to answer with a firmware UUID, for up to timeout ms.
Useful after a reboot or a firmware update. An SSH connection is re-established between attempts, since a session to a rebooted device can hang for a while.
@spec detach_console(id()) :: :ok
Evaluates Elixir code on the device and returns the inspected result.
Code that raises, throws or exits gives {:error, formatted_exception}.
Evaluates Elixir code on the device, capturing what it prints as well.
Reads the UUID of the firmware the device is running.
Fails when the device does not answer, does not run Nerves, or has no UUID.
@spec probe(id(), timeout()) :: {:ok, String.t()} | {:eval_error, String.t()} | :noise | :down | :busy
Probes what is on the other end. Returns:
{:ok, result}- Elixir ran and gave this for the firmware UUID{:eval_error, message}- Elixir ran, but reading the UUID failed:noise- bytes came back but no Elixir result:down- not connected, or nothing came back:busy- other requests are in flight
Drops and re-establishes the connection. Only SSH needs this; UART is a no-op.
Writes bytes to the device as they are.
Runs a shell command on a device that offers a shell rather than IEx.
Runs a shell command, capturing stdout, stderr and the exit code.
@spec type(id()) :: :ssh | :uart | nil
The transport a server uses: :ssh, :uart, or nil when it is not running.
Checks a :connection option before a server is started with it.
The connection process for a server, if it is running.