From 09b3cf93ca1c49adce3c967058cd8012161b39d2 Mon Sep 17 00:00:00 2001 From: Matthieu Verdy Date: Fri, 9 Oct 2020 17:07:30 +0200 Subject: [PATCH] Release v1.4.0 --- embedded/application/inc/version.h | 2 +- host/README.md | 13 +- .../NavParser/__main__.py | 23 --- .../NavParser/navParser/__init__.py | 21 --- .../NavParser/navParser/core/satelliteInfo.py | 69 --------- .../navParser/core/satelliteResults.py | 141 ------------------ .../lr1110_nav_message_parser_py/changelog.md | 36 ----- .../lr1110_nav_message_parser_py/setup.py | 19 --- host/lr1110evk/AppConfiguration.py | 2 +- .../Core/GeoLocServiceClientBase.py | 76 +++------- .../lr1110evk/FieldTestPost/Core/Geocoding.py | 6 +- .../FieldTestPost/Core/RequestBase.py | 71 +-------- .../FieldTestPost/Core/RequestSender.py | 12 +- host/lr1110evk/FieldTestPost/Core/__init__.py | 2 +- host/lr1110evk/FieldTestPost/__main__.py | 4 - host/lr1110evk/Job/KmlExport.py | 11 +- .../NavParserFile/FileNavMessageParser.py | 2 +- host/lr1110evk/NavParserFile/__init__.py | 6 + host/lr1110evk/NavParserFile/__main__.py | 2 +- .../navParser}/NavMessageParser.py | 10 +- .../NavParserFile/navParser}/__init__.py | 17 ++- .../baseTypes/IdentifiableElement.py | 7 +- .../navParser/baseTypes/__init__.py | 3 +- .../navParser/baseTypes/exceptions.py | 0 .../navParser/baseTypes/navMessage.py | 16 +- .../NavParserFile}/navParser/core/__init__.py | 2 +- .../navParser/core/cnGetterFromNav.py | 24 +++ .../navParser/core/constellationResults.py | 8 +- .../navParser/core/getterFromId.py | 3 +- .../navParser/core/navMessageConsumer.py | 0 .../navParser/core/satelliteResults.py | 45 ++++++ .../NavParserFile}/navParser/navParser.py | 14 -- .../lr1110evk/SerialExchange/DemoVcpReader.py | 2 +- host/lr1110evk/__main__.py | 4 - host/lr1110evk/main_almanac_update.py | 11 +- host/setup.py | 9 +- 36 files changed, 165 insertions(+), 528 deletions(-) delete mode 100644 host/external_lib/lr1110_nav_message_parser_py/NavParser/__main__.py delete mode 100644 host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/__init__.py delete mode 100644 host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteInfo.py delete mode 100644 host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteResults.py delete mode 100644 host/external_lib/lr1110_nav_message_parser_py/changelog.md delete mode 100644 host/external_lib/lr1110_nav_message_parser_py/setup.py rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile/navParser}/NavMessageParser.py (83%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile/navParser}/__init__.py (61%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/baseTypes/IdentifiableElement.py (95%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/baseTypes/__init__.py (89%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/baseTypes/exceptions.py (100%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/baseTypes/navMessage.py (74%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/core/__init__.py (86%) create mode 100644 host/lr1110evk/NavParserFile/navParser/core/cnGetterFromNav.py rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/core/constellationResults.py (81%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/core/getterFromId.py (97%) rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/core/navMessageConsumer.py (100%) create mode 100644 host/lr1110evk/NavParserFile/navParser/core/satelliteResults.py rename host/{external_lib/lr1110_nav_message_parser_py/NavParser => lr1110evk/NavParserFile}/navParser/navParser.py (89%) diff --git a/embedded/application/inc/version.h b/embedded/application/inc/version.h index 52d57a0..6b89cef 100644 --- a/embedded/application/inc/version.h +++ b/embedded/application/inc/version.h @@ -36,7 +36,7 @@ #ifndef DEMO_VERSION #warning "No demo version provided" -#define DEMO_VERSION "v1.3.1" +#define DEMO_VERSION "v1.4.0" #endif typedef struct diff --git a/host/README.md b/host/README.md index a89a22c..d309cb1 100644 --- a/host/README.md +++ b/host/README.md @@ -31,7 +31,7 @@ $ Lr1110Demo -h A basic usage of the Lr1110Demo is: ```bash -Lr1110Demo -d +Lr1110Demo -d ``` With: @@ -39,27 +39,26 @@ With: - ``: The com port where the LR1110 EVK is connected (something like */dev/ttyACM0* on linux, *COM10* on Windows); - ``: The assistance coordinate provide to the GNSS solver when requesting a location solving. Format is `latitude,longitude,altitude` expressed in decimal degree. Note there are no space characters around the `,` to avoid breaking the command line interpretation; - ``: The exact location where the scan operation occured. The format is the same as ``; -- ``: The authentication token on GLS server; -- ``: The authentication on DAS server. +- ``: The authentication token on GLS server. **NOTE**: If one of the location has a negative latitude, then its value on the command line will starts with a `-` character. It will therefore be interpreted as an optional argument (as for `-d `). Moreover, as it will certainly refers to a non existing optional argument, command line parsing will fail with an error similar to ```bash -$ Lr1110Demo -b COM10 -1.0000,0.0000,0 -1.0000,0.0000,0 +$ Lr1110Demo -b COM10 -1.0000,0.0000,0 -1.0000,0.0000,0 usage: Lr1110Demo [-h] [-s WIFI_SERVER_BASE_URL] [-p WIFI_SERVER_PORT] [-t GNSS_SERVER_BASE_URL] [-q GNSS_SERVER_PORT] [-d DEVICE_ADDRESS] [-b DEVICE_BAUD] [-n] [-l GNSS_ASSISTED_SCAN_APPROXIMATE_LOCALIZATION] [-r] [-F FAKE_DATE] [--verbose] [--version] approximateGnssServerLocalization exactCoordinate - glsAuthenticationToken dasAuthenticationToken -Lr1110Demo: error: the following arguments are required: dasAuthenticationToken + glsAuthenticationToken +Lr1110Demo: error: the following arguments are required: glsAuthenticationToken ``` To avoid the bad interpretation of the coordinate as optional argument, you must use the `--` separator between optional and positional arguments as follows: ```bash -Lr1110Demo -b COM10 -- -1.0000,0.0000,0 -1.0000,0.0000,0 +Lr1110Demo -b COM10 -- -1.0000,0.0000,0 -1.0000,0.0000,0 ``` See guideline 10 of [that reference](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html). \ No newline at end of file diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/__main__.py b/host/external_lib/lr1110_nav_message_parser_py/NavParser/__main__.py deleted file mode 100644 index 84b0d33..0000000 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/__main__.py +++ /dev/null @@ -1,23 +0,0 @@ -from argparse import ArgumentParser -import pkg_resources -from NavParser.NavMessageParser import NavMessageParser -from NavParser.navParser.baseTypes import GnssSolverDestination - - -def entry_point_nav_parser_file(): - version = pkg_resources.get_distribution("NavParser").version - parser = ArgumentParser(description="Parse NAV messages from LR1110") - parser.add_argument("--version", action="version", version=version) - parser.add_argument( - "nav_message", - help="NAV message to interpret", - ) - args = parser.parse_args() - parsed_nav = NavMessageParser.parse(args.nav_message) - if parsed_nav.destination != GnssSolverDestination: - print("The NAV message is not for the solver") - print("Nav Message:\n{}".format(parsed_nav)) - - -if __name__ == '__main__': - entry_point_nav_parser_file() \ No newline at end of file diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/__init__.py b/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/__init__.py deleted file mode 100644 index 7eb7c4a..0000000 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from .core import ( - SatelliteInfo, - SatelliteResults, - ConstellationResults, - NavMessageConsumerBitsExtractionOutOfBound -) -from .baseTypes import ( - GnssDmcDestination, - GnssDmcNavMessage, - GnssSolverDestination, - GnssSolverFrameTypeNav, - GnssSolverFrameTypeNoAssistance, - GnssSolverNavMessage, - GpsModulationType, - CnRangeVeryHigh, - CnRangeHigh, - CnRangeLow, - CnRangeVeryLow -) - -from .navParser import NavParser \ No newline at end of file diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteInfo.py b/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteInfo.py deleted file mode 100644 index 9e064e1..0000000 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteInfo.py +++ /dev/null @@ -1,69 +0,0 @@ -from ..baseTypes import CnRangeVeryHigh, CnRangeHigh, CnRangeLow, CnRangeVeryLow -from .getterFromId import GetterFromId - - -class SatelliteInfo: - def __init__( - self, - timestamp1_exists, - timestamp2_exists, - doppler_exists, - doppler_error, - bit_change_info1, - bit_change_info2, - c_n, - ): - self.__timestamp1_exists = timestamp1_exists - self.__timestamp2_exists = timestamp2_exists - self.__doppler_exists = doppler_exists - self.__doppler_error = doppler_error - self.__bit_change_info1_exists = bit_change_info1 - self.__bit_change_info2_exists = bit_change_info2 - self.__c_n = c_n - - @property - def timestamp1_exists(self): - return self.__timestamp1_exists - - @property - def timestamp2_exists(self): - return self.__timestamp2_exists - - @property - def doppler_exists(self): - return self.__doppler_exists - - @property - def doppler_error(self): - return self.__doppler_error - - @property - def bit_change_info1_exists(self): - return self.__bit_change_info1_exists - - @property - def bit_change_info2_exists(self): - return self.__bit_change_info2_exists - - @property - def c_n(self): - return self.__c_n - - @staticmethod - def from_nav_parser(nav_parser): - c_n = GetterFromId.get_cn_range_from_id(nav_parser.consume_field(2)) - bit_change_info2_exists = bool(nav_parser.consume_field(1) == b"\x01") - bit_change_info1_exists = bool(nav_parser.consume_field(1) == b"\x01") - doppler_error = bool(nav_parser.consume_field(1) == b"\x01") - doppler_exists = bool(nav_parser.consume_field(1) == b"\x01") - timestamp2_exists = bool(nav_parser.consume_field(1) == b"\x01") - timestamp1_exists = bool(nav_parser.consume_field(1) == b"\x01") - return SatelliteInfo( - timestamp1_exists, - timestamp2_exists, - doppler_exists, - doppler_error, - bit_change_info1_exists, - bit_change_info2_exists, - c_n, - ) diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteResults.py b/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteResults.py deleted file mode 100644 index c493cd3..0000000 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/satelliteResults.py +++ /dev/null @@ -1,141 +0,0 @@ -from .satelliteInfo import SatelliteInfo - - -class SatelliteResults: - def __init__( - self, - satellite_id, - status_info, - timestamp1, - timestamp2, - doppler, - bit_change_info1, - bit_change_info2, - ): - self.__satellite_id = satellite_id - self.__status_info = status_info - self.__timestamp1 = timestamp1 - self.__timestamp2 = timestamp2 - self.__doppler = doppler - self.__bit_change_info1 = bit_change_info1 - self.__bit_change_info2 = bit_change_info2 - - @property - def satellite_id(self): - return self.__satellite_id - - @property - def satellite_name(self): - return SatelliteResults.satellite_id_to_name(self.__satellite_id) - - @property - def status_info(self): - return self.__status_info - - @property - def timestamp1(self): - return self.__timestamp1 - - @property - def timestamp2(self): - return self.__timestamp2 - - @property - def doppler(self): - return self.__doppler - - @property - def bit_change_info1(self): - return self.__bit_change_info1 - - @property - def bit_change_info2(self): - return self.__bit_change_info2 - - @staticmethod - def from_nav_consumer(nav_consumer): - satellite_id_raw = int.from_bytes( - nav_consumer.consume_field(7), byteorder="little" - ) - status_info = SatelliteInfo.from_nav_parser(nav_consumer) - - if status_info.timestamp1_exists: - timestamp1_raw = nav_consumer.consume_field(19) - timestamp1 = int.from_bytes(timestamp1_raw, byteorder="little") - else: - timestamp1 = None - if status_info.timestamp2_exists: - timestamp2_raw = nav_consumer.consume_field(19) - timestamp2 = int.from_bytes(timestamp2_raw, byteorder="little") - else: - timestamp2 = None - if status_info.doppler_exists: - doppler_raw = nav_consumer.consume_field(15) - doppler_value = SatelliteResults._doppler_value_from_raw_val(doppler_raw) - else: - doppler_value = None - if status_info.bit_change_info1_exists: - bit_change_info1_raw = nav_consumer.consume_field(8) - else: - bit_change_info1_raw = None - if status_info.bit_change_info2_exists: - bit_change_info2_raw = nav_consumer.consume_field(8) - else: - bit_change_info2_raw = None - - return SatelliteResults( - satellite_id=satellite_id_raw, - status_info=status_info, - timestamp1=timestamp1, - timestamp2=timestamp2, - doppler=doppler_value, - bit_change_info1=bit_change_info1_raw, - bit_change_info2=bit_change_info2_raw, - ) - - @staticmethod - def _doppler_value_from_raw_val(raw_value: bytes): - doppler_value = int.from_bytes(raw_value, byteorder='little') - if doppler_value & 0x4000: - doppler_value |= 0xC000 - doppler_value = int.from_bytes( - doppler_value.to_bytes( - length=2, - byteorder='little' - ), - byteorder='little', - signed=True - ) - return doppler_value - - @staticmethod - def satellite_id_to_name(satellite_id: int): - if 0 <= satellite_id <= 31: - satellite_number = satellite_id + 1 - return f"GPS #{satellite_number}" - elif 64 <= satellite_id <= 100: - satellite_number = satellite_id - 63 - return f"BeiDou #{satellite_number}" - elif 32 <= satellite_id <= 50: - special_sbas_names = { - 34: "AUS-NZ", - 35: "EGNOS", - 38: "EGNOS", - 39: "GAGAN", - 40: "GAGAN", - 41: "MSAS", - 42: "ARTEMIS", - 43: "WAAS", - 44: "GAGAN", - 45: "WAAS", - 48: "EGNOS", - 49: "MSAS", - 50: "WAAS", - } - satellite_number = satellite_id + 88 - return f"SBAS #{satellite_number}" - else: - return f"RFU (sv_id: {satellite_id})" - - def __str__(self): - return f"Sv Id: {self.satellite_id} (C/N: {self.status_info.c_n()}): timestamps {self.timestamp1}/{self.timestamp2}" diff --git a/host/external_lib/lr1110_nav_message_parser_py/changelog.md b/host/external_lib/lr1110_nav_message_parser_py/changelog.md deleted file mode 100644 index 9bd12a6..0000000 --- a/host/external_lib/lr1110_nav_message_parser_py/changelog.md +++ /dev/null @@ -1,36 +0,0 @@ -# Python NAV Message Parser - -## [0.4] 2020-03-23 - -### Changed - -- Renaming to LR1110 -- Determined the human readable value for constellation type instead of keeping raw value -- Sanitize printing of human readable NAV message -- The method `NavMessageParser.get_cn_vs_from_parsed_message` now returns the satellite names instead of the satellite IDs - -### Fixed - -- Handling of negative values when parsing satellite doppler field -- Fix IDs of GNSS and BeiDou modulation types - -## [0.3] 2020-01-28 - -### Changed - -- Add a getter for the gps time indicator member of GNSS solver NAV message - -### Fixed - -- Remove the version field of GNSS solver NAV message -- Change the parsing length of frame type of GNSS solver NAV message from 4 bits to 8 bits - -## [0.2] 2020-01-27 - -### Changed - -- Modify parser to be compliant with NAV parser with Sniff date included - -### Remove - -- Drop support for parsing NAV message without date included \ No newline at end of file diff --git a/host/external_lib/lr1110_nav_message_parser_py/setup.py b/host/external_lib/lr1110_nav_message_parser_py/setup.py deleted file mode 100644 index 3e0ef94..0000000 --- a/host/external_lib/lr1110_nav_message_parser_py/setup.py +++ /dev/null @@ -1,19 +0,0 @@ -from setuptools import setup, find_packages - -PACKAGE_NAME = 'NavParser' - -setup( - name=PACKAGE_NAME, - version_format='{tag}.dev{commitcount}+{gitsha}', - setup_requires=[ - 'setuptools-git-version' - ], - packages=find_packages(), - author="Semtech", - description="Library for parsing NAV messages", - entry_points={ - 'console_scripts': [ - 'NavParser = NavParser.__main__:entry_point_nav_parser_file', - ] - } -) diff --git a/host/lr1110evk/AppConfiguration.py b/host/lr1110evk/AppConfiguration.py index 9998df8..d620061 100644 --- a/host/lr1110evk/AppConfiguration.py +++ b/host/lr1110evk/AppConfiguration.py @@ -31,7 +31,7 @@ def __init__(self): def _set_from_arguments(self, args): self.gnss_server = GeoLocServiceClientGnss.from_token_and_url_info( - args.dasAuthenticationToken, + args.glsAuthenticationToken, args.gnss_server_base_url, args.gnss_server_port, GeoLocServiceClientGnss.get_default_url_version(), diff --git a/host/lr1110evk/FieldTestPost/Core/GeoLocServiceClientBase.py b/host/lr1110evk/FieldTestPost/Core/GeoLocServiceClientBase.py index ef1e46e..507a3a3 100644 --- a/host/lr1110evk/FieldTestPost/Core/GeoLocServiceClientBase.py +++ b/host/lr1110evk/FieldTestPost/Core/GeoLocServiceClientBase.py @@ -163,89 +163,53 @@ def call_service_and_get_response(self, request_data): class GeoLocServiceClientGnss(GeoLocServiceClientBase): - DEFAULT_BASE_URL = "https://das.loracloud.com" - DEFAULT_PATH_URL = "uplink/send" + DEFAULT_BASE_URL = "https://gls.loracloud.com" + DEFAULT_PATH_URL = "solve/gnss_lr1110_singleframe" DEFAULT_PORT = 443 - DEFAULT_COMPATIBLE_VERSION_URL = "v1" + DEFAULT_COMPATIBLE_VERSION_URL = "v3" @staticmethod def build_header_from_authentication_token(authentication_token): return { - "Authorization": authentication_token, + "Ocp-Apim-Subscription-Key": authentication_token, "Content-Type": "application/json", } - def get_first_result(self, response_dict): - RESULT_KEY = "result" - # A result structure can have results for several devices. In the frame of the application - # we assume that there is only one result which is the one we want - all_results_dict = response_dict[RESULT_KEY] - first_result_key = list(all_results_dict.keys())[0] - result_first_device = all_results_dict[first_result_key][RESULT_KEY] - return result_first_device - - def get_log_message_from_result(self, result_device): - LOG_MESSAGE_KEY = "log_messages" - LOG_MESSAGE_KEY_AGAIN = "logmsg" - return result_device[LOG_MESSAGE_KEY][0][LOG_MESSAGE_KEY_AGAIN] + def get_log_message_from_warning(self, response_dict): + LOG_MESSAGE_KEY = "warnings" + return response_dict[LOG_MESSAGE_KEY] def get_log_message_from_error(self, response_dict): + ERROR_MESSAGE_KEY = "errors" + return response_dict[ERROR_MESSAGE_KEY] + + def get_coordinate_accuracy_from_result(self, response_dict): RESULT_KEY = "result" - ERROR_MESSAGE_KEY = "error" - # A result structure can have results for several devices. In the frame of the application - # we assume that there is only one result which is the one we want - all_results_dict = response_dict[RESULT_KEY] - first_error_key = list(all_results_dict.keys())[0] - error_first_device = all_results_dict[first_error_key][ERROR_MESSAGE_KEY] - print(error_first_device) - return error_first_device - - def get_coordinate_accuracy_from_result(self, result_device): - POSITION_SOLUTION_KEY = "position_solution" ACCURACY_KEY = "accuracy" REFERENTIAL_KEY = "llh" - latitude = float(result_device[POSITION_SOLUTION_KEY][REFERENTIAL_KEY][0]) - longitude = float(result_device[POSITION_SOLUTION_KEY][REFERENTIAL_KEY][1]) - altitude = float(result_device[POSITION_SOLUTION_KEY][REFERENTIAL_KEY][2]) + latitude = float(response_dict[RESULT_KEY][REFERENTIAL_KEY][0]) + longitude = float(response_dict[RESULT_KEY][REFERENTIAL_KEY][1]) + altitude = float(response_dict[RESULT_KEY][REFERENTIAL_KEY][2]) coordinate = Coordinate( latitude=latitude, longitude=longitude, altitude=altitude ) - accuracy = float(result_device[POSITION_SOLUTION_KEY][ACCURACY_KEY]) + accuracy = float(response_dict[RESULT_KEY][ACCURACY_KEY]) return coordinate, accuracy def build_response(self, http_code, response_text): response_dict = loads(response_text) - try: - result_first_device = self.get_first_result(response_dict) - except TypeError as err: - if "NoneType" in str(err): - # It is due to the field "position_solution" set to null - failure_text = self.get_log_message_from_result(result_first_device) - response = ResponseFailureBase( - http_code=http_code, - raw_response=response_text, - failure_reason_from_server=failure_text, - ) - return response - raise err - except KeyError: - # It is due to the inexistance of the field result - failure_text = self.get_log_message_from_error(response_dict) - response = ResponseFailureBase( - http_code=http_code, - raw_response=response_text, - failure_reason_from_server=failure_text, - ) - return response try: coordinates, loc_accuracy = self.get_coordinate_accuracy_from_result( - result_first_device + response_dict ) except TypeError as err: if "NoneType" in str(err): - failure_text = self.get_log_message_from_result(result_first_device) + failure_text = "errors: {}, warnings: {}".format( + self.get_log_message_from_error(response_dict), + self.get_log_message_from_warning(response_dict), + ) response = ResponseFailureBase( http_code=http_code, raw_response=response_text, diff --git a/host/lr1110evk/FieldTestPost/Core/Geocoding.py b/host/lr1110evk/FieldTestPost/Core/Geocoding.py index 25441b6..9a4a992 100644 --- a/host/lr1110evk/FieldTestPost/Core/Geocoding.py +++ b/host/lr1110evk/FieldTestPost/Core/Geocoding.py @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -from yaml import load_all +from yaml import load_all, SafeLoader from pkg_resources import resource_string from unicodedata import normalize @@ -49,7 +49,9 @@ def __init__(self): self.name_aliases = None def load_names_aliases(self): - self.name_aliases = [doc for doc in load_all(self.geo_coding_file)] + self.name_aliases = [ + doc for doc in load_all(self.geo_coding_file, Loader=SafeLoader) + ] def build_data(self, osm_json): road = GeocodingBuilder.extract_from_name_or_none( diff --git a/host/lr1110evk/FieldTestPost/Core/RequestBase.py b/host/lr1110evk/FieldTestPost/Core/RequestBase.py index 5f29744..bc1e5e8 100644 --- a/host/lr1110evk/FieldTestPost/Core/RequestBase.py +++ b/host/lr1110evk/FieldTestPost/Core/RequestBase.py @@ -43,11 +43,10 @@ def __str__(self): return self.to_json() -class GnssRequestUplink: - def __init__(self, payload, timestamp, message_type, aiding_coordinate): +class RequestGnssGls(RequestBase): + def __init__(self, payload, timestamp, aiding_coordinate): self.__payload = payload self.__timestamp = timestamp - self.__message_type = message_type self.__aiding_coordinate = aiding_coordinate @property @@ -58,22 +57,18 @@ def payload(self): def timestamp(self): return self.__timestamp - @property - def message_type(self): - return self.__message_type - @property def aiding_coordinate(self): return self.__aiding_coordinate - def to_json_dict(self): + def _to_json_dict(self): json_dict = { "payload": self.payload[ 2: - ], # The very first byte is removed here. "Why?"" I heard you asked. "Because" is my answer. - "timestamp": self.timestamp, - "msgtype": self.message_type, - "gnss_capture_time": self.timestamp + 18 - 315964800, + ], # The very first byte (destinationID) is removed here as it should not be sent to the solver + "gnss_capture_time": self.timestamp.replace(tzinfo=timezone.utc).timestamp() + + 18 + - 315964800, # "capture_time_accuracy": 120, } if self.aiding_coordinate: @@ -85,58 +80,6 @@ def to_json_dict(self): return json_dict -class GnssRequestFakeUplink(GnssRequestUplink): - FAKE_MESSAGE_TYPE = "gnss" - - def __init__(self, payload, timestamp, aiding_coordinate): - super().__init__( - payload=payload, - timestamp=timestamp.replace(tzinfo=timezone.utc).timestamp(), - message_type=GnssRequestFakeUplink.FAKE_MESSAGE_TYPE, - aiding_coordinate=aiding_coordinate, - ) - - -class RequestGnssPerDevice(RequestBase): - def __init__(self): - self.__request_mapping = dict() - - def append_device_request(self, dev_eui, uplink_request): - self.__request_mapping[dev_eui] = uplink_request - - def _to_json_dict(self): - json_dict = { - dev_eui: request_uplink.to_json_dict() - for dev_eui, request_uplink in self.__request_mapping.items() - } - return json_dict - - -import random - - -class RequestGnssPerDeviceFake(RequestGnssPerDevice): - @staticmethod - def generate_random_device_eui(): - def get_random_hex(): - return random.randint(0, 255) - - return "AA-AA-AA-00-00-{:02X}-{:02X}-{:02X}".format( - get_random_hex(), get_random_hex(), get_random_hex() - ) - - def append_device(self, nav_message, capture_instant, aiding_coordinate): - fake_uplink_request = GnssRequestFakeUplink( - payload=nav_message, - timestamp=capture_instant, - aiding_coordinate=aiding_coordinate, - ) - fake_deveui = RequestGnssPerDeviceFake.generate_random_device_eui() - super().append_device_request( - dev_eui=fake_deveui, uplink_request=fake_uplink_request - ) - - class RequestWifiGls(RequestBase): def __init__(self): self.macs = list() diff --git a/host/lr1110evk/FieldTestPost/Core/RequestSender.py b/host/lr1110evk/FieldTestPost/Core/RequestSender.py index b12fb99..396eed0 100644 --- a/host/lr1110evk/FieldTestPost/Core/RequestSender.py +++ b/host/lr1110evk/FieldTestPost/Core/RequestSender.py @@ -29,7 +29,7 @@ from lr1110evk.BaseTypes import ScannedMacAddress, ScannedGnss from .FileReader import FileReader -from .RequestBase import RequestWifiGls, RequestGnssPerDevice, GnssRequestFakeUplink +from .RequestBase import RequestWifiGls, RequestGnssGls from .ResponseBase import ResponseBase from .ExternalCoordinate import ExternalCoordinate from .GeoLocServiceClientBase import GeoLocServiceBadResponseStatus @@ -82,12 +82,12 @@ class RequestSender: def __init__(self, configuration): self.configuration = configuration self.TYPE_REQUEST_MAPPER = { - ScannedGnss: self.build_gnss_request_per_device, + ScannedGnss: self.build_gnss_requests, ScannedMacAddress: self.build_wifi_requests, } self.GEOLOC_SERVICE_MAPPER = { RequestWifiGls: self.configuration.wifi_server, - RequestGnssPerDevice: self.configuration.gnss_server, + RequestGnssGls: self.configuration.gnss_server, } self.device_eui = None @@ -99,7 +99,7 @@ def build_wifi_requests(self, mac_addresses): request.macs = wifi_data return request - def build_gnss_request_per_device(self, gnss_scan): + def build_gnss_requests(self, gnss_scan): gnss_data = [data for data in gnss_scan if isinstance(data, ScannedGnss)] if len(gnss_data) > 1: raise TooManyNavMessagesException(gnss_data) @@ -107,13 +107,11 @@ def build_gnss_request_per_device(self, gnss_scan): raise NoNavMessageException() gnss_data = gnss_data[0] utc_time = gnss_data.instant_scan - request = RequestGnssPerDevice() - up_link_request = GnssRequestFakeUplink( + request = RequestGnssGls( payload=gnss_data.nav_message, timestamp=utc_time, aiding_coordinate=self.configuration.approximate_gnss_server_localization, ) - request.append_device_request(self.device_eui, up_link_request) return request def get_geo_loc_service_for_request(self, request): diff --git a/host/lr1110evk/FieldTestPost/Core/__init__.py b/host/lr1110evk/FieldTestPost/Core/__init__.py index ff5c847..45bc3ca 100644 --- a/host/lr1110evk/FieldTestPost/Core/__init__.py +++ b/host/lr1110evk/FieldTestPost/Core/__init__.py @@ -17,4 +17,4 @@ ResponseBase, ResponseBaseException, ) -from .RequestBase import RequestGnssPerDeviceFake, RequestWifiGls +from .RequestBase import RequestGnssGls, RequestWifiGls diff --git a/host/lr1110evk/FieldTestPost/__main__.py b/host/lr1110evk/FieldTestPost/__main__.py index a076eea..840fa5c 100644 --- a/host/lr1110evk/FieldTestPost/__main__.py +++ b/host/lr1110evk/FieldTestPost/__main__.py @@ -115,10 +115,6 @@ def post_analyzis_fetch_results(): "glsAuthenticationToken", help="HTTP header token to authenticate the Wi-Fi requests on LoRa Cloud Geolocation (GLS) server", ) - parser.add_argument( - "dasAuthenticationToken", - help="HTTP header token to authenticate the GNSS requests on LoRa Cloud Device and Application Services (DAS) server", - ) parser.add_argument( "-s", "--wifi-server-base-url", diff --git a/host/lr1110evk/Job/KmlExport.py b/host/lr1110evk/Job/KmlExport.py index 31787de..6395b03 100644 --- a/host/lr1110evk/Job/KmlExport.py +++ b/host/lr1110evk/Job/KmlExport.py @@ -30,8 +30,11 @@ import xml.etree.cElementTree as ET from lr1110evk.BaseTypes import Coordinate, ScannedMacAddress, ScannedGnss from lr1110evk.BaseTypes.WifiChannels import WifiChannel -from NavParser.NavMessageParser import NavMessageParser -from NavParser.navParser import baseTypes +from lr1110evk.NavParserFile import ( + NavMessageParser, + GpsModulationType, + BeidouModulationType, +) import os @@ -148,9 +151,9 @@ def add_point(self, name, localization_type, coordinates, metadata=None): nav_message = NavMessageParser.parse(nav_message) for constellation in nav_message.constellation_results: modulation = constellation.modulation_type - if modulation == baseTypes.GpsModulationType: + if modulation == GpsModulationType: gps_sv = len(constellation.satellites) - elif modulation == baseTypes.BeidouModulationType: + elif modulation == BeidouModulationType: beidou_sv = len(constellation.satellites) else: raise NotImplementedError( diff --git a/host/lr1110evk/NavParserFile/FileNavMessageParser.py b/host/lr1110evk/NavParserFile/FileNavMessageParser.py index 1c91f0e..e2faf58 100644 --- a/host/lr1110evk/NavParserFile/FileNavMessageParser.py +++ b/host/lr1110evk/NavParserFile/FileNavMessageParser.py @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ -from NavParser import NavMessageConsumerBitsExtractionOutOfBound, NavMessageParser +from lr1110evk.NavParserFile import NavMessageConsumerBitsExtractionOutOfBound, NavMessageParser from lr1110evk.FieldTestPost.Core.FileReader import FileReader from lr1110evk.BaseTypes import ScannedGnss from lr1110evk.Job.Logger import ResultLogger diff --git a/host/lr1110evk/NavParserFile/__init__.py b/host/lr1110evk/NavParserFile/__init__.py index e69de29..6fdd5ea 100644 --- a/host/lr1110evk/NavParserFile/__init__.py +++ b/host/lr1110evk/NavParserFile/__init__.py @@ -0,0 +1,6 @@ +from .navParser import ( + NavMessageConsumerBitsExtractionOutOfBound, + NavMessageParser, + GpsModulationType, + BeidouModulationType, +) diff --git a/host/lr1110evk/NavParserFile/__main__.py b/host/lr1110evk/NavParserFile/__main__.py index 9fb239b..9e24594 100644 --- a/host/lr1110evk/NavParserFile/__main__.py +++ b/host/lr1110evk/NavParserFile/__main__.py @@ -30,7 +30,7 @@ from argparse import ArgumentParser import pkg_resources from lr1110evk.NavParserFile.FileNavMessageParser import FileNavMessageParserInterpreter -from NavParser.NavMessageParser import NavMessageParser +from lr1110evk.NavParserFile.navParser.NavMessageParser import NavMessageParser def entry_point_nav_parser_file(): diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/NavMessageParser.py b/host/lr1110evk/NavParserFile/navParser/NavMessageParser.py similarity index 83% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/NavMessageParser.py rename to host/lr1110evk/NavParserFile/navParser/NavMessageParser.py index 5c0f8e7..dec10e5 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/NavMessageParser.py +++ b/host/lr1110evk/NavParserFile/navParser/NavMessageParser.py @@ -1,5 +1,5 @@ -from .navParser.navParser import NavParser -from .navParser.baseTypes import GnssSolverDestination +from .navParser import NavParser +from .baseTypes import GnssSolverDestination class NavMessageParserException(Exception): @@ -42,7 +42,7 @@ def get_cn_vs_from_parsed_message(parsed_nav_message): raise NotGnssSolverDestinationException(parsed_nav_message.destination) for constellation in parsed_nav_message.constellation_results: for satellite in constellation.satellites: - satellite_id = satellite.satellite_name - c_n = satellite.status_info.c_n.get_name() - cn_vs_satellite_id[satellite_id] = c_n + satellite_name = satellite.satellite_name + c_n = satellite.c_n.get_name() + cn_vs_satellite_id[satellite_name] = c_n return cn_vs_satellite_id diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/__init__.py b/host/lr1110evk/NavParserFile/navParser/__init__.py similarity index 61% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/__init__.py rename to host/lr1110evk/NavParserFile/navParser/__init__.py index b7b902c..1c40b65 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/__init__.py +++ b/host/lr1110evk/NavParserFile/navParser/__init__.py @@ -1,10 +1,10 @@ -from .navParser import ( - SatelliteInfo, +from .core import ( + CNGetterFromNav, SatelliteResults, ConstellationResults, NavMessageConsumerBitsExtractionOutOfBound, - GnssDmcDestination, - GnssDmcNavMessage, +) +from .baseTypes import ( GnssSolverDestination, GnssSolverFrameTypeNav, GnssSolverFrameTypeNoAssistance, @@ -14,8 +14,9 @@ CnRangeHigh, CnRangeLow, CnRangeVeryLow, - NavParser + GpsModulationType, + BeidouModulationType, ) -from .NavMessageParser import ( - NavMessageParser -) \ No newline at end of file + +from .navParser import NavParser +from .NavMessageParser import NavMessageParser diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/IdentifiableElement.py b/host/lr1110evk/NavParserFile/navParser/baseTypes/IdentifiableElement.py similarity index 95% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/IdentifiableElement.py rename to host/lr1110evk/NavParserFile/navParser/baseTypes/IdentifiableElement.py index c2cad30..52c6f8a 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/IdentifiableElement.py +++ b/host/lr1110evk/NavParserFile/navParser/baseTypes/IdentifiableElement.py @@ -25,11 +25,6 @@ class GnssSolverDestination(DestinationBase): _name = "GNSS solver" -class GnssDmcDestination(DestinationBase): - _id = b"\x02" - _name = "GNSS DMC" - - class GnssSolverFrameTypeBase(IdentifiedElements): def __str__(self): return "{}".format(self.get_name()) @@ -136,7 +131,7 @@ class CnRangeVeryLow(CnRangeBase): class ModulationTypeBase(IdentifiedElements): def __str__(self): - return f"{self.get_name()}" + return "{}".format(self.get_name()) class GpsModulationType(ModulationTypeBase): diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/__init__.py b/host/lr1110evk/NavParserFile/navParser/baseTypes/__init__.py similarity index 89% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/__init__.py rename to host/lr1110evk/NavParserFile/navParser/baseTypes/__init__.py index 3f46c4e..1f87028 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/__init__.py +++ b/host/lr1110evk/NavParserFile/navParser/baseTypes/__init__.py @@ -1,7 +1,6 @@ from .IdentifiableElement import ( HostDestination, GnssSolverDestination, - GnssDmcDestination, GnssSolverFrameTypeNoAssistance, GnssSolverFrameTypeNav, HostStatusBaseOk, @@ -32,4 +31,4 @@ NavParserModulationTypeUnknownException, ) -from .navMessage import HostNavMessage, GnssSolverNavMessage, GnssDmcNavMessage +from .navMessage import HostNavMessage, GnssSolverNavMessage diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/exceptions.py b/host/lr1110evk/NavParserFile/navParser/baseTypes/exceptions.py similarity index 100% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/exceptions.py rename to host/lr1110evk/NavParserFile/navParser/baseTypes/exceptions.py diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/navMessage.py b/host/lr1110evk/NavParserFile/navParser/baseTypes/navMessage.py similarity index 74% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/navMessage.py rename to host/lr1110evk/NavParserFile/navParser/baseTypes/navMessage.py index 6ff3701..6ff9eee 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/baseTypes/navMessage.py +++ b/host/lr1110evk/NavParserFile/navParser/baseTypes/navMessage.py @@ -1,7 +1,6 @@ from .IdentifiableElement import ( HostDestination, GnssSolverDestination, - GnssDmcDestination, ) @@ -60,15 +59,10 @@ def gps_time_indicator(self): return self.__gps_time_indicator def __str__(self): - return ( - f"- Assistance Position: {self.assistance_position}\n- GPS time indicator: {self.gps_time_indicator}\n- frame type: '{self.frame_type()}'" - + "\n- Constellations:\n - {}".format( - "\n - ".join( - [str(constellation) for constellation in self.constellation_results] - ) + return "- Assistance Position: {}\n- GPS time indicator: {}\n- frame type: '{}'".format( + self.assistance_position, self.gps_time_indicator, self.frame_type() + ) + "\n- Constellations:\n - {}".format( + "\n - ".join( + [str(constellation) for constellation in self.constellation_results] ) ) - - -class GnssDmcNavMessage(NavMessageBase): - DESTINATION = GnssDmcDestination diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/__init__.py b/host/lr1110evk/NavParserFile/navParser/core/__init__.py similarity index 86% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/__init__.py rename to host/lr1110evk/NavParserFile/navParser/core/__init__.py index 4c6caba..224f7e3 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/__init__.py +++ b/host/lr1110evk/NavParserFile/navParser/core/__init__.py @@ -4,6 +4,6 @@ NavMessageConsumerBitsExtractionOutOfBound, ) from .satelliteResults import SatelliteResults -from .satelliteInfo import SatelliteInfo +from .cnGetterFromNav import CNGetterFromNav from .getterFromId import GetterFromId from .constellationResults import ConstellationResults diff --git a/host/lr1110evk/NavParserFile/navParser/core/cnGetterFromNav.py b/host/lr1110evk/NavParserFile/navParser/core/cnGetterFromNav.py new file mode 100644 index 0000000..7fbbe40 --- /dev/null +++ b/host/lr1110evk/NavParserFile/navParser/core/cnGetterFromNav.py @@ -0,0 +1,24 @@ +from .getterFromId import GetterFromId + + +class CNGetterFromNav: + @staticmethod + def get_c_n_from_nav(nav_parser): + c_n = GetterFromId.get_cn_range_from_id(nav_parser.consume_field(2)) + + index = 0 + if bool(nav_parser.consume_field(1) == b"\x01"): + index += 8 + if bool(nav_parser.consume_field(1) == b"\x01"): + index += 8 + if bool(nav_parser.consume_field(1) == b"\x01"): + index += 0 + if bool(nav_parser.consume_field(1) == b"\x01"): + index += 15 + if bool(nav_parser.consume_field(1) == b"\x01"): + index += 19 + if bool(nav_parser.consume_field(1) == b"\x01"): + index += 19 + if bool(nav_parser.consume_field(index) == b"\x01"): + index += 0 + return c_n diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/constellationResults.py b/host/lr1110evk/NavParserFile/navParser/core/constellationResults.py similarity index 81% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/constellationResults.py rename to host/lr1110evk/NavParserFile/navParser/core/constellationResults.py index 2f99c46..dc606da 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/constellationResults.py +++ b/host/lr1110evk/NavParserFile/navParser/core/constellationResults.py @@ -17,7 +17,9 @@ def satellites(self): @staticmethod def from_nav_consumer(nav_consumer): - modulation_type = GetterFromId.get_modulation_type_from_id(nav_consumer.consume_field(4)) + modulation_type = GetterFromId.get_modulation_type_from_id( + nav_consumer.consume_field(4) + ) number_of_sv_raw = nav_consumer.consume_field(4) satellites = list() for _ in range(0, int.from_bytes(number_of_sv_raw, byteorder="little")): @@ -28,4 +30,6 @@ def from_nav_consumer(nav_consumer): ) def __str__(self): - return f"Modulation type: {self.modulation_type()!s}\n - " + '\n - '.join([str(sat) for sat in self.satellites]) + return "Modulation type: {}\n - ".format( + str(self.modulation_type()) + ) + "\n - ".join([str(sat) for sat in self.satellites]) diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/getterFromId.py b/host/lr1110evk/NavParserFile/navParser/core/getterFromId.py similarity index 97% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/getterFromId.py rename to host/lr1110evk/NavParserFile/navParser/core/getterFromId.py index 7addf44..5fb1c8d 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/getterFromId.py +++ b/host/lr1110evk/NavParserFile/navParser/core/getterFromId.py @@ -1,7 +1,6 @@ from ..baseTypes import ( HostDestination, GnssSolverDestination, - GnssDmcDestination, GnssSolverFrameTypeNoAssistance, GnssSolverFrameTypeNav, HostStatusBaseOk, @@ -36,7 +35,7 @@ def id_to_class_mapper(class_list): class GetterFromId: ALL_DESTINATIONS = id_to_class_mapper( - [HostDestination, GnssSolverDestination, GnssDmcDestination] + [HostDestination, GnssSolverDestination] ) ALL_GNSS_SOLVER_FRAME_TYPES = id_to_class_mapper( [GnssSolverFrameTypeNoAssistance, GnssSolverFrameTypeNav] diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/navMessageConsumer.py b/host/lr1110evk/NavParserFile/navParser/core/navMessageConsumer.py similarity index 100% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/core/navMessageConsumer.py rename to host/lr1110evk/NavParserFile/navParser/core/navMessageConsumer.py diff --git a/host/lr1110evk/NavParserFile/navParser/core/satelliteResults.py b/host/lr1110evk/NavParserFile/navParser/core/satelliteResults.py new file mode 100644 index 0000000..1bc4b5b --- /dev/null +++ b/host/lr1110evk/NavParserFile/navParser/core/satelliteResults.py @@ -0,0 +1,45 @@ +from .cnGetterFromNav import CNGetterFromNav + + +class SatelliteResults: + def __init__(self, satellite_id, c_n): + self.__satellite_id = satellite_id + self.__c_n = c_n + + @property + def satellite_id(self): + return self.__satellite_id + + @property + def satellite_name(self): + return SatelliteResults.satellite_id_to_name(self.__satellite_id) + + @property + def c_n(self): + return self.__c_n + + @staticmethod + def from_nav_consumer(nav_consumer): + satellite_id_raw = int.from_bytes( + nav_consumer.consume_field(7), byteorder="little" + ) + c_n = CNGetterFromNav.get_c_n_from_nav(nav_consumer) + + return SatelliteResults(satellite_id=satellite_id_raw, c_n=c_n) + + @staticmethod + def satellite_id_to_name(satellite_id: int): + if 0 <= satellite_id <= 31: + satellite_number = satellite_id + 1 + return "GPS #{}".format(satellite_number) + elif 64 <= satellite_id <= 100: + satellite_number = satellite_id - 63 + return "BeiDou #{}".format(satellite_number) + elif 32 <= satellite_id <= 50: + satellite_number = satellite_id + 88 + return "SBAS #{}".format(satellite_number) + else: + return "RFU (sv_id: {})".format(satellite_id) + + def __str__(self): + return "Sv Id: {} - C/N: {}".format(self.satellite_id, self.c_n()) diff --git a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/navParser.py b/host/lr1110evk/NavParserFile/navParser/navParser.py similarity index 89% rename from host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/navParser.py rename to host/lr1110evk/NavParserFile/navParser/navParser.py index 6c1f6f5..14d5d80 100644 --- a/host/external_lib/lr1110_nav_message_parser_py/NavParser/navParser/navParser.py +++ b/host/lr1110evk/NavParserFile/navParser/navParser.py @@ -1,10 +1,8 @@ from .baseTypes import ( - GnssDmcDestination, GnssSolverDestination, GnssSolverFrameTypeNav, HostDestination, GnssSolverDestination, - GnssDmcDestination, GnssSolverNavMessage, HostNavMessage, ) @@ -23,7 +21,6 @@ def get_builder_from_destination(cls, destination): destination_to_builder_mapper = { HostDestination: cls.build_host_nav, GnssSolverDestination: cls.build_gnss_solver_nav, - GnssDmcDestination: cls.build_gnss_dmc_nav, } return destination_to_builder_mapper[destination] @@ -41,10 +38,6 @@ def extract_gnss_solver_frame_type(cls, nav_message): ) return GetterFromId.get_gnss_solver_frame_type_from_id(gnss_frame_type_raw) - @classmethod - def build_gnss_dmc_nav(cls, nav_consumer): - pass - @classmethod def build_host_nav(cls, nav_consumer): nav_host_status = GetterFromId.get_host_status_from_id( @@ -111,10 +104,3 @@ def parse(cls, nav_message): builder = cls.get_builder_from_destination(destination) nav_message = builder(nav_consumer) return nav_message - - -if __name__ == "__main__": - nav_message_raw = bytes.fromhex( - "0101070808e210a8ef20e22e0014529bec007d0080a4522becb70e20513d41e5e9dd45b05a2115da3b8b67957d73c8f498caaa216e9aec23" - ) - nav_message = NavParser.parse(nav_message_raw) diff --git a/host/lr1110evk/SerialExchange/DemoVcpReader.py b/host/lr1110evk/SerialExchange/DemoVcpReader.py index af74e77..0a869fe 100644 --- a/host/lr1110evk/SerialExchange/DemoVcpReader.py +++ b/host/lr1110evk/SerialExchange/DemoVcpReader.py @@ -127,7 +127,7 @@ def FlushDataCommandHandler(self): self.storage.clear() def SendGnssDataToServer(self): - request = self.request_sender.build_gnss_request_per_device(self.storage) + request = self.request_sender.build_gnss_requests(self.storage) if self.embedded_version: request.embedded_versions = self.embedded_version self.print_if_verbose( diff --git a/host/lr1110evk/__main__.py b/host/lr1110evk/__main__.py index 6d249a5..ff1073a 100644 --- a/host/lr1110evk/__main__.py +++ b/host/lr1110evk/__main__.py @@ -131,10 +131,6 @@ def entry_point_demo(): "glsAuthenticationToken", help="HTTP header token to authenticate the Wi-Fi requests on LoRa Cloud Geolocation (GLS) server", ) - parser.add_argument( - "dasAuthenticationToken", - help="HTTP header token to authenticate the GNSS requests on LoRa Cloud Device and Application Services (DAS) server", - ) parser.add_argument( "-s", "--wifi-server-base-url", diff --git a/host/lr1110evk/main_almanac_update.py b/host/lr1110evk/main_almanac_update.py index 456c64a..8b8ea33 100644 --- a/host/lr1110evk/main_almanac_update.py +++ b/host/lr1110evk/main_almanac_update.py @@ -48,13 +48,12 @@ def entry_point_update_almanac(): default_device = "/dev/ttyACM0" default_baud = 921600 default_log_filename = "log.log" - default_url_base = "https://das.loracloud.com" + default_url_base = "https://gls.loracloud.com" version = pkg_resources.get_distribution("lr1110evk").version parser = ArgumentParser() parser.add_argument( - "dasToken", - help="Authentication token to the Device And Application Server (DAS)", + "glsToken", help="Authentication token to the GeoLocation Server (GLS)", ) parser.add_argument( "-u", @@ -67,7 +66,7 @@ def entry_point_update_almanac(): parser.add_argument( "-f", "--almanac-file", - help="Get the almanac information from a file instead of downloading it from web API. In this case the DAS token is not used", + help="Get the almanac information from a file instead of downloading it from web API. In this case the GLS token is not used", default=None, ) parser.add_argument( @@ -107,9 +106,9 @@ def entry_point_update_almanac(): from base64 import decodebytes log_logger.log("Fetching almanac data from url {}...".format(args.url_base)) - full_url_api = "{}/api/v1/almanac/full".format(args.url_base) + full_url_api = "{}/api/v3/almanac/full".format(args.url_base) request_header = { - "Authorization": args.dasToken, + "Ocp-Apim-Subscription-Key": args.glsToken, "Content-Type": "application/json", } almanac_server_response = requests.get(full_url_api, headers=request_header) diff --git a/host/setup.py b/host/setup.py index d03c7d7..532723a 100644 --- a/host/setup.py +++ b/host/setup.py @@ -3,19 +3,12 @@ PACKAGE_NAME = "lr1110evk" -def get_all_packages(): - packages = find_packages() - packages.extend(find_packages(where="external_lib/lr1110_nav_message_parser_py")) - return packages - - setup( name=PACKAGE_NAME, version_format="{tag}.dev{commitcount}+{gitsha}", setup_requires=["setuptools-git-version"], include_package_data=True, - packages=get_all_packages(), - package_dir={"NavParser": "./external_lib/lr1110_nav_message_parser_py/NavParser"}, + packages=find_packages(), author="Semtech", install_requires=[ "pyserial",