Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b6f7b8a

Browse files
authored
fix: add TDM and edge intelligence flags to provision.py (ruvnet#131)
The user guide and release notes document TDM and edge intelligence provisioning flags but provision.py only accepted --ssid, --password, --target-ip, --target-port, and --node-id. Add all NVS keys the firmware actually reads: - --tdm-slot / --tdm-total: TDM mesh slot assignment - --edge-tier: edge processing tier (0=off, 1=stats, 2=vitals) - --pres-thresh, --fall-thresh: detection thresholds - --vital-win, --vital-int: vitals timing parameters - --subk-count: top-K subcarrier selection Also validates that --tdm-slot and --tdm-total are specified together and that slot < total. Closes ruvnet#130
1 parent 86f0830 commit b6f7b8a

1 file changed

Lines changed: 73 additions & 18 deletions

File tree

firmware/esp32-csi-node/provision.py

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,40 @@
3030
NVS_PARTITION_SIZE = 0x6000 # 24 KiB
3131

3232

33-
def build_nvs_csv(ssid, password, target_ip, target_port, node_id):
33+
def build_nvs_csv(args):
3434
"""Build an NVS CSV string for the csi_cfg namespace."""
3535
buf = io.StringIO()
3636
writer = csv.writer(buf)
3737
writer.writerow(["key", "type", "encoding", "value"])
3838
writer.writerow(["csi_cfg", "namespace", "", ""])
39-
if ssid:
40-
writer.writerow(["ssid", "data", "string", ssid])
41-
if password is not None:
42-
writer.writerow(["password", "data", "string", password])
43-
if target_ip:
44-
writer.writerow(["target_ip", "data", "string", target_ip])
45-
if target_port is not None:
46-
writer.writerow(["target_port", "data", "u16", str(target_port)])
47-
if node_id is not None:
48-
writer.writerow(["node_id", "data", "u8", str(node_id)])
39+
if args.ssid:
40+
writer.writerow(["ssid", "data", "string", args.ssid])
41+
if args.password is not None:
42+
writer.writerow(["password", "data", "string", args.password])
43+
if args.target_ip:
44+
writer.writerow(["target_ip", "data", "string", args.target_ip])
45+
if args.target_port is not None:
46+
writer.writerow(["target_port", "data", "u16", str(args.target_port)])
47+
if args.node_id is not None:
48+
writer.writerow(["node_id", "data", "u8", str(args.node_id)])
49+
# TDM mesh settings
50+
if args.tdm_slot is not None:
51+
writer.writerow(["tdm_slot", "data", "u8", str(args.tdm_slot)])
52+
if args.tdm_total is not None:
53+
writer.writerow(["tdm_nodes", "data", "u8", str(args.tdm_total)])
54+
# Edge intelligence settings (ADR-039)
55+
if args.edge_tier is not None:
56+
writer.writerow(["edge_tier", "data", "u8", str(args.edge_tier)])
57+
if args.pres_thresh is not None:
58+
writer.writerow(["pres_thresh", "data", "u16", str(args.pres_thresh)])
59+
if args.fall_thresh is not None:
60+
writer.writerow(["fall_thresh", "data", "u16", str(args.fall_thresh)])
61+
if args.vital_win is not None:
62+
writer.writerow(["vital_win", "data", "u16", str(args.vital_win)])
63+
if args.vital_int is not None:
64+
writer.writerow(["vital_int", "data", "u16", str(args.vital_int)])
65+
if args.subk_count is not None:
66+
writer.writerow(["subk_count", "data", "u8", str(args.subk_count)])
4967
return buf.getvalue()
5068

5169

@@ -127,14 +145,37 @@ def main():
127145
parser.add_argument("--target-ip", help="Aggregator host IP (e.g. 192.168.1.20)")
128146
parser.add_argument("--target-port", type=int, help="Aggregator UDP port (default: 5005)")
129147
parser.add_argument("--node-id", type=int, help="Node ID 0-255 (default: 1)")
148+
# TDM mesh settings
149+
parser.add_argument("--tdm-slot", type=int, help="TDM slot index for this node (0-based)")
150+
parser.add_argument("--tdm-total", type=int, help="Total number of TDM nodes in mesh")
151+
# Edge intelligence settings (ADR-039)
152+
parser.add_argument("--edge-tier", type=int, choices=[0, 1, 2],
153+
help="Edge processing tier: 0=off, 1=stats, 2=vitals")
154+
parser.add_argument("--pres-thresh", type=int, help="Presence detection threshold (default: 50)")
155+
parser.add_argument("--fall-thresh", type=int, help="Fall detection threshold (default: 500)")
156+
parser.add_argument("--vital-win", type=int, help="Phase history window in frames (default: 300)")
157+
parser.add_argument("--vital-int", type=int, help="Vitals packet interval in ms (default: 1000)")
158+
parser.add_argument("--subk-count", type=int, help="Top-K subcarrier count (default: 32)")
130159
parser.add_argument("--dry-run", action="store_true", help="Generate NVS binary but don't flash")
131160

132161
args = parser.parse_args()
133162

134-
if not any([args.ssid, args.password is not None, args.target_ip,
135-
args.target_port, args.node_id is not None]):
136-
parser.error("At least one config value must be specified "
137-
"(--ssid, --password, --target-ip, --target-port, --node-id)")
163+
has_value = any([
164+
args.ssid, args.password is not None, args.target_ip,
165+
args.target_port, args.node_id is not None,
166+
args.tdm_slot is not None, args.tdm_total is not None,
167+
args.edge_tier is not None, args.pres_thresh is not None,
168+
args.fall_thresh is not None, args.vital_win is not None,
169+
args.vital_int is not None, args.subk_count is not None,
170+
])
171+
if not has_value:
172+
parser.error("At least one config value must be specified")
173+
174+
# Validate TDM: if one is given, both should be
175+
if (args.tdm_slot is not None) != (args.tdm_total is not None):
176+
parser.error("--tdm-slot and --tdm-total must be specified together")
177+
if args.tdm_slot is not None and args.tdm_slot >= args.tdm_total:
178+
parser.error(f"--tdm-slot ({args.tdm_slot}) must be less than --tdm-total ({args.tdm_total})")
138179

139180
print("Building NVS configuration:")
140181
if args.ssid:
@@ -147,9 +188,23 @@ def main():
147188
print(f" Target Port: {args.target_port}")
148189
if args.node_id is not None:
149190
print(f" Node ID: {args.node_id}")
150-
151-
csv_content = build_nvs_csv(args.ssid, args.password, args.target_ip,
152-
args.target_port, args.node_id)
191+
if args.tdm_slot is not None:
192+
print(f" TDM Slot: {args.tdm_slot} of {args.tdm_total}")
193+
if args.edge_tier is not None:
194+
tier_desc = {0: "off (raw CSI)", 1: "stats", 2: "vitals"}
195+
print(f" Edge Tier: {args.edge_tier} ({tier_desc.get(args.edge_tier, '?')})")
196+
if args.pres_thresh is not None:
197+
print(f" Pres Thresh: {args.pres_thresh}")
198+
if args.fall_thresh is not None:
199+
print(f" Fall Thresh: {args.fall_thresh}")
200+
if args.vital_win is not None:
201+
print(f" Vital Window: {args.vital_win} frames")
202+
if args.vital_int is not None:
203+
print(f" Vital Interval:{args.vital_int} ms")
204+
if args.subk_count is not None:
205+
print(f" Top-K Subcarr: {args.subk_count}")
206+
207+
csv_content = build_nvs_csv(args)
153208

154209
try:
155210
nvs_bin = generate_nvs_binary(csv_content, NVS_PARTITION_SIZE)

0 commit comments

Comments
 (0)