View Source AprsUtils.AprsIs (AprsUtils v0.1.0)

A module to connect to an APRS-IS server and listen for packets.

These functions implement a client for the APRS-IS server. To use this module, you must implement a client module that implements the AprsUtils.AprsIsClient behaviour. The client module will be called when packets are recieved from the APRS-IS server.

Example

defmodule Client do
  @behaviour AprsUtils.AprsIsClient

  def got_packet(packet, _packet_count) do
    IO.puts("Got packet: #{String.replace_invalid(packet)}")
  end

  def got_comment(comment) do
    IO.puts("Got comment: #{String.replace_invalid(comment)}")
  end

  def disconnected(reason) do
    IO.puts("Disconnected: #{reason}")
  end
end

{:ok, aprs_is_pid} =
  AprsIs.connect(
    username: "my_call_sign",
    password: "my_aprs_is_password",
    app_name: "MyAppName",
    app_version: "0.1",
    client_module: Client
  )

Note to connect to APRS-IS take a look at Connecting to APRS-IS. Also, please follow the rules and guidelines for using APRS-IS.

Summary

Functions

Closes the connection to the APRS-IS server. The aprs_is_pid is the pid returned by connect. Note that calling this does not cause a call to the disconnected callback in the client module.

Connects to the APRS-IS server and starts listening for packets.

Returns true if the APRS-IS server is connected, false otherwise. The aprs_is_pid is the pid returned by connect.

Functions

Closes the connection to the APRS-IS server. The aprs_is_pid is the pid returned by connect. Note that calling this does not cause a call to the disconnected callback in the client module.

Connects to the APRS-IS server and starts listening for packets.

opts may contain the following fields:

  • :host - The hostname of the APRS-IS server. Defaults to "rotate.aprs.net".
  • :port - The port of the APRS-IS server. Defaults to 14580.
  • :username - The username (typically your CALLSIGN) to connect to the APRS-IS server.
  • :password - The password to connect to the APRS-IS server.
  • :app_name - The name of your application.
  • :app_version - The version of your application.
  • :filter - The filter. See the docs here to use for the APRS-IS server. Defaults to "t/poimqstunw".
  • :client_module - The module that implements the AprsUtilsIsClient behaviour.

All of the fields are required except for :host, :port, and :filter which have defaults.

Returns {:ok, pid} if the connection is successful. The pid is the pid of the listener process that is spawned by a successful call.

Returns {:error, reason} if the connection fails. reason is a binary describing the error.

Note that only one connection can be made to the APRS-IS server. It was intended that multiple connections could be made to the APRS-IS server, but this does not work as of this release.

Link to this function

is_connected?(aprs_is_pid)

View Source

Returns true if the APRS-IS server is connected, false otherwise. The aprs_is_pid is the pid returned by connect.