gpsd_json

Types and functions for working with GPSD’s JSON API.

https://gpsd.io/gpsd_json.html

This library does not cover the full API presently, instead it only covers basic parts of the API that I wanted for my project. Pull requests to add support for parts that you want are very welcome!

Types

pub type Command {
  WatchCommand(enable: Option(Bool), json: Option(Bool))
  PollCommand
}

Constructors

  • WatchCommand(enable: Option(Bool), json: Option(Bool))

    This command sets watcher mode.

    https://gpsd.io/gpsd_json.html#_watch

    Arguments

    • enable

      Enable (true) or disable (false) watcher mode.

    • json

      Enable (true) or disable (false) dumping of JSON reports.

  • PollCommand

    The POLL command requests data from the last-seen fixes on all active GPS devices. Devices must previously have been activated by ?WATCH to be pollable.

    https://gpsd.io/gpsd_json.html#_poll

pub type NmeaMode {
  UnknownNmeaMode
  NoFixNmeaMode
  TwoDimensionalNmeaMode
  ThreeDimensionalNmeaMode
}

Constructors

  • UnknownNmeaMode
  • NoFixNmeaMode
  • TwoDimensionalNmeaMode
  • ThreeDimensionalNmeaMode
pub type Response {
  TpvResponse(Tpv)
  PollResponse(time: String, active: Int, tpv: List(Tpv))
  OtherResponse(class: String)
}

Constructors

  • TpvResponse(Tpv)

    A TPV object is a time-position-velocity report.

    https://gpsd.io/gpsd_json.html#_tpv

  • PollResponse(time: String, active: Int, tpv: List(Tpv))

    Response to the POLL command.

    https://gpsd.io/gpsd_json.html#_poll

    Arguments

    • time

      Timestamp in ISO 8601 format. May have a fractional part of up to .001sec precision.

    • active

      Count of active devices.

  • OtherResponse(class: String)
pub type Tpv {
  Tpv(
    mode: NmeaMode,
    device: Option(String),
    time: Option(String),
    latitude: Option(Float),
    longitude: Option(Float),
  )
}

Constructors

  • Tpv(
      mode: NmeaMode,
      device: Option(String),
      time: Option(String),
      latitude: Option(Float),
      longitude: Option(Float),
    )

    Arguments

    • device

      The name of the originating device

    • time

      Time/date stamp in ISO8601 format, UTC. May have a fractional part of up to .001sec precision. May be absent if the mode is not 2D or 3D. May be present, but invalid, if there is no fix. Verify 3 consecutive 3D fixes before believing it is UTC. Even then it may be off by several seconds until the current leap seconds is known.

    • latitude

      Latitude in degrees: +/- signifies North/South.

    • longitude

      Longitude in degrees: +/- signifies East/West.

Functions

pub fn command_to_string(command: Command) -> String
pub fn decode_response(
  data: Dynamic,
) -> Result(Response, List(DecodeError))
pub fn response_decoder() -> Decoder(Response)
Search Document