Commit Graph

7 Commits

Author SHA1 Message Date
Ronny Eia
4af0f1b248 Add chip temperature sensor and RGB LED control, verified live in HA
Quick end-to-end data-flow proof using only what's on the ESP32-C6-
DevKitC-1 itself (no sensors on the bare devkit -- confirmed via
research: BOOT button, WS2812 LED, no external sensors):

- drivers::chip_temperature_* wraps ESP-IDF's built-in
  temperature_sensor driver (SoC die temperature).
- drivers::rgb_led_* wraps the onboard WS2812 (GPIO8) via the
  espressif/led_strip managed component (another external registry
  dependency, like mdns/mqtt).
- profiles::ChipTemperatureSensor is the first real implementation of
  the Sensor interface designed earlier, converting the driver's float
  reading to the fixed-point convention once at the boundary.
- transport/mqtt.cpp publishes chip temperature as an HA "temperature"
  sensor every 30s, and exposes the LED as an HA "light" entity
  (rgb_command_topic) -- the first use of MQTT subscribe in this
  project, not just publish.

Added a ChipTemperature SensorChannel (distinct from
AmbientTemperature -- different meaning/range) to sensor.h.

Verified live: both the chip temperature reading and LED color control
work from Home Assistant against the real device.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 19:27:00 +02:00
Ronny Eia
1bdc19b695 Add MQTT client + Home Assistant Discovery, verified end-to-end
Adds espressif/mqtt and mdns as the project's first external managed
component dependencies (neither ships with ESP-IDF core in v6.0.2
anymore). Once Wi-Fi connects, the device advertises itself on the LAN
as kvida-xxxxxx.local and serves a persistent settings page there for
MQTT broker host/port and credentials -- the ongoing config channel
beyond the one-time Wi-Fi captive portal.

mDNS auto-discovery of _mqtt._tcp was the original plan, but verified
against a real Home Assistant OS + Mosquitto add-on that it doesn't
reliably answer PTR queries on the LAN (confirmed with a raw mDNS
query from the host, parsed properly with dnspython after an earlier
naive byte-check gave a false positive). Manual host/port entry is
now the primary path; mDNS discovery still runs as a secondary
fallback attempt, retried every 30s, in case it works on other
networks.

On MQTT_EVENT_CONNECTED, publishes retained HA MQTT Discovery for a
diagnostic "connectivity" binary_sensor (grouped under a Kvida/Xylon
device block) plus an online/offline availability topic driven by
MQTT's own LWT. Verified end-to-end on real hardware: the device
appears in Home Assistant with a "Connected" Connectivity sensor.

Also extracts url_decode() (previously local to commissioning.cpp)
and a new device_id() helper into shared headers, since both
commissioning's Wi-Fi form and the new MQTT settings form need them.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 18:13:34 +02:00
Ronny Eia
af0c2da146 Add Wi-Fi commissioning: SoftAP captive portal with IPv6 support
Implements first-boot Wi-Fi setup with no companion app required: a
SoftAP + captive portal (DNS wildcard redirect, DHCP option 114, HTTP
form) lets the user submit Wi-Fi credentials from any browser. On
submit, credentials are saved to NVS and the device switches to STA
mode; on subsequent boots it reconnects automatically via stored
credentials. dns_server.c/.h are vendored from ESP-IDF's official
captive_portal example (Unlicense/CC0).

Requests both link-local and global IPv6 addresses once the STA
connection has an IPv4 address (not on WIFI_EVENT_STA_CONNECTED --
esp_netif_create_ip6_linklocal() reliably fails there because
esp-netif's own handler, which marks the lwIP netif "up", hasn't run
yet due to event-handler registration order). Verified end-to-end on
real ESP32-C6 hardware: SoftAP comes up, credential submission works,
STA reconnects on reboot, and both a link-local and a router-assigned
global IPv6 address are obtained via SLAAC.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 21:24:38 +02:00
Ronny Eia
f1be175dc2 Add sensors Sensor interface and a verified host test setup
Sensor/SensorValue in components/sensors/include/sensor.h is modeled
on Zephyr's sensor API: a fetch()/get() split so multi-channel sensors
(e.g. BME280) pay the hardware read cost once, fixed-point SensorValue
(no float/double -- ESP32-C6 has no hardware FPU), a fine-grained
SensorChannel enum, and an optional interrupt-driven set_trigger() for
the battery-first sleep/wake design.

Adds components/sensors/test_apps/host, a self-contained ESP-IDF
project building against the `linux` target so this logic is
host-testable per AGENTS.md's testing philosophy -- verified in a
clean run against the pinned espressif/idf:v6.0.2 image (builds, 4/4
tests pass). Replaces the earlier generic top-level test/README.md
placeholder now that a real per-component pattern exists.

Also fixes .gitignore's build/managed_components patterns to match
nested paths, not just the repo root.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-08 20:44:48 +02:00
Ronny Eia
524714148b Rebuild firmware scaffold for ESP32-C6/ESP-IDF, replacing NCS/Zephyr
The product pivoted away from a Matter-first nRF54L15 device to an
ESP32-C6/ESP-IDF/C++17 platform where behaviour is defined by a
Blockly-generated Lua program instead of custom firmware (see the
updated kvida meta-repo vision). Removes the west/NCS/Zephyr scaffold
and replaces it with:

- A pinned ESP-IDF v6.0.2 Docker build environment (Espressif's
  official image already bundles the toolchain, unlike NCS/west).
- A layered component structure (drivers -> sensors -> profiles ->
  lua_runtime -> transport) matching the new architecture principles,
  with per-component READMEs describing responsibilities.
- An A/B OTA + LittleFS partition table and a minimal main.cpp.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-08 19:54:25 +02:00
Ronny Eia
13406a24a3 Scaffold NCS firmware project structure
Sets up kvida-os as a freestanding nRF Connect SDK application for the
nRF54L15, pinned to NCS v3.4.0, with a Docker/WSL2 build environment
(toolchain-only image, NCS modules fetched into a separate volume at
first run) and placeholder module directories matching the architecture
described in the kvida meta-repo.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-07 21:57:10 +02:00
Ronny Eia
cf18cf2c00 init commit 2026-07-07 21:05:23 +02:00