code wiki / (root) / nx_iot_capability.nx

nx_iot_capability.nx

buildroot/runtime/nx_iot_capability.nx

7106 B198 linesdepth 0pulls 0 transitivereach 12 importersview sourcekind librarytopic iot
docsdependenciesstructsconstsfunctions

about

nx_iot_capability.nx -- per-device capability model for the hub UI. Roadmap: NISHI_IOT_HUB_ROADMAP.md Epoch 6 (CALIBRATE) + the nishifamily.com/iot control-panel substrate. Operator ask (2026-06-18): manage devices "with the ability to change the lights on what capabilities they have like color and light intensity." The triad: nx_iot_anchor = WHO (stable identity), the vendor driver = HOW (wire protocol), this = WHAT-IT-CAN-DO. The /iot UI reads a device's capability set and renders exactly the right controls -- a toggle for a switch, a slider for a dimmer, a colour wheel + temp slider for a colour bulb. Data-driven (CLAUDE.md #11): the UI never hardcodes per-device controls; it asks this model. Capabilities are bit flags so a device advertises a SET. Device classes map to default capability sets; per-vendor quirks refine. Pure caller-buffer, no syscalls, no imports -> portable + sovereign. license_tier: ORIGINAL nx_capability_claims: needs: [pointer_arithmetic, bit_ops] provides: [capability_flags, class_to_caps, caps_has, caps_clamp_level, caps_emit_json] safety: [no_unchecked_deref, no_floating_point, no_syscall, bounded_iteration, data_driven] verdict: [sealed_enum_class, no_silent_failure] license: ORIGINAL kind: iot_runtime_primitive sss: [S6, S7]

dependencies 0 imports · 3 importers

nx_iot_capability.nx nx_iot_capability_test.nx nx_iot_control_page.nx nx_iot_page.nx

imports: none

imported by: nx_iot_capability_test.nxnx_iot_control_page.nxnx_iot_page.nx

structs

none

consts

35const NX_IOT_CAP_ONOFF: i64 = 1 // bit 0 -> render a toggle
36const NX_IOT_CAP_BRIGHTNESS: i64 = 2 // bit 1 -> render a 0-100 slider
37const NX_IOT_CAP_COLOR: i64 = 4 // bit 2 -> render a hue/sat picker
38const NX_IOT_CAP_COLOR_TEMP: i64 = 8 // bit 3 -> render a Kelvin slider
39const NX_IOT_CAP_SCENE: i64 = 16 // bit 4 -> render a scene list
40const NX_IOT_CAP_ENERGY: i64 = 32 // bit 5 -> render energy readout
44const NX_IOT_CLASS_UNKNOWN: i64 = 0
45const NX_IOT_CLASS_SWITCH: i64 = 1
46const NX_IOT_CLASS_PLUG: i64 = 2
47const NX_IOT_CLASS_PLUG_ENERGY: i64 = 3
48const NX_IOT_CLASS_DIMMER: i64 = 4
49const NX_IOT_CLASS_BULB_WHITE: i64 = 5
50const NX_IOT_CLASS_BULB_TUNABLE: i64 = 6
51const NX_IOT_CLASS_BULB_COLOR: i64 = 7
52const NX_IOT_CLASS_N: i64 = 8
62const NX_IOT_BRIGHTNESS_MIN: i64 = 0
63const NX_IOT_BRIGHTNESS_MAX: i64 = 100
64const NX_IOT_COLOR_TEMP_MIN: i64 = 2700 // warm white, Kelvin
65const NX_IOT_COLOR_TEMP_MAX: i64 = 6500 // cool daylight, Kelvin

functions

54func nx_iot_class_is_valid(c: i64) -> i64
called by 1: main
69func nx_iot_cap_puts_z(out: *u8, off: i64, s: *u8) -> i64
85func nx_iot_cap_for_class(vendor: i64, dev_class: i64) -> i64
108func nx_iot_cap_has(caps: i64, flag: i64) -> i64
115func nx_iot_cap_clamp_brightness(caps: i64, v: i64) -> i64
called by 1: main calls 1: nx_iot_cap_has
122func nx_iot_cap_clamp_color_temp(caps: i64, k: i64) -> i64
called by 1: main calls 1: nx_iot_cap_has
136func nx_iot_cap_emit_json(caps: i64, out: *u8, out_cap: i64) -> i64