diff --git a/src/infuse_iot/generated/kv_definitions.py b/src/infuse_iot/generated/kv_definitions.py index 22c7b33..1cd25e6 100644 --- a/src/infuse_iot/generated/kv_definitions.py +++ b/src/infuse_iot/generated/kv_definitions.py @@ -118,6 +118,17 @@ class device_name(VLACompatLittleEndianStruct): vla_field = ("name", structs.kv_string) _pack_ = 1 + class infuse_application_id(VLACompatLittleEndianStruct): + """CONFIG_INFUSE_APPLICATION_ID, store will be reset if the values don't match""" + + NAME = "INFUSE_APPLICATION_ID" + BASE_ID = 5 + RANGE = 1 + _fields_ = [ + ("application_id", ctypes.c_uint32), + ] + _pack_ = 1 + class fixed_location(VLACompatLittleEndianStruct): """Fixed global location of the device""" @@ -279,6 +290,7 @@ class lora_config(VLACompatLittleEndianStruct): ("coding_rate", ctypes.c_uint8), ("preamble_len", ctypes.c_uint16), ("tx_power", ctypes.c_int8), + ("sync_word", ctypes.c_uint8), ] _pack_ = 1 @@ -354,6 +366,7 @@ class secure_storage_reserved(VLACompatLittleEndianStruct): 2: exfat_disk_info, 3: bluetooth_ctlr_version, 4: device_name, + 5: infuse_application_id, 10: fixed_location, 20: wifi_ssid, 21: wifi_psk, diff --git a/src/infuse_iot/rpc_wrappers/kv_bt_peer.py b/src/infuse_iot/rpc_wrappers/kv_bt_peer.py index 2d4ff35..af19b25 100644 --- a/src/infuse_iot/rpc_wrappers/kv_bt_peer.py +++ b/src/infuse_iot/rpc_wrappers/kv_bt_peer.py @@ -65,9 +65,15 @@ def handle_response(self, return_code, response): def print_status(name, rc): if rc < 0: - print(f"{name} failed to write ({os.strerror(-rc)})") + if self.addr == b"": + print(f"{name} failed to delete ({os.strerror(-rc)})") + else: + print(f"{name} failed to write ({os.strerror(-rc)})") elif rc == 0: - print(f"{name} already matched") + if self.addr == b"": + print(f"{name} deleted") + else: + print(f"{name} already matched") else: print(f"{name} updated") diff --git a/src/infuse_iot/tools/ota_upgrade.py b/src/infuse_iot/tools/ota_upgrade.py index 2deacaf..900319d 100644 --- a/src/infuse_iot/tools/ota_upgrade.py +++ b/src/infuse_iot/tools/ota_upgrade.py @@ -57,6 +57,10 @@ def __init__(self, args): TransferSpeedColumn(), ) self.task = None + if args.log is None: + self._log = None + else: + self._log = open(args.log, "+a", encoding="utf-8") # noqa: SIM115 @classmethod def add_parser(cls, parser): @@ -65,6 +69,7 @@ def add_parser(cls, parser): ) parser.add_argument("--rssi", type=int, help="Minimum RSSI to attempt upgrade process") parser.add_argument("--id", type=lambda x: int(x, 0), help="Single device to upgrade") + parser.add_argument("--log", type=str, help="File to write upgrade results to") def progress_table(self): table = Table() @@ -124,8 +129,15 @@ def run(self): self._handled.append(source.infuse_id) if v_str == self._new_ver: self._updated += 1 + result = "upgraded" else: self._failed += 1 + result = "failed" + if self._log: + self._log.write( + f"{time.time()},0x{source.infuse_id:016x},0x{self._app_id:08x},{v_str},{result}\n" + ) + self._log.flush() continue # Already running the requested version? @@ -133,6 +145,11 @@ def run(self): self._handled.append(source.infuse_id) self._already += 1 self.state_update(live, "Scanning") + if self._log: + self._log.write( + f"{time.time()},0x{source.infuse_id:016x},0x{self._app_id:08x},{v_str},already\n" + ) + self._log.flush() continue # Do we have a valid diff? @@ -175,7 +192,7 @@ def run(self): ) if hdr.return_code == 0: - self._pending[source.infuse_id] = time.time() + 30 + self._pending[source.infuse_id] = time.time() + 60 except ConnectionRefusedError: self.state_update(live, "Scanning")