View Source VintageNetMobile.ExChat (vintage_net_mobile v0.11.5)

Send commands to your modem and get notifications

This module is used by the "monitor" modules for reporting modem and connection status.

It can be handy to debug modems too. If you'd like to send commands and receive notifications from the IEx prompt, here's what to do:

require Logger
RingLogger.attach
tty_name = "ttyUSB2" # set to your AT command interface
VintageNetMobile.ExChat.register(tty_name, "+", fn m -> Logger.debug("Got: " <> inspect(m)) end)
VintageNetMobile.ExChat.send(tty_name, "AT+CSQ")

To reset the registrations, VintageNet.deconfigure/2 and VintageNet.configure/3 your modem.

Summary

Types

The options for the ATCommand server are

Functions

Returns a specification to start this module under a supervisor.

Register a callback function for reports

Send a command to the modem

Helper for sending commands to the modem as best effort

Types

@type opt() ::
  {:speed, non_neg_integer()}
  | {:tty, String.t()}
  | {:uart, module()}
  | {:uart_opts, keyword()}

The options for the ATCommand server are:

  • :speed - the speed of the serial connection
  • :tty - the tty name for sending AT commands
  • :uart - use an alternative UART-provider (for testing)
  • :uart_opts - additional options to pass to UART.open

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

register(tty_name, type, callback)

View Source
@spec register(binary(), binary(), function()) :: :ok

Register a callback function for reports

Link to this function

send(tty_name, command, options \\ [])

View Source
@spec send(binary(), iodata(), VintageNetMobile.ExChat.Core.send_options()) ::
  {:ok, [binary()]} | {:error, any()}

Send a command to the modem

On success, this returns a list of the lines received back from the modem.

Link to this function

send_best_effort(tty_name, command, options \\ [])

View Source
@spec send_best_effort(
  binary(),
  iodata(),
  VintageNetMobile.ExChat.Core.send_options()
) :: :ok

Helper for sending commands to the modem as best effort

This function always succeeds. Failed commands log errors, but that's it. This is useful for monitoring operations where intermittent failures should be logged, but really aren't worth dealing with.

@spec start_link([opt()]) :: GenServer.on_start()