1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-06-25 05:25:21 -04:00

Fix packets timestamp to int

Python's default timestamp is a float.
APRS packet expect to have an old style unix integer
timestamp.
This commit is contained in:
Hemna 2022-12-16 15:54:40 -05:00
parent 6030cb394b
commit f1de7bc681

View File

@ -26,6 +26,11 @@ PACKET_TYPE_BEACON = "beacon"
PACKET_TYPE_UNCOMPRESSED = "uncompressed" PACKET_TYPE_UNCOMPRESSED = "uncompressed"
def _int_timestamp():
"""Build a unix style timestamp integer"""
return int(round(time.time()))
@dataclass() @dataclass()
class Packet(metaclass=abc.ABCMeta): class Packet(metaclass=abc.ABCMeta):
from_call: str from_call: str
@ -34,7 +39,7 @@ class Packet(metaclass=abc.ABCMeta):
format: str = None format: str = None
msgNo: str = None # noqa: N815 msgNo: str = None # noqa: N815
packet_type: str = None packet_type: str = None
timestamp: float = field(default_factory=time.time) timestamp: float = field(default_factory=_int_timestamp)
raw: str = None raw: str = None
_raw_dict: dict = field(repr=False, default_factory=lambda: {}) _raw_dict: dict = field(repr=False, default_factory=lambda: {})
_retry_count = 3 _retry_count = 3