Skip to content

Commit

Permalink
Merge pull request #65 from semuconsulting/RC-1.0.26
Browse files Browse the repository at this point in the history
update spartn decryption arg names
  • Loading branch information
semuadmin committed May 1, 2024
2 parents 1d84afe + 1a524f6 commit 560e599
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"editor.formatOnSave": true,
"python3.8InterpreterPath": "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8",
"modulename": "${workspaceFolderBasename}",
"distname": "${workspaceFolderBasename}",
"moduleversion": "1.0.25"
"moduleversion": "1.0.26"
}
10 changes: 10 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@
],
"problemMatcher": []
},
{
"label": "Test3.8",
"type": "process",
"command": "${config:python3.8InterpreterPath}",
"args": [
"-m",
"pytest",
],
"problemMatcher": []
},
{
"label": "Sphinx",
"type": "process",
Expand Down
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# pygnssutils Release Notes

### RELEASE 1.0.26

FIXES:

1. Update SPARTN decryption argument names - Fixes no `decode` setting error.

### RELEASE 1.0.25

ENHANCEMENTS:
Expand Down
12 changes: 6 additions & 6 deletions examples/gnssmqttclient_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
:license: BSD 3-Clause
"""

from datetime import datetime
from datetime import datetime, timezone
from os import getenv, path
from pathlib import Path
from sys import argv
Expand All @@ -38,8 +38,8 @@ def main(**kwargs):
clientid = kwargs.get("clientid", getenv("MQTTCLIENTID", default="enter-client-id"))
outfile = kwargs.get("outfile", None)
decode = kwargs.get("decode", 0)
decryptkey = kwargs.get("decryptkey", getenv("MQTTKEY", default=None))
decryptbasedate = kwargs.get("decryptbasedate", datetime.now())
key = kwargs.get("key", getenv("MQTTKEY", default=None))
basedate = kwargs.get("basedate", datetime.now(timezone.utc))
stream = None

if outfile is not None:
Expand All @@ -56,9 +56,9 @@ def main(**kwargs):
"topic_ip": 1, # SPARTN correction data (SPARTN OCB, HPAC & GAD messages)
"topic_mga": 0, # Assist Now ephemera data (UBX MGA-EPH-* messages)
"topic_key": 0, # SPARTN decryption keys (UBX RXM_SPARTNKEY messages)
"decode": decode,
"decryptkey": decryptkey,
"decryptbasedate": decryptbasedate,
"spartndecode": decode,
"spartnkey": key,
"spartnbasedate": basedate,
"output": stream,
"errevent": Event(),
}
Expand Down
29 changes: 14 additions & 15 deletions examples/spartn_mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class from pygnssutils library. Can be used with the
Usage:
python3 spartn_mqtt_client.py clientid="abcd1234-abcd-efgh-4321-1234567890ab" outfile="spartnmqtt.log"
python3 spartn_mqtt_client.py clientid="abcd1234-abcd-efgh-4321-1234567890ab" region="eu" decode=1 key="abcdef1234567890abcdef1234567890" outfile="spartnmqtt.log"
Run from /examples folder.
Expand All @@ -27,7 +27,7 @@ class from pygnssutils library. Can be used with the
:license: BSD 3-Clause
"""

from datetime import datetime, UTC
from datetime import datetime, timezone
from os import path, getenv
from pathlib import Path
from sys import argv
Expand All @@ -38,8 +38,6 @@ class from pygnssutils library. Can be used with the

SERVER = "pp.services.u-blox.com"
PORT = 8883
REGION = "eu" # amend to your region
DECODE = 0


def main(**kwargs):
Expand All @@ -48,28 +46,29 @@ def main(**kwargs):
"""

clientid = kwargs.get("clientid", getenv("MQTTCLIENTID", ""))
region = kwargs.get("region", "eu")
decode = int(kwargs.get("decode", 0))
key = kwargs.get("key", getenv("MQTTKEY", None))
outfile = kwargs.get("outfile", "spartnmqtt.log")

with open(outfile, "wb") as out:
gmc = GNSSMQTTClient()

print(
f"SPARTN MQTT Client started, writing output to {outfile}... Press CTRL-C to terminate."
)
print(f"SPARTN MQTT Client started, writing output to {outfile}...")
gmc.start(
server=SERVER,
port=PORT,
clientid=clientid,
tlscrt=path.join(Path.home(), f"device-{clientid}-pp-cert.crt"),
tlskey=path.join(Path.home(), f"device-{clientid}-pp-key.pem"),
region=REGION,
region=region,
mode=0,
topic_ip=1, # SPARTN data
topic_mga=0, # UBX MGA data
topic_key=0, # UBX RXM-SPARTNKEY data
decode=DECODE,
decryptkey=getenv("MQTTKEY", default=None),
decryptbasedate=datetime.now(UTC),
topic_ip=1, # SPARTN correction data (SPARTN OCB, HPAC & GAD messages)
topic_mga=0, # Assist Now ephemera data (UBX MGA-EPH-* messages)
topic_key=0, # SPARTN decryption keys (UBX RXM_SPARTNKEY messages)
spartndecode=decode,
spartnkey=key,
spartnbasedate=datetime.now(timezone.utc),
output=out,
)

Expand All @@ -80,7 +79,7 @@ def main(**kwargs):
print("SPARTN MQTT Client terminated by User")
print(
f"To decrypt the contents of the output file {outfile} using pyspartn,",
f"use kwargs: decode=True, key=key_supplied_by_service_provider, basedate={repr(datetime.now(UTC))}",
f"use kwargs: decode=True, key=key_supplied_by_service_provider, basedate={repr(datetime.now(timezone.utc))}",
)


Expand Down
8 changes: 7 additions & 1 deletion examples/spartn_ntrip_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class from pygnssutils library. Can be used with the
:license: BSD 3-Clause
"""

from os import getenv
from os import path, getenv
from sys import argv
from time import sleep
from datetime import datetime, timezone

from pygnssutils import GNSSNTRIPClient

Expand All @@ -46,6 +47,8 @@ def main(**kwargs):

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")

Expand All @@ -64,6 +67,9 @@ def main(**kwargs):
ntripuser=user,
ntrippassword=password,
ggainterval=-1,
spartndecode=decode,
spartnkey=key,
spartnbasedate=datetime.now(timezone.utc),
output=out,
)

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pygnssutils"
authors = [{ name = "semuadmin", email = "[email protected]" }]
maintainers = [{ name = "semuadmin", email = "[email protected]" }]
description = "GNSS Command Line Utilities"
version = "1.0.25"
version = "1.0.26"
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.8"
Expand Down Expand Up @@ -37,7 +37,7 @@ dependencies = [
"certifi>=2024.0.0",
"paho-mqtt>=1.6.0",
"pyserial>=3.5",
"pyspartn>=0.3.3",
"pyspartn>=0.4.0",
"pyubx2>=1.2.39",
]

Expand Down
2 changes: 1 addition & 1 deletion src/pygnssutils/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:license: BSD 3-Clause
"""

__version__ = "1.0.25"
__version__ = "1.0.26"
28 changes: 14 additions & 14 deletions src/pygnssutils/gnssmqttclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import socket
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from datetime import datetime
from datetime import datetime, timezone
from io import BufferedWriter, BytesIO, TextIOWrapper
from os import getenv, path
from pathlib import Path
Expand Down Expand Up @@ -94,9 +94,9 @@ def __init__(self, app=None, **kwargs):
"topic_key": 1,
"tlscrt": path.join(Path.home(), f"device-{clientid}-pp-cert.crt"),
"tlskey": path.join(Path.home(), f"device-{clientid}-pp-key.pem"),
"decode": 0,
"decryptkey": getenv("MQTTKEY", default=None),
"decryptbasedate": datetime.now(),
"spartndecode": 0,
"spartnkey": getenv("MQTTKEY", default=None),
"spartnbasedate": datetime.now(timezone.utc),
"output": None,
}

Expand Down Expand Up @@ -174,9 +174,9 @@ def start(self, **kwargs) -> int:
"topic_key",
"tlscrt",
"tlskey",
"decode",
"decryptkey",
"decryptbasedate",
"spartndecode",
"spartnkey",
"spartnbasedate",
"output",
]:
if kwarg in kwargs:
Expand Down Expand Up @@ -257,9 +257,9 @@ def _run(
"output": settings["output"],
"topics": topics,
"app": app,
"decode": settings["decode"],
"key": settings["decryptkey"],
"basedate": settings["decryptbasedate"],
"decode": settings["spartndecode"],
"key": settings["spartnkey"],
"basedate": settings["spartnbasedate"],
}

try:
Expand Down Expand Up @@ -569,24 +569,24 @@ def main():
default=path.join(Path.home(), f"device-{clientid}-pp-key.pem"),
)
ap.add_argument(
"--decode",
"--spartndecode",
required=False,
help="Decode payload?",
type=int,
choices=[0, 1],
default=0,
)
ap.add_argument(
"--decryptkey",
"--spartnkey",
required=False,
help="Decryption key for encrypted payloads",
default=getenv("MQTTKEY", default=None),
)
ap.add_argument(
"--decryptbasedate",
"--spartnbasedate",
required=False,
help="Decryption basedate for encrypted payloads",
default=datetime.now(),
default=datetime.now(timezone.utc),
)
ap.add_argument(
"--output",
Expand Down
Loading

0 comments on commit 560e599

Please sign in to comment.