mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-20 16:41:13 -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
1b49f128a9
commit
59e5af8ee5
@ -365,24 +365,12 @@ class SendMessageNamespace(Namespace):
|
||||
LOG.debug(f"Lat DDM {lat}")
|
||||
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(
|
||||
from_call=self._config["aprs"]["login"],
|
||||
to_call="APDW16",
|
||||
raw=txt,
|
||||
latitude=lat,
|
||||
longitude=long,
|
||||
comment="APRSD WebChat Beacon",
|
||||
)
|
||||
beacon.send_direct()
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import abc
|
||||
from dataclasses import asdict, dataclass, field
|
||||
import datetime
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
@ -220,7 +221,6 @@ class MessagePacket(PathPacket):
|
||||
@dataclass()
|
||||
class StatusPacket(PathPacket):
|
||||
status: str = None
|
||||
timestamp: int = 0
|
||||
messagecapable: bool = False
|
||||
comment: str = None
|
||||
|
||||
@ -235,15 +235,35 @@ class GPSPacket(PathPacket):
|
||||
altitude: float = 0.00
|
||||
rng: float = 0.00
|
||||
posambiguity: int = 0
|
||||
timestamp: int = 0
|
||||
comment: str = None
|
||||
symbol: str = None
|
||||
symbol_table: str = None
|
||||
symbol: str = field(default="l")
|
||||
symbol_table: str = field(default="/")
|
||||
speed: float = 0.00
|
||||
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):
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user