Files
HaloKeymind/tools/hil/profile_pair_transfer.py
T
mikecarper 091c8d8324 Preserve radio lab experiments and reuse unchanged SX1262 modulation
Skip redundant modulation writes during owned fast RX retunes when the last
acknowledged SF/BW/CR/LDRO tuple matches. Invalidate that cache after ordinary
setters, failed writes, and lifecycle changes.

Include the remaining scan, preamble, settling, and memory-soak experiments,
their collectors, validation notes, and original capture records. Preserve
capture bytes across checkouts and keep private soak credentials local.

Run lab collector and compiled contract tests in CI. Update the expectation,
profile mapping, and result-buffer tests for the extended lab tools, and make
the private WiFi override header optional for ordinary soak diagnostics.

Validation: 145 host tests passed from the staged source snapshot. Clean
heltec_v4_repeater and Xiao_S3_WIO_companion_radio_usb builds passed their
RAM/flash gates. All 229 staged capture files retain their original bytes;
all 75 local documentation links resolve in the clean snapshot.
2026-09-14 22:34:17 -07:00

23 lines
1.2 KiB
Python

"""Receive bounded chunks through the already configured SSH bridge."""
import base64
import hashlib
import json
from pathlib import Path
import struct
frame=base64.b64decode('__PAYLOAD_B64__',validate=True)
offset,total=struct.unpack_from('<II',frame);digest=frame[8:40].hex();chunk=frame[40:]
root=Path.home()/'hwtest/runs/pair-sf8-32-20260914'
root.mkdir(mode=0o700,parents=True,exist_ok=True)
if (root/'manifest.json').exists():raise RuntimeError('Already unpacked')
archive=root/'bundle.zip';size=archive.stat().st_size if archive.exists() else 0
if len(chunk)>32768 or offset+len(chunk)>total or total>2000000:raise RuntimeError('Chunk bounds')
if size==offset:
with archive.open('ab') as f:f.write(chunk)
elif size==offset+len(chunk):
with archive.open('rb') as f:f.seek(offset);prior=f.read(len(chunk))
if prior!=chunk:raise RuntimeError('Mismatched duplicate chunk')
else:raise RuntimeError('Out of order chunk')
if archive.stat().st_size==total and hashlib.sha256(archive.read_bytes()).hexdigest()!=digest:
raise RuntimeError('Wrong complete bundle hash')
print(json.dumps({'uploaded':archive.stat().st_size,'total':total,'complete':archive.stat().st_size==total}),flush=True)