diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..29441e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,33 @@ +LicenseID: LicenseRef-Embeint + +Copyright (c) 2024 - Present, Embeint Inc +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code or in binary form must reproduce +the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the +distribution. + +2. Neither the name of Embeint nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +3. This software, with or without modification, must only be used with +Embeint services and integrated with the INFUSE-IoT platform. + +4. Any software provided in binary form under this license must not be +reverse engineered, decompiled, modified and/or disassembled. + +THIS SOFTWARE IS PROVIDED BY EMBEINT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL EMBEINT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index e04170d..c7f3673 100644 --- a/README.md +++ b/README.md @@ -22,20 +22,49 @@ eval "$(register-python-argcomplete infuse)" ## Usage ``` -infuse --help -usage: infuse [-h] ... +> infuse --help +usage: infuse [-h] [--version] ... options: -h, --help show this help message and exit + --version show program's version number and exit commands: + bt_log Connect to remote Bluetooth device serial logs + cloud Infuse-IoT cloud interaction + credentials Manage Infuse-IoT credentials csv_annotate Annotate CSV data csv_plot Plot CSV data gateway Connect to a local gateway device + localhost Run a local server for TDF viewing + native_bt Native Bluetooth gateway + ota_upgrade Automatically OTA upgrade observed devices + provision Provision device on Infuse Cloud rpc Run remote procedure calls on devices + rpc_cloud Manage remote procedure calls through Infuse-IoT cloud serial_throughput Test serial throughput to local gateway tdf_csv Save received TDFs in CSV files tdf_list Display received TDFs in a list ``` + +## Credential Storage + +Under linux, the preferred credential storage provider for the python ``keyring`` +package is provided by ``gnome-keyring``. The available backends can be listed with +``keyring --list-backends``. + +``` +sudo apt install gnome-keyring +``` + +### WSL Issues + +Under WSL, they keyring has been observed to consistently raise +``secretstorage.exceptions.PromptDismissedException: Prompt dismissed``. +This can be resolved by adding the following to ``~/.bashrc`` and reloading +the terminal. +``` +dbus-update-activation-environment --all > /dev/null 2>&1 +``` diff --git a/src/infuse_iot/generated/tdf_definitions.py b/src/infuse_iot/generated/tdf_definitions.py index ad2016c..a9fceec 100644 --- a/src/infuse_iot/generated/tdf_definitions.py +++ b/src/infuse_iot/generated/tdf_definitions.py @@ -919,7 +919,7 @@ class array_type(TdfReadingBase): } -id_type_mapping: dict[int, TdfReadingBase] = { +id_type_mapping: dict[int, type[TdfReadingBase]] = { 1: readings.announce, 2: readings.battery_state, 3: readings.ambient_temp_pres_hum, diff --git a/src/infuse_iot/tdf.py b/src/infuse_iot/tdf.py index 3070347..5e15ec9 100644 --- a/src/infuse_iot/tdf.py +++ b/src/infuse_iot/tdf.py @@ -8,6 +8,19 @@ from infuse_iot.time import InfuseTime +def unknown_tdf_factory(tdf_id: int, tdf_len: int) -> type[tdf_base.TdfReadingBase]: + class UnknownTDF(tdf_base.TdfReadingBase): + name = str(tdf_id) + _fields_ = [ + ("data", tdf_len * ctypes.c_uint8), + ] + _pack_ = 1 + _postfix_ = {"data": ""} + _display_fmt_ = {"data": "{}"} + + return UnknownTDF + + class TDF: class flags(enum.IntEnum): TIMESTAMP_NONE = 0x0000 @@ -83,7 +96,10 @@ def decode(self, buffer: bytes) -> Generator[Reading, None, None]: time_flags = header.id_flags & self.flags.TIMESTAMP_MASK tdf_id = header.id_flags & 0x0FFF - id_type = tdf_definitions.id_type_mapping[tdf_id] + try: + id_type = tdf_definitions.id_type_mapping[tdf_id] + except KeyError: + id_type = unknown_tdf_factory(tdf_id, header.len) if time_flags == self.flags.TIMESTAMP_NONE: time = None diff --git a/src/infuse_iot/tools/tdf_list.py b/src/infuse_iot/tools/tdf_list.py index 56b58f2..f828fca 100644 --- a/src/infuse_iot/tools/tdf_list.py +++ b/src/infuse_iot/tools/tdf_list.py @@ -5,6 +5,8 @@ __author__ = "Jordan Yates" __copyright__ = "Copyright 2024, Embeint Inc" +import time + import tabulate from infuse_iot.commands import InfuseCommand @@ -44,7 +46,7 @@ def run(self) -> None: t = tdf.data[-1] num = len(tdf.data) if num > 1: - tdf_name = f"{t.name}[{num-1}]" + tdf_name = f"{t.name}[{num - 1}]" else: tdf_name = t.name @@ -52,13 +54,13 @@ def run(self) -> None: if idx == 0: if tdf.time is not None: if tdf.period is None: - time = InfuseTime.utc_time_string(tdf.time) + time_str = InfuseTime.utc_time_string(tdf.time) else: offset = (len(tdf.data) - 1) * tdf.period - time = InfuseTime.utc_time_string(tdf.time + offset) + time_str = InfuseTime.utc_time_string(tdf.time + offset) else: - time = "N/A" - table.append((time, tdf_name, field.name, field.val_fmt(), field.postfix)) + time_str = InfuseTime.utc_time_string(time.time()) + table.append((time_str, tdf_name, field.name, field.val_fmt(), field.postfix)) else: table.append((None, None, field.name, field.val_fmt(), field.postfix))