Skip to content

Commit

Permalink
Use timestamp from APRS server (fixes #85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meisterschueler committed Jun 12, 2021
1 parent 7eacc96 commit e58c1d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## unreleased
- client: If no reference_timestamp provided use timestamp from APRS server (fixes #85)

## 1.2.1: - 2021-06-06
- client: Added peer IP to log messages
- parser: Added rainfall_1h and rainfall_24h to beacon_type 'position_weather'
Expand Down
13 changes: 10 additions & 3 deletions ogn/parser/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@
from ogn.parser.aprs_comment.generic_parser import GenericParser

positions = {}
server_timestamp = None


def parse(aprs_message, reference_timestamp=None, calculate_relations=False):
def parse(aprs_message, reference_timestamp=None, calculate_relations=False, use_server_timestamp=True):
global positions
global server_timestamp

if reference_timestamp is None:
if use_server_timestamp is True:
reference_timestamp = server_timestamp or datetime.utcnow()
elif reference_timestamp is None:
reference_timestamp = datetime.utcnow()

message = parse_aprs(aprs_message, reference_timestamp)
message = parse_aprs(aprs_message, reference_timestamp=reference_timestamp)
if message['aprs_type'] == 'position' or message['aprs_type'] == 'status':
message.update(parse_comment(message['comment'],
dstcall=message['dstcall'],
Expand All @@ -42,6 +46,9 @@ def parse(aprs_message, reference_timestamp=None, calculate_relations=False):
message['bearing'] = cheap_ruler.bearing((message['longitude'], message['latitude']), positions[message['receiver_name']])
message['normalized_quality'] = normalized_quality(message['distance'], message['signal_quality']) if 'signal_quality' in message else None

if message['aprs_type'] == 'server':
server_timestamp = message['timestamp']

return message


Expand Down

0 comments on commit e58c1d8

Please sign in to comment.