Utilities¶
-
class
aprspy.utils.
APRSUtils
¶ Useful generic functions for APRS parsing and decoding.
This class provides functions for parsing and decoding different kinds of APRS packets. Packet type-specific functions are defined under the different
APRSPacket
subclasses.-
static
decode_compressed_latitude
(latitude: str) → float¶ Convert a compressed latitude string to a latitude value.
- Parameters
latitude (str) – a latitude in a compressed format
Compressed latitudes have the format YYYY, where all values are base-91 printable ASCII characters.
See also APRS 1.01 C9 P38.
-
static
decode_compressed_longitude
(longitude: str) → float¶ Convert a compressed longitude string to a latitude value.
- Parameters
longitude (str) – a longitude in compressed format
Compressed longitude have the format XXXX, where all values are base-91 printable ASCII characters
See also APRS 1.01 C9 P38
-
static
decode_dfs
(dfs: str) → Tuple[int, int, int, Optional[int]]¶ Decode a DFS (Omni-DF Signal Strength) value and return the individual values.
- Parameters
dfs (str) – a DFS value, minus the initial
DFS
identifier
- The DFS extension provides a way of specifying approximate values for:-
Received signal strength (in S-points)
Antenna height above average terrain (in feet)
Antenna gain (in dB)
Directivity (in degrees)
Like PHG values, DFS values are 4 characters long, and each digit is responsible for one of the above values. The APRS spec does not specify it, but it is assumed that - like the PHG value - the antenna height can be any ASCII value from 0 upwards.
See APRS 1.01 C7 P29
-
static
decode_nrq
(nrq: str) → Tuple[Union[float, str, None], Optional[int], Optional[int]]¶ Parse an NRQ (Number/Range/Quality) value and return the individual values.
- Parameters
nrq (str) – an NRQ value
- For direction-finding reports, the NRQ value provides:-
The number of hits per period relative to the length of the time period (as a percentage)
The range (in miles)
The bearing accuracy (in degrees)
NRQ values are 3 digits long, and all digits from 0 to 9. An ‘N’ value of 0 implies that the rest of the values are meaningless. An ‘N’ value of 9 indicates that the report is manual.
The bearing accuracy represents the degree of accuracy, so a ‘Q’ value of 3 is 64, meaning that the accuracy is to less than 64 degrees.
See APRS 1.01 C7 P30
-
static
decode_phg
(phg: str) → Tuple[int, int, int, Optional[int]]¶ Decode a PHG (Power, Effective Antenna Height/Gain/Directivity) value and return the individual values.
- Parameters
phg (str) – a PHG value, minus the initial
PHG
identifier
- The PHG extension provides a way of specifying approximate values for:-
Power (in watts)
Height above average local terrain (in feet)
Antenna gain (in dB)
Directivity (in degrees)
PHG values are 4 characters long, and each digit is responsible for one of the above values. As per the APRS spec, the height value can be any ASCII character from 0 upwards.
See APRS 1.01 C7 P28
-
static
decode_timestamp
(raw_timestamp: str) → datetime.datetime¶ Decode a timestamp.
- Parameters
raw_timestamp (str) – a string representing a timestamp
- Timestamps can take a number of different forms:-
Zulu, identified with a trailing ‘z’, which refers to zulu time
Local, identified with a trailing ‘/’, which has no timezone information
A hour/minute/second timestamp without any date information
-
static
decode_uncompressed_latitude
(latitude: str) → Tuple[Union[int, float], int]¶ Convert an uncompressed latitude string to a latitude and an ambiguity value.
- Parameters
latitude (str) – an uncompressed latitude, in the form
DDMM.HHC
- Uncompressed latitudes have the format DDMM.HHC, where:-
DD are the degrees
MM are the minutes
HH are the hundredths of minutes
C is either N (for the northern hemisphere) or S (southern)
MM and HH can be replaced with spaces (” “) to provide positional ambiguity (C6 P24).
See also APRS 1.01 C6 P23.
-
static
decode_uncompressed_longitude
(longitude: str, ambiguity: int = 0) → float¶ Convert an uncompressed longitude string to a longitude value, with an optional ambiguity level applied.
- Parameters
longitude (str) – the longitude, in the format
DDDMM.HHC
ambiguity (int) – the level of ambiguity, between 1 and 4
- Uncompressed longitudes have the format DDDMM.HHC, where:-
DD are the degrees
MM are the minutes
HH are the hundreths of minutes
C is either W (for west of the meridian) or E (for east)
Positional ambiguity is handled by the latitude, and so should be honoured regardless of the precision of the longitude given (as per C6 P24).
-
static
encode_compressed_latitude
(latitude: Union[float, int]) → str¶ Convert a latitude to a compressed latitude value.
- Parameters
latitude (float/int) – a latitude
Compressed latitudes have the format YYYY, where all values are base-91 printable ASCII characters.
See also APRS 1.01 C9 P38.
-
static
encode_compressed_longitude
(longitude: Union[float, int]) → str¶ Convert a longitude to a compressed latitude value.
- Parameters
longitude (float/int) – a longitude
Compressed longitude have the format XXXX, where all values are base-91 printable ASCII characters
See also APRS 1.01 C9 P38
-
static
encode_dfs
(strength: int, height: int, gain: int, directivity: int = None) → str¶ Encode a DFS (Omni-DF Signal Strength) value from individual values.
- Parameters
strength (int) – the received signal strength, in S-points
height (int) – the antenna height, in feet
gain (int) – the antenna gain, in dB
directivity (int/str) – the antenna directivity, in degrees, or
omni
For more information, see
decode_dfs()
.
-
static
encode_phg
(power: int, height: int, gain: int, directivity: Union[int, str]) → str¶ Encode a PHG (Power, Effective Antenna Height/Gain/Directivity) value from individual values.
- Parameters
power (int) – the power, in watts
height (int) – the antenna height, in feet
gain (int) – the antenna gain, in dB
directivity (int/str) – the antenna directivity, in degrees
For more information, see
decode_phg()
.
-
static
encode_timestamp
(timestamp: datetime.datetime, timestamp_type: str = 'zulu') → str¶ Encode a timestamp.
- Parameters
timestamp (datetime) – a timestamp
timestamp_type (str) – the timestamp type (zulu, hms or local)
-
static
encode_uncompressed_latitude
(latitude: Union[float, int], ambiguity: int = 0) → str¶ Encode a latitude into an uncompressed latitude format.
- Parameters
latitude (float/int) – a latitude
ambiguity (int) – an optional ambiguity level
For more information see
decode_uncompressed_latitude()
-
static
encode_uncompressed_longitude
(longitude: float, ambiguity: int = 0) → str¶ Encode a longitude into an uncompressed longitude format.
- Parameters
longitude (float) – a longitude
ambiguity (int) – an optional ambiguity level
For more information see
decode_uncompressed_latitude()
-
static
generate_passcode
(callsign: str) → str¶ Generate an APRS-IS passcode for a given callsign.
- Parameters
callsign (str) – a callsign, with or without an SSID
This will generate an APRS-IS passcode for a callsign, after stripping the SSID (if given).
-
classmethod
validate_passcode
(callsign: str, passcode: str) → bool¶ Validate an APRS-IS passcode for a given callsign.
- Parameters
callsign (str) – a callsign, with or without an SSID
passcode (str) – a passcode
This will generate a passcode for the given callsign, and compare it to the provided passcode.
-
static