-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
spartn_ntrip_client.py
85 lines (64 loc) · 2.24 KB
/
spartn_ntrip_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
spartn_ntrip_client.py
Illustration of SPARTN NTRIP Client using GNSSNTRIPClient
class from pygnssutils library. Can be used with the
u-blox Thingstream PointPerfect NTRIP service.
The contents of the output file can be decoded using the
spartn_decrypt.py example.
NB: requires a valid userid and password. These can be set as
environment variables PYGPSCLIENT_USER and PYGPSCLIENT_PASSWORD,
or passed as keyword arguments user and password.
At time of writing the PointPerfect NTRIP service is unencrypted
(eaf=0), so no key or basedate is required to decode the messages.
Usage:
python3 spartn_ntrip_client.py user="youruser" password="yourpassword" mountpoint="EU" outfile="spartnntrip.log"
Run from /examples folder.
Created on 12 Feb 2023
:author: semuadmin
:copyright: SEMU Consulting © 2023
:license: BSD 3-Clause
"""
from os import path, getenv
from sys import argv
from time import sleep
from datetime import datetime, timezone
from pygnssutils import GNSSNTRIPClient
SERVER = "ppntrip.services.u-blox.com"
PORT = 2102
HTTPS = 1
def main(**kwargs):
"""
Main routine.
"""
user = kwargs.get("user", getenv("PYGPSCLIENT_USER", "user"))
password = kwargs.get("password", getenv("PYGPSCLIENT_PASSWORD", "password"))
decode = int(kwargs.get("decode", 0))
key = kwargs.get("key", getenv("MQTTKEY", None))
mountpoint = kwargs.get("mountpoint", "EU")
outfile = kwargs.get("outfile", "spartnntrip.log")
with open(outfile, "wb") as out:
gnc = GNSSNTRIPClient()
print(
f"SPARTN NTRIP Client started, writing output to {outfile}... Press CTRL-C to terminate."
)
gnc.run(
server=SERVER,
port=PORT,
https=HTTPS,
mountpoint=mountpoint,
datatype="SPARTN",
ntripuser=user,
ntrippassword=password,
ggainterval=-1,
spartndecode=decode,
spartnkey=key,
spartnbasedate=datetime.now(timezone.utc),
output=out,
)
try:
while True:
sleep(3)
except KeyboardInterrupt:
print("SPARTN NTRIP Client terminated by User")
if __name__ == "__main__":
main(**dict(arg.split("=") for arg in argv[1:]))