org.discotools.io.aprs
Class APRS

java.lang.Object
  extended by org.discotools.io.aprs.APRS

public final class APRS
extends Object

Common fields and methods class.

APRS Report Format parser use fields and methods in this class to parse common fields like ALTITUDE in comment text and CSE/SPD in APRS extensions.

All fields and methods are static.

Author:
kengu

Field Summary
static String ALT
          ALTITUDE in Comment Text (/A=aaaaaa) (p. 26, APRS Protocol version 1.0.1) This REGEX contains three groups: 0: all groups 1: altitude field 2: altitude value (feet)
static String C_COORD
          Compressed coordinate pattern
static String C_CST
          Compressed Extension Format (p. 39, APRS Protocol version 1.0.1) This REGEX contains four groups: 0: all groups 1: 'c' 2: 's' 3: 'T'
static String C_EXT_CS
          Compressed CSE/SPD (COURSE/SPEED) Extension Format (p. 38-39, APRS Protocol version 1.0.1) This REGEX contains two groups: 0: all groups 1: 'cs' (two characters)
static byte C_EXT_T_GGA
          Compression Type (T) Byte - GGA (NMEA source) flag (p. 39, APRS Protocol version 1.0.1) This flag codifies that the extension field 'cs' is an ALTITUDE from a GGA sentences.
static byte C_EXT_T_NMEA
          Compression Type (T) Byte - NMEA flag mask (p. 39, APRS Protocol version 1.0.1) This mask is bitwise AND'ed with NMEA flags to detect NMEA source codified in the extension field 'T'.
static String C_POS
          Compressed LAT/LON position pattern
static String EXT_CS
          COURSE/SPEED Extension Format (p. 58,59, APRS Protocol version 1.0.1) This REGEX contains three groups: 0: all groups 1: course (degrees) 2: speed (knots)
static String EXT_CS_BNRQ
          BRG/NRQ (BEARING/NUMBER/RANGE/QUALITY) Extension Format (p. 34, APRS Protocol version 1.0.1) This REGEX contains five groups: 0: all groups 1: bearing (degrees) 2: number (byte 0-9) 3: range (byte 0-9) 4: quality (byte 0-9)
static String LAT
          Latitude pattern
static String LON
          Longitude pattern
static String POS
          LAT/LON position pattern
static String TIME
          Time stamp pattern
static String VERSION
          IO-APRS version string
static String ZULU
          Zulu (GMT+0) time zone pattern.
 
Constructor Summary
APRS()
           
 
Method Summary
static double decodeCoord(String coord)
           
static double decodeLAT(String lat)
           
static double decodeLON(String lon)
           
static com.vividsolutions.jts.geom.Point decodePoint(String lat, String lon)
           
static boolean isNMEASource(char type, Byte source)
          Check if given compression type byte is given NMEA source.
static Matcher matcher(String regexp, String data)
           
static String parseALT(AprsPosition report, String data, boolean decode)
          Parse ALTITUDE from comment text or compressed extension field (p. 33, 38-40, APRS Protocol version 1.0.1) If decode true, ALTITUDE decoded as compressed extension data.
static String parseBNRQ(AprsDirection report, String extension)
          Parse BRG/NRQ (bearing/number-range-quality) extension (p. 34, APRS Protocol version 1.0.1) This method should only be called from parseCS(AprsReport, String, boolean)!
static String parseCS(AprsReport report, String extension, boolean decode)
          Parse CSE/SPD (COURSE/SPEED) extension (p. 33, 38-39, APRS Protocol version 1.0.1) If COURSE/SPEED extension format is found, current AprsReport.getExtension() is merged and replaced with a new AprsDirection instance.
static AprsReport parsePOS(AprsPosition position, String payload, Matcher matcher, int offset, boolean decode)
          Common Position Report and Extension payload parser This methods parse position report data from payload with POS and C_POS format.
static Pattern pattern(String regexp)
           
static String residue(String data, Matcher matcher)
           
static String residue(String payload, Matcher matcher, int... groups)
           
static boolean setPoint(AprsPosition position, String lat, String lon, boolean decode)
           
static void setSymbol(AprsReport report, int table, char code, char overlay)
           
static boolean setTime(AprsReport report, String field, boolean isNMEA)
           
static boolean setTime(AprsReport report, String date, String time)
           
static byte[] toAddress(String callsign, boolean toAX25)
          Convert APRS callsign to AX.25 address This conversion is based on the method Callsign.toAX25() in javAPRSlib.
static String toAPRS(byte[] packet)
          Convert from AX.25 packet to APRS packet with "TNC-2" source path header format The packet should not include the '0x7e' flag which separates each UI-frame Frame Check Sequence (FCS) field (two bytes)
static String toCallsign(byte[] packet, int offset)
          Convert AX.25 address to APRS callsign This conversion is based on the Callsign class constructor in javAPRSlib.
static long toDate(String date, String time)
          Get timestamp value from Day/Month/Year (DMY) format.
static long toDHM(String field, boolean isZulu)
          Get timestamp value from Day/Hours/Minutes (DHM) format.
static long toHMS(String field, boolean isNMEA, boolean isZulu)
          Get timestamp value from Hour/Minutes/Seconds (HMS) format.
static long toMHDM(String field, boolean isZulu)
          Get timestamp value from Month/Day/Hours/Minutes (MDHM) format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
IO-APRS version string

See Also:
Constant Field Values

ZULU

public static final String ZULU
Zulu (GMT+0) time zone pattern.

See Also:
Constant Field Values

TIME

public static final String TIME
Time stamp pattern

See Also:
Constant Field Values

LAT

public static final String LAT
Latitude pattern

See Also:
Constant Field Values

LON

public static final String LON
Longitude pattern

See Also:
Constant Field Values

POS

public static final String POS
LAT/LON position pattern

See Also:
Constant Field Values

C_COORD

public static final String C_COORD
Compressed coordinate pattern

See Also:
Constant Field Values

C_POS

public static final String C_POS
Compressed LAT/LON position pattern

See Also:
Constant Field Values

EXT_CS

public static final String EXT_CS
COURSE/SPEED Extension Format

(p. 58,59, APRS Protocol version 1.0.1)

This REGEX contains three groups:

  • 0: all groups
  • 1: course (degrees)
  • 2: speed (knots)
  • See Also:
    Constant Field Values

    EXT_CS_BNRQ

    public static final String EXT_CS_BNRQ
    BRG/NRQ (BEARING/NUMBER/RANGE/QUALITY) Extension Format

    (p. 34, APRS Protocol version 1.0.1)

    This REGEX contains five groups:

  • 0: all groups
  • 1: bearing (degrees)
  • 2: number (byte 0-9)
  • 3: range (byte 0-9)
  • 4: quality (byte 0-9)
  • See Also:
    Constant Field Values

    ALT

    public static final String ALT
    ALTITUDE in Comment Text (/A=aaaaaa)

    (p. 26, APRS Protocol version 1.0.1)

    This REGEX contains three groups:

  • 0: all groups
  • 1: altitude field
  • 2: altitude value (feet)
  • See Also:
    Constant Field Values

    C_EXT_CS

    public static final String C_EXT_CS
    Compressed CSE/SPD (COURSE/SPEED) Extension Format

    (p. 38-39, APRS Protocol version 1.0.1)

    This REGEX contains two groups:

  • 0: all groups
  • 1: 'cs' (two characters)
  • See Also:
    Constant Field Values

    C_CST

    public static final String C_CST
    Compressed Extension Format

    (p. 39, APRS Protocol version 1.0.1)

    This REGEX contains four groups:

  • 0: all groups
  • 1: 'c'
  • 2: 's'
  • 3: 'T'
  • See Also:
    Constant Field Values

    C_EXT_T_NMEA

    public static final byte C_EXT_T_NMEA
    Compression Type (T) Byte - NMEA flag mask

    (p. 39, APRS Protocol version 1.0.1)

    This mask is bitwise AND'ed with NMEA flags to detect NMEA source codified in the extension field 'T'.


    C_EXT_T_GGA

    public static final byte C_EXT_T_GGA

    Compression Type (T) Byte - GGA (NMEA source) flag

    (p. 39, APRS Protocol version 1.0.1)

    This flag codifies that the extension field 'cs' is an ALTITUDE from a GGA sentences.

    Constructor Detail

    APRS

    public APRS()
    Method Detail

    toAPRS

    public static final String toAPRS(byte[] packet)
                               throws org.discotools.io.ParseException
    Convert from AX.25 packet to APRS packet with "TNC-2" source path header format

    The packet should not include the

  • '0x7e' flag which separates each UI-frame
  • Frame Check Sequence (FCS) field (two bytes)
  • Parameters:
    packet - - byte array with single AX.25 frame
    Returns:
    String
    Throws:
    org.discotools.io.ParseException

    toCallsign

    public static String toCallsign(byte[] packet,
                                    int offset)
    Convert AX.25 address to APRS callsign

    This conversion is based on the Callsign class constructor in javAPRSlib.

    Parameters:
    packet -
    offset -
    Returns:
    String

    toAddress

    public static byte[] toAddress(String callsign,
                                   boolean toAX25)
                            throws org.discotools.io.ParseException
    Convert APRS callsign to AX.25 address

    This conversion is based on the method Callsign.toAX25() in javAPRSlib.

    NOTE: SSIDs on AX.25 are constrained to the range [0,16] (integer). SSIDs on the Internet (APRS-IS) however, are not constrained by the AX.25 address length in the AX.25 header (maximum of 7 bytes), and therefore allow any characters in SSIDs. This method will throw an ParseException if SSID is not an integer in the range [0,16] (see SSID documentation).

    Parameters:
    callsign -
    toAX25 - - if true, byte 0 through 5 are shifted to the left (AX.25). If false, the byte array is an APRS callsign in ASCII format with a SSID in the range [0,16] (integer).
    Returns:
    7 byte address
    Throws:
    org.discotools.io.ParseException - if SSID is not an integer in the range [0,16].

    parsePOS

    public static final AprsReport parsePOS(AprsPosition position,
                                            String payload,
                                            Matcher matcher,
                                            int offset,
                                            boolean decode)
    Common Position Report and Extension payload parser

    This methods parse position report data from payload with POS and C_POS format. All APRS report formats which contains uncompressed LAT/LON data, contains the same position format. The difference is the position field offset from the first field in any given format. The same applies to compressed LAT/LON data, which this method is able to decode into uncompressed format.

    Unsupported formats and extensions in parsed as comment text.

    Parameters:
    position - - an AprsPosition instance which data is parsed into.
    payload - - payload containing position data
    matcher - - an REGEX matcher for any report format which contains data on common position format
    offset - - position field offset from first field in given payload
    decode - - if true, position and extension data is decoded into uncompressed format.
    Returns:
    AprsReport

    parseCS

    public static String parseCS(AprsReport report,
                                 String extension,
                                 boolean decode)
    Parse CSE/SPD (COURSE/SPEED) extension

    (p. 33, 38-39, APRS Protocol version 1.0.1)

    If COURSE/SPEED extension format is found, current AprsReport.getExtension() is merged and replaced with a new AprsDirection instance.

    Parameters:
    report - - AprsReport instance
    extension - - APRS extension field
    decode - - if true, extension is compressed.

    Returns:
    extension residue after CSE/SPD is subtracted

    parseALT

    public static String parseALT(AprsPosition report,
                                  String data,
                                  boolean decode)
    Parse ALTITUDE from comment text or compressed extension field

    (p. 33, 38-40, APRS Protocol version 1.0.1)

    If decode true, ALTITUDE decoded as compressed extension data.

    Parameters:
    report - - AprsReport instance
    data - - APRS data
    decode - - if true, extension data is compressed.

    Returns:
    data residue after ALTITUDE is subtracted

    isNMEASource

    public static boolean isNMEASource(char type,
                                       Byte source)
    Check if given compression type byte is given NMEA source.

    (p. 39, APRS Protocol version 1.0.1)

    Parameters:
    type - - compression type byte 'T'
    source - - NMEA source flag
    Returns:
    true if source match type.

    parseBNRQ

    public static String parseBNRQ(AprsDirection report,
                                   String extension)
    Parse BRG/NRQ (bearing/number-range-quality) extension

    (p. 34, APRS Protocol version 1.0.1)

    This method should only be called from parseCS(AprsReport, String, boolean)!

    Parameters:
    report - - AprsReport instance
    extension - - APRS extension field

    Returns:
    extension residue after BRG/NRQ is subtracted

    setPoint

    public static boolean setPoint(AprsPosition position,
                                   String lat,
                                   String lon,
                                   boolean decode)

    setTime

    public static boolean setTime(AprsReport report,
                                  String field,
                                  boolean isNMEA)

    setTime

    public static boolean setTime(AprsReport report,
                                  String date,
                                  String time)

    toHMS

    public static long toHMS(String field,
                             boolean isNMEA,
                             boolean isZulu)
                      throws org.discotools.io.ParseException
    Get timestamp value from Hour/Minutes/Seconds (HMS) format.

    (see page 22 in APRS specification 1.0.1 for complete list)

    Parameters:
    field - - In NMEA sentences, a 6-character timestamp: hour, minute, second UTC. In APRS Data, a 7-character timestamp: hour, minute, second, zulu 'z'|'h' or local '/' time.
    isNMEA - - if true, field in NMEA sentence
    isZulu - - if true, field should be parsed in Zulu (GMT=UTC) time
    Returns:
    time in milliseconds
    Throws:
    org.discotools.io.ParseException

    toMHDM

    public static long toMHDM(String field,
                              boolean isZulu)
                       throws org.discotools.io.ParseException
    Get timestamp value from Month/Day/Hours/Minutes (MDHM) format.

    (see page 22 in APRS specification 1.0.1 for complete list)

    Parameters:
    field - - a 8-byte timestamp: month, day, hour, minute (used in positionless weather station reports).
    Returns:
    time in milliseconds
    Throws:
    org.discotools.io.ParseException

    toDHM

    public static long toDHM(String field,
                             boolean isZulu)
                      throws org.discotools.io.ParseException
    Get timestamp value from Day/Hours/Minutes (DHM) format.

    (see page 22 in APRS specification 1.0.1 for complete list)

    Parameters:
    field - - a 7-character timestamp: day-of-the-month, hour, minute, zulu 'z'|'h' or local '/' time.
    Returns:
    time in milliseconds
    Throws:
    org.discotools.io.ParseException - If not a valid DHM format

    toDate

    public static long toDate(String date,
                              String time)
                       throws org.discotools.io.ParseException
    Get timestamp value from Day/Month/Year (DMY) format.

    (NMEA GPRMC sentence)

    Parameters:
    date - - a 6-character timestamp: day-of-month, month, year
    time - - a 6-character timestamp: hourd, minutes, seconds, zulu
    Returns:
    time in milliseconds
    Throws:
    org.discotools.io.ParseException

    decodePoint

    public static com.vividsolutions.jts.geom.Point decodePoint(String lat,
                                                                String lon)

    decodeLAT

    public static double decodeLAT(String lat)

    decodeLON

    public static double decodeLON(String lon)

    decodeCoord

    public static double decodeCoord(String coord)

    pattern

    public static Pattern pattern(String regexp)

    matcher

    public static Matcher matcher(String regexp,
                                  String data)

    residue

    public static String residue(String data,
                                 Matcher matcher)

    residue

    public static String residue(String payload,
                                 Matcher matcher,
                                 int... groups)

    setSymbol

    public static void setSymbol(AprsReport report,
                                 int table,
                                 char code,
                                 char overlay)


    Copyright © 2012-2013 DISCO Foundation. All Rights Reserved.