mirror of
https://github.com/ruvnet/RuView.git
synced 2026-05-06 01:45:44 +00:00
* feat: happiness scoring pipeline with ESP32 swarm + Cognitum Seed coordinator ADR-065: Hotel guest happiness scoring from WiFi CSI physiological proxies. ADR-066: ESP32 swarm with Cognitum Seed as coordinator for multi-zone analytics. Firmware: - swarm_bridge.c/h: FreeRTOS task on Core 0, HTTP client with Bearer auth, registers with Seed, sends heartbeats (30s) and happiness vectors (5s) - nvs_config: seed_url, seed_token, zone_name, swarm intervals - provision.py: --seed-url, --seed-token, --zone CLI args - esp32-hello-world: capability discovery firmware for 4MB ESP32-S3 variant WASM edge modules: - exo_happiness_score.rs: 8-dim happiness vector from gait speed, stride regularity, movement fluidity, breathing calm, posture, dwell time (events 690-694, 11 tests, ESP32-optimized buffers + event decimation) - ghost_hunter.rs standalone binary: 5.7 KB WASM, feature-gated default pipeline RuView Live: - --mode happiness dashboard with bar visualization - --seed flag for Cognitum Seed bridge (urllib, background POST) - HappinessScorer + SeedBridge classes (stdlib only, no deps) Examples: - seed_query.py: CLI tool (status, search, witness, monitor, report) - provision_swarm.sh: batch provisioning for multi-node deployment - happiness_vector_schema.json: 8-dim vector format documentation Verified live: ESP32 on COM5 (4MB flash) registered with Seed at 10.1.10.236, vectors flowing, witness chain growing (epoch 455, chain 1108). Co-Authored-By: claude-flow <ruv@ruv.net> * ci: raise firmware binary size gate to 1100 KB for HTTP client stack The swarm bridge (ADR-066) adds esp_http_client for Seed communication, which pulls in the HTTP/TLS stack (~150 KB). Binary grew from ~978 KB to ~1077 KB. Raise the gate from 950 KB to 1100 KB. Still fits comfortably in both 4MB (1856 KB OTA slot, 43% free) and 8MB flash variants. Co-Authored-By: claude-flow <ruv@ruv.net>
67 lines
2.4 KiB
C
67 lines
2.4 KiB
C
/**
|
|
* @file swarm_bridge.h
|
|
* @brief ADR-066: ESP32 Swarm Bridge — Cognitum Seed coordinator client.
|
|
*
|
|
* Registers this node with a Cognitum Seed, sends periodic heartbeats,
|
|
* and pushes happiness vectors for cross-zone analytics.
|
|
* Runs as a FreeRTOS task on Core 0.
|
|
*/
|
|
|
|
#ifndef SWARM_BRIDGE_H
|
|
#define SWARM_BRIDGE_H
|
|
|
|
#include <stdint.h>
|
|
#include "esp_err.h"
|
|
#include "edge_processing.h"
|
|
|
|
/** Happiness vector dimension. */
|
|
#define SWARM_VECTOR_DIM 8
|
|
|
|
/** Swarm bridge configuration. */
|
|
typedef struct {
|
|
char seed_url[64]; /**< Cognitum Seed base URL (e.g. "http://192.168.1.10:8080"). */
|
|
char seed_token[64]; /**< Bearer token for Seed WiFi API auth (from pairing). */
|
|
char zone_name[16]; /**< Zone name for this node (e.g. "bedroom"). */
|
|
uint16_t heartbeat_sec; /**< Heartbeat interval in seconds (default 30). */
|
|
uint16_t ingest_sec; /**< Happiness ingest interval in seconds (default 5). */
|
|
uint8_t enabled; /**< 1 = bridge active, 0 = disabled. */
|
|
} swarm_config_t;
|
|
|
|
/**
|
|
* Initialize the swarm bridge and start the background task.
|
|
* Registers this node with the Cognitum Seed on first successful POST.
|
|
*
|
|
* @param cfg Swarm bridge configuration.
|
|
* @param node_id This node's identifier (from NVS).
|
|
* @return ESP_OK on success, ESP_ERR_INVALID_ARG if seed_url is empty.
|
|
*/
|
|
esp_err_t swarm_bridge_init(const swarm_config_t *cfg, uint8_t node_id);
|
|
|
|
/**
|
|
* Feed the latest vitals packet into the swarm bridge.
|
|
* Called from the main loop whenever new vitals are available.
|
|
*
|
|
* @param vitals Pointer to the latest vitals packet.
|
|
*/
|
|
void swarm_bridge_update_vitals(const edge_vitals_pkt_t *vitals);
|
|
|
|
/**
|
|
* Update the happiness vector to be pushed at the next ingest cycle.
|
|
*
|
|
* @param vector Float array of happiness values.
|
|
* @param dim Number of elements (clamped to SWARM_VECTOR_DIM).
|
|
*/
|
|
void swarm_bridge_update_happiness(const float *vector, uint8_t dim);
|
|
|
|
/**
|
|
* Get cumulative bridge statistics.
|
|
*
|
|
* @param regs Output: number of successful registrations.
|
|
* @param heartbeats Output: number of successful heartbeats sent.
|
|
* @param ingests Output: number of successful happiness ingests sent.
|
|
* @param errors Output: number of HTTP errors encountered.
|
|
*/
|
|
void swarm_bridge_get_stats(uint32_t *regs, uint32_t *heartbeats,
|
|
uint32_t *ingests, uint32_t *errors);
|
|
|
|
#endif /* SWARM_BRIDGE_H */
|