From 397640208e88a8ed56edf4a7e48df3e6580b372f Mon Sep 17 00:00:00 2001 From: semuadmin <28569967+semuadmin@users.noreply.github.com> Date: Thu, 2 May 2024 19:35:57 +0100 Subject: [PATCH] update readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 88ebe87..76e5443 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ for (raw_data, parsed_data) in spr: #### Encrypted Payloads -Some proprietary SPARTN message sources (e.g. Thingstream PointPerfect © MQTT) use encrypted payloads (`eaf=1`). In order to decrypt and decode these payloads, the user must set `decode=1` and provide a valid decryption `key`. Keys are typically 32-character hexadecimal strings valid for a 4 week period. If the datastream contains messages with ambiguous 16-bit gnssTimetags (`timeTagtype=0`) - which generally includes all GAD messages and some OCB messages - a nominal `basedate` is also required, representing the date on which the datastream was originally created to the nearest half day. If you're parsing data in real time, this can be left at the default `datetime.now(timezone.utc)`. If you're parsing historical data, you will need to provide a basedate representing the date on which the datastream was originally created to the nearest half day. See examples below. +Some proprietary SPARTN message sources (e.g. Thingstream PointPerfect © MQTT) use encrypted payloads (`eaf=1`). In order to decrypt and decode these payloads, the user must set `decode=1` and provide a valid decryption `key`. Keys are typically 32-character hexadecimal strings valid for a 4 week period. If the datastream contains messages with ambiguous 16-bit gnssTimetags (`timeTagtype=0`) - which generally includes all GAD messages and some OCB messages - a nominal `basedate` is also required, representing the UTC datetime on which the datastream was originally created to the nearest half day. If you're parsing data in real time, this can be left at the default `datetime.now(timezone.utc)`. If you're parsing historical data, you will need to provide a basedate representing the UTC datetime on which the datastream was originally created to the nearest half day. See examples below. The current decryption key can also be set via environment variable `MQTTKEY`, but bear in mind this will need amending every 4 weeks. @@ -155,10 +155,10 @@ for (raw_data, parsed_data) in spr: Example - Historical file input with decryption. ```python -from datetime import datetime +from datetime import datetime, timezone from pyspartn import SPARTNReader stream = open('spartndata.log', 'rb') -spr = SPARTNReader(stream, decode=1, key="930d847b779b126863c8b3b2766ae7cc", basedate=datetime(2023, 4, 18, 20, 48, 29, 977255)) +spr = SPARTNReader(stream, decode=1, key="930d847b779b126863c8b3b2766ae7cc", basedate=datetime(2023, 4, 18, 20, 48, 29, 977255, tzinfo=timezone.utc)) for (raw_data, parsed_data) in spr: print(parsed_data) ``` @@ -166,7 +166,7 @@ for (raw_data, parsed_data) in spr: --- ## Parsing -You can parse individual SPARTN messages using the static `SPARTNReader.parse(data)` function, which takes a bytes array containing a binary SPARTN message and returns a `SPARTNMessage` object. If the message payload is encrypted (`eaf=1`), a decryption `key` and `basedate` must be provided. See examples below. +You can parse individual SPARTN messages using the static `SPARTNReader.parse(data)` function, which takes a bytes array containing a binary SPARTN message and returns a `SPARTNMessage` object. If the message payload is encrypted (`eaf=1`), a decryption `key` and UTC `basedate` must be provided. See examples below. **NB:** Once instantiated, a `SPARTNMMessage` object is immutable. @@ -194,7 +194,7 @@ msg = SPARTNReader.parse( transport, decode=1, key="6b30302427df05b4d98911ebff3a4d95", - basedate=datetime(2023, 6, 27, 22, 3, 0), + basedate=datetime(2023, 6, 27, 22, 3, 0, tzinfo=timezone.utc), ) print(msg) ``` @@ -207,7 +207,7 @@ The `SPARTNMessage` object exposes different public attributes depending on its ```python from datetime import datetime from pyspartn import SPARTNReader, datadesc -msg = SPARTNReader.parse(b"s\x02\xf7\xeb\x08\xd7!\xef\x80[\x17\x88\xc2?\x0f\x ... \xc4#fFy\xb9\xd5", decode=True, key="930d847b779b126863c8b3b2766ae7cc", basedate=datetime(2024, 4, 18, 20, 48, 29, 977255)) +msg = SPARTNReader.parse(b"s\x02\xf7\xeb\x08\xd7!\xef\x80[\x17\x88\xc2?\x0f\x ... \xc4#fFy\xb9\xd5", decode=True, key="930d847b779b126863c8b3b2766ae7cc", basedate=datetime(2024, 4, 18, 20, 48, 29, 977255, tzinfo=timezone.utc)) print(msg) print(msg.identity) print(msg.gnssTimeTag)