mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-21 23:55:17 -05:00
Added contructing a GPSPacket for sending
This patch adds the needed code to construct the raw output string for sending a GPSPacket. TODO: Need to incorporate speed, course, rng, position ambiguity ? TODO: Need to add option to 'compress' the output location data.
This commit is contained in:
parent
98c426d61a
commit
4af94fb2e4
@ -365,24 +365,12 @@ class SendMessageNamespace(Namespace):
|
|||||||
LOG.debug(f"Lat DDM {lat}")
|
LOG.debug(f"Lat DDM {lat}")
|
||||||
LOG.debug(f"Long DDM {long}")
|
LOG.debug(f"Long DDM {long}")
|
||||||
|
|
||||||
local_datetime = datetime.datetime.now()
|
|
||||||
utc_offset_timedelta = datetime.datetime.utcnow() - local_datetime
|
|
||||||
result_utc_datetime = local_datetime + utc_offset_timedelta
|
|
||||||
time_zulu = result_utc_datetime.strftime("%d%H%M")
|
|
||||||
|
|
||||||
# now construct a beacon to send over the client connection
|
|
||||||
txt = (
|
|
||||||
f"{self._config['aprs']['login']}>APZ100,WIDE2-1"
|
|
||||||
f":@{time_zulu}z{lat}/{long}l APRSD WebChat Beacon"
|
|
||||||
)
|
|
||||||
|
|
||||||
LOG.debug(f"Sending {txt}")
|
|
||||||
beacon = packets.GPSPacket(
|
beacon = packets.GPSPacket(
|
||||||
from_call=self._config["aprs"]["login"],
|
from_call=self._config["aprs"]["login"],
|
||||||
to_call="APDW16",
|
to_call="APDW16",
|
||||||
raw=txt,
|
|
||||||
latitude=lat,
|
latitude=lat,
|
||||||
longitude=long,
|
longitude=long,
|
||||||
|
comment="APRSD WebChat Beacon",
|
||||||
)
|
)
|
||||||
beacon.send_direct()
|
beacon.send_direct()
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import abc
|
import abc
|
||||||
from dataclasses import asdict, dataclass, field
|
from dataclasses import asdict, dataclass, field
|
||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
@ -220,7 +221,6 @@ class MessagePacket(PathPacket):
|
|||||||
@dataclass()
|
@dataclass()
|
||||||
class StatusPacket(PathPacket):
|
class StatusPacket(PathPacket):
|
||||||
status: str = None
|
status: str = None
|
||||||
timestamp: int = 0
|
|
||||||
messagecapable: bool = False
|
messagecapable: bool = False
|
||||||
comment: str = None
|
comment: str = None
|
||||||
|
|
||||||
@ -235,15 +235,35 @@ class GPSPacket(PathPacket):
|
|||||||
altitude: float = 0.00
|
altitude: float = 0.00
|
||||||
rng: float = 0.00
|
rng: float = 0.00
|
||||||
posambiguity: int = 0
|
posambiguity: int = 0
|
||||||
timestamp: int = 0
|
|
||||||
comment: str = None
|
comment: str = None
|
||||||
symbol: str = None
|
symbol: str = field(default="l")
|
||||||
symbol_table: str = None
|
symbol_table: str = field(default="/")
|
||||||
speed: float = 0.00
|
speed: float = 0.00
|
||||||
course: int = 0
|
course: int = 0
|
||||||
|
|
||||||
|
def _build_time_zulu(self):
|
||||||
|
"""Build the timestamp in UTC/zulu."""
|
||||||
|
if self.timestamp:
|
||||||
|
local_dt = datetime.datetime.fromtimestamp(self.timestamp)
|
||||||
|
else:
|
||||||
|
local_dt = datetime.datetime.now()
|
||||||
|
self.timestamp = datetime.datetime.timestamp(local_dt)
|
||||||
|
|
||||||
|
utc_offset_timedelta = datetime.datetime.utcnow() - local_dt
|
||||||
|
result_utc_datetime = local_dt + utc_offset_timedelta
|
||||||
|
time_zulu = result_utc_datetime.strftime("%d%H%M")
|
||||||
|
return time_zulu
|
||||||
|
|
||||||
def _build_raw(self):
|
def _build_raw(self):
|
||||||
raise NotImplementedError
|
time_zulu = self._build_time_zulu()
|
||||||
|
|
||||||
|
self.raw = (
|
||||||
|
f"{self.from_call}>{self.to_call},WIDE2-1:"
|
||||||
|
f"@{time_zulu}z{self.latitude}{self.symbol_table}"
|
||||||
|
f"{self.longitude}{self.symbol}"
|
||||||
|
)
|
||||||
|
if self.comment:
|
||||||
|
self.raw = f"{self.raw}{self.comment}"
|
||||||
|
|
||||||
|
|
||||||
@dataclass()
|
@dataclass()
|
||||||
|
Loading…
Reference in New Issue
Block a user