mirror of
https://github.com/craigerl/aprsd.git
synced 2025-09-04 06:07:48 -04:00
Fix in for aprslib issue #80
aprslib incorrectly decodes weather packets and doesn't provide wind_speed or wind_direction from the CSE/SPD 7 bytes in the APRS packet. This patch puts a temporary fix in place until the aprslib pull request lands and is released. https://github.com/rossengeorgiev/aprs-python/issues/80 https://github.com/rossengeorgiev/aprs-python/pull/81
This commit is contained in:
parent
bba7b68112
commit
63bf82aab5
@ -126,9 +126,33 @@ class Packet(metaclass=abc.ABCMeta):
|
|||||||
if packet_type == PACKET_TYPE_WX:
|
if packet_type == PACKET_TYPE_WX:
|
||||||
# the weather information is in a dict
|
# the weather information is in a dict
|
||||||
# this brings those values out to the outer dict
|
# this brings those values out to the outer dict
|
||||||
|
|
||||||
for key in raw["weather"]:
|
for key in raw["weather"]:
|
||||||
raw[key] = raw["weather"][key]
|
raw[key] = raw["weather"][key]
|
||||||
|
|
||||||
|
# If we have the broken aprslib, then we need to
|
||||||
|
# Convert the course and speed to wind_speed and wind_direction
|
||||||
|
# aprslib issue #80
|
||||||
|
# https://github.com/rossengeorgiev/aprs-python/issues/80
|
||||||
|
# Wind speed and course is option in the SPEC.
|
||||||
|
# For some reason aprslib multiplies the speed by 1.852.
|
||||||
|
if "wind_speed" not in raw and "wind_direction" not in raw:
|
||||||
|
# Most likely this is the broken aprslib
|
||||||
|
# So we need to convert the wind_gust speed
|
||||||
|
raw["wind_gust"] = raw.get("wind_gust", 0) / 0.44704
|
||||||
|
if "wind_speed" not in raw:
|
||||||
|
wind_speed = raw.get("speed")
|
||||||
|
if wind_speed:
|
||||||
|
raw["wind_speed"] = wind_speed / 1.852
|
||||||
|
if "speed" in raw:
|
||||||
|
del raw["speed"]
|
||||||
|
if "wind_direction" not in raw:
|
||||||
|
wind_direction = raw.get("course")
|
||||||
|
if wind_direction:
|
||||||
|
raw["wind_direction"] = wind_direction
|
||||||
|
if "course" in raw:
|
||||||
|
del raw["course"]
|
||||||
|
|
||||||
return dacite.from_dict(data_class=class_name, data=raw)
|
return dacite.from_dict(data_class=class_name, data=raw)
|
||||||
|
|
||||||
def log(self, header=None):
|
def log(self, header=None):
|
||||||
@ -281,10 +305,6 @@ class GPSPacket(PathPacket):
|
|||||||
comment: str = None
|
comment: str = None
|
||||||
symbol: str = field(default="l")
|
symbol: str = field(default="l")
|
||||||
symbol_table: str = field(default="/")
|
symbol_table: str = field(default="/")
|
||||||
# in MPH
|
|
||||||
speed: float = 0.00
|
|
||||||
# 0 to 360
|
|
||||||
course: int = 0
|
|
||||||
|
|
||||||
def decdeg2dms(self, degrees_decimal):
|
def decdeg2dms(self, degrees_decimal):
|
||||||
is_positive = degrees_decimal >= 0
|
is_positive = degrees_decimal >= 0
|
||||||
@ -387,6 +407,10 @@ class MicEPacket(GPSPacket):
|
|||||||
messagecapable: bool = False
|
messagecapable: bool = False
|
||||||
mbits: str = None
|
mbits: str = None
|
||||||
mtype: str = None
|
mtype: str = None
|
||||||
|
# in MPH
|
||||||
|
speed: float = 0.00
|
||||||
|
# 0 to 360
|
||||||
|
course: int = 0
|
||||||
|
|
||||||
def _build_raw(self):
|
def _build_raw(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -397,6 +421,10 @@ class ObjectPacket(GPSPacket):
|
|||||||
alive: bool = True
|
alive: bool = True
|
||||||
raw_timestamp: str = None
|
raw_timestamp: str = None
|
||||||
symbol: str = field(default="r")
|
symbol: str = field(default="r")
|
||||||
|
# in MPH
|
||||||
|
speed: float = 0.00
|
||||||
|
# 0 to 360
|
||||||
|
course: int = 0
|
||||||
|
|
||||||
def _build_raw(self):
|
def _build_raw(self):
|
||||||
"""
|
"""
|
||||||
@ -424,6 +452,8 @@ class ObjectPacket(GPSPacket):
|
|||||||
@dataclass()
|
@dataclass()
|
||||||
class WeatherPacket(GPSPacket):
|
class WeatherPacket(GPSPacket):
|
||||||
symbol: str = "_"
|
symbol: str = "_"
|
||||||
|
wind_speed: float = 0.00
|
||||||
|
wind_direction: int = 0
|
||||||
wind_gust: float = 0.00
|
wind_gust: float = 0.00
|
||||||
temperature: float = 0.00
|
temperature: float = 0.00
|
||||||
# in inches. 1.04 means 1.04 inches
|
# in inches. 1.04 means 1.04 inches
|
||||||
|
Loading…
x
Reference in New Issue
Block a user