Skip to content

Commit 3f6a0ee

Browse files
authored
Store partial images when the OTA image's size is unknown (#37)
1 parent 1243cf9 commit 3f6a0ee

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

zigpy_cli/ota.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ def reconstruct_from_pcaps(
232232

233233
ota_chunks[image_key].add((offset, data))
234234

235+
unknown_sizes = set()
236+
237+
for key in ota_chunks:
238+
if key in ota_sizes:
239+
continue
240+
241+
unknown_sizes.add(key)
242+
ota_sizes[key] = max(offset + len(data) for offset, data in ota_chunks[key])
243+
LOGGER.error(
244+
"Image size for %s not captured, assuming size %s", key, ota_sizes[key]
245+
)
246+
235247
for image_key, image_size in ota_sizes.items():
236248
image_version, image_type, image_manuf_code = image_key
237249
print(
@@ -283,6 +295,7 @@ def reconstruct_from_pcaps(
283295

284296
filename = output_root / (
285297
f"ota_t{image_type}_m{image_manuf_code}_v{image_version}"
298+
f"{'_unk_size' if image_key in unknown_sizes else ''}"
286299
f"{'_partial' if missing_ranges else ''}.ota"
287300
)
288301

0 commit comments

Comments
 (0)