Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,49 @@ eval "$(register-python-argcomplete infuse)"
## Usage

```
infuse --help
usage: infuse [-h] <command> ...
> infuse --help
usage: infuse [-h] [--version] <command> ...

options:
-h, --help show this help message and exit
--version show program's version number and exit

commands:
<command>
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
```
2 changes: 1 addition & 1 deletion src/infuse_iot/generated/tdf_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 17 additions & 1 deletion src/infuse_iot/tdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/infuse_iot/tools/tdf_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
__author__ = "Jordan Yates"
__copyright__ = "Copyright 2024, Embeint Inc"

import time

import tabulate

from infuse_iot.commands import InfuseCommand
Expand Down Expand Up @@ -44,21 +46,21 @@ 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

for idx, field in enumerate(t.iter_fields()):
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))

Expand Down
Loading