How nearmeter/nrfclaw works
nRFClaw is an embedded platform whose host-side compiler turns user-described behavior into deterministic VM bytecode, programs devices over BLE, and lets low-power firmware execute autonomously. The README documents a standalone semantic path and optional AI-agent path, plus Direct BLE/NDP and NinaLink/Home Assistant capabilities. Firmware initialization and event dispatch are partly visible in src/main.c; most other firmware and Home Assistant links below reflect README-documented behavior rather than inspected implementation details.
Main entry points: nrfclaw_vm.c Bytecode VM · main.c Firmware coordinator · nrfclaw_cli.py nRFClaw CLI · nrfclaw_hybrid_semantic.py Standalone semantics
Components 23
Host programming
- nRFClaw CLI
NRFCLAW_CLI/nrfclaw_cli.py
Semantic compilation
- Standalone semantics
NRFCLAW_CLI/nrfclaw_hybrid_semantic.py - Optional AI agent
NRFCLAW_CLI/nrfclaw_agent/core.py - Agent router
NRFCLAW_CLI/nrfclaw_agent/router.py - Semantic IR
NRFCLAW_CLI/nrfclaw_semantic_ir.py - Pseudo compiler
NRFCLAW_CLI/nrfclaw_pseudo.py - Text compiler
NRFCLAW_CLI/nrfclaw_text_compiler.py - Schedule semantics
NRFCLAW_CLI/nrfclaw_schedule_semantics.py
Device runtime
- Firmware coordinator
src/main.c - Bytecode VM
src/nrfclaw_vm.c - RTC scheduler
src/nrfclaw_scheduler.c - Persistent state
src/nrfclaw_flash.c - Event system
src/nrfclaw_event.c - Sensors and inputs
src/nrfclaw_lis2dh12.c
Connectivity
- BLE programming
src/nrfclaw_ble_app.c - LoRa transport
src/nrfclaw_lora.c - Direct BLE/NDP
src/nrfclaw_ndp.c - NinaLink network
src/nrfclaw_ninalink_bridge.c
Home Assistant
- Home Assistant
integrations/home-assistant/custom_components/nrfclaw/__init__.py - HA device client
integrations/home-assistant/custom_components/nrfclaw/client.py - NinaLink runtime
integrations/home-assistant/custom_components/nrfclaw/ninalink_runtime.py
Other components
- Device author
- External radios
Connections 28
- Device author → nRFClaw CLI: describes behavior
- nRFClaw CLI → Standalone semantics: requests compile
NRFCLAW_CLI/nrfclaw_cli.py - nRFClaw CLI → Agent router: routes agent request
NRFCLAW_CLI/nrfclaw_cli.py - Agent router → Optional AI agent: calls provider
NRFCLAW_CLI/nrfclaw_agent/router.py - Agent router → Standalone semantics: falls back
NRFCLAW_CLI/nrfclaw_agent/router.py - Standalone semantics → Semantic IR: produces plan
- Optional AI agent → Semantic IR: emits semantic plan
NRFCLAW_CLI/nrfclaw_agent/core.py - Semantic IR → Pseudo compiler: lowers to pseudo
NRFCLAW_CLI/nrfclaw_semantic_ir.py - Pseudo compiler → Text compiler: assembles bytecode
NRFCLAW_CLI/nrfclaw_pseudo.py - Standalone semantics → Text compiler: lowers deterministically
NRFCLAW_CLI/nrfclaw_hybrid_semantic.py - Schedule semantics → Text compiler: normalizes schedules
- nRFClaw CLI → BLE programming: programs over BLE
- BLE programming → Firmware coordinator: delivers program
- Firmware coordinator → Bytecode VM: initializes VM
src/main.c - Firmware coordinator → RTC scheduler: initializes scheduler
src/main.c - Firmware coordinator → Persistent state: recovers program
src/main.c - Firmware coordinator → Event system: dispatches events
src/main.c - Event system → Bytecode VM: notifies VM
- Bytecode VM → Sensors and inputs: reads and controls
- Bytecode VM → LoRa transport: sends and receives
- Bytecode VM → Direct BLE/NDP: uses BLE services
- Bytecode VM → RTC scheduler: uses schedules
- LoRa transport → External radios: transmits LoRa
- Direct BLE/NDP → HA device client: serves Direct BLE/NDP
- NinaLink network → External radios: bridges LoRa
- Home Assistant → HA device client: configures integration
- Home Assistant → NinaLink runtime: uses NinaLink
- NinaLink runtime → NinaLink network: communicates with nodes