nx_iot_discover.nx
buildroot/runtime/nx_iot_discover.nx
about
nx_iot_discover.nx -- universal multi-vendor device DISCOVERY brain.
Roadmap: NISHI_IOT_HUB_ROADMAP.md Epoch 1 (DISCOVER), rung D1.
Operator ask (2026-06-22): "it needs a discovery mechanism like all the
hardware discovery" -- find EVERY device on the LAN and figure out what
each one is, WITHOUT knowing brands in advance.
This is the DISCOVERY ORCHESTRATOR that ties the existing thin organs
into one pass: a captured datagram (raw bytes + source port + source IP
+ optional MAC) goes IN; a classified, de-duplicated logical device in
the anchor registry comes OUT. It composes -- it duplicates nothing:
- nx_iot_local_kasa : decrypt the autokey-XOR :9999 replies + confirm
sysinfo (the one wire format nx_iot_announce's
first-byte classifier could not read)
- nx_iot_classify : fuse 4 signals (reply / OUI / port / SSID) -> vendor
- nx_iot_anchor : idempotent adopt keyed by stable hardware id ->
re-discovery RE-ADOPTS (no duplicate-on-repair)
The live socket sweep (rung D2) calls nx_iot_disc_ingest once per
captured datagram; this brain has NO sockets so it is deterministic,
portable across every nxc2 backend, and hard-gateable with canned beacons.
NEVER-BRICK (CLAUDE.md #26): discovery is READ-ONLY classification plus an
ADDITIVE in-memory registry adopt (soft-state, #13). It emits no device
write of any kind -- brick-safe by construction; there is no firmware path
here to prove safe because none exists.
UNKNOWN is a FIRST-CLASS result (no silent drop): an unrecognised device
still anchors + gets a logical id, so the hub can active-probe / build a
driver for it later (operator's "build it autonomously" path).
genealogy_id: NISHI_IOT_HUB_ROADMAP.md Epoch 1 + project-iot-hub-multi-vendor-kickoff-2026-05-16
license_tier: ORIGINAL
nx_capability_claims:
needs: [pointer_arithmetic]
provides: [universal_discovery_ingest, kasa_reply_decode,
fused_vendor_classify, dedup_by_hardware_id,
unknown_is_first_class, measured_duplicates_prevented]
safety: [no_unchecked_deref, no_floating_point, no_syscall,
dependencies 3 imports · 2 importers
imports: nx_iot_classify.nxnx_iot_anchor.nxnx_iot_local_kasa.nx
imported by: nx_iot_discover_test.nxnx_iot_softap_discover_test.nx
structs
| none |
consts
| 68 | const NX_IOT_DISC_UNKNOWN: i64 = 0 |
| 69 | const NX_IOT_DISC_NEW: i64 = 1 // newly discovered + anchored |
| 70 | const NX_IOT_DISC_READOPTED: i64 = 2 // known device re-seen -> same logical id, no dup |
| 71 | const NX_IOT_DISC_FULL: i64 = 3 // registry at capacity |
| 72 | const NX_IOT_DISC_BAD_ARG: i64 = 4 |
| 73 | const NX_IOT_DISC_N: i64 = 5 |
functions
| 75 | func nx_iot_disc_verdict_is_valid(v: i64) -> i64 called by 1: main |
| 88 | func nx_iot_disc_to_plain(raw: *u8, n: i64, src_port: i64, |
| 110 | func nx_iot_disc_classify(plain: *u8, plain_n: i64, src_port: i64, |
| 132 | func nx_iot_disc_ingest(reg: *IotAnchorReg, metas: *IotDeviceMeta, blob: *u8, |
| 170 | func nx_iot_disc_duplicates_prevented(reg: *IotAnchorReg) -> i64 |
| 182 | func nx_iot_disc_classify_softap(ssid: *u8, ssid_n: i64, called by 1: nx_iot_disc_ingest_softap calls 3: nx_iot_classify_by_ssidnx_iot_classify_by_ouinx_iot_classify_fuse |
| 198 | func nx_iot_disc_softap_pairable(vendor: i64, auth_open: i64) -> i64 called by 1: nx_iot_disc_ingest_softap |
| 211 | func nx_iot_disc_ingest_softap(reg: *IotAnchorReg, metas: *IotDeviceMeta, blob: *u8, called by 1: main calls 3: nx_iot_disc_classify_softapnx_iot_disc_softap_pairablenx_iot_anchor_adopt |