Skip to content

Commit

Permalink
create location entry
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Aug 23, 2023
1 parent 8b5c9f6 commit ee065a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions services/telit/zero_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,32 @@ def main():
if not ping(args.check_ip):
lte_config(args)
gps_config(args)
next_tpv = None
with GPSDClient(host="127.0.0.1") as gpsd_client:
while args.running:
try:
if time.time() >= last_push + args.push_interval:
# Get gps position
document = {"date": epoch_to_elasticsearch_date(
time.time())}
if next_tpv:
document["TPV"] = next_tpv
next_tpv = None
for result in gpsd_client.dict_stream(
convert_datetime=False,
filter=["TPV", "Sky", "GST", "Att", "Imu",
"Toff", "PPS", "Osc"]):
if result["class"] == "TPV" and "TPV" in \
document.keys():
next_tpv = result
break
document[result["class"]] = result
# Read stuff from telit
if "TPV" in document.keys() and "lat" in document["TPV"].keys():
# create special entry specifically for elastic search
document["location"] = {"lat": document["TPV"]["lat"],
"lon": document["TPV"]["lat"],
"z": document["TPV"]["alt"]}
try:
with serial.Serial('/dev/ttyUSB2', 115200,
timeout=5) as ser:
Expand Down

0 comments on commit ee065a0

Please sign in to comment.