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
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
.
Register a callback function for reports
@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.
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()