forked from ruvnet/RuView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnvs_config.h
More file actions
64 lines (54 loc) · 2.68 KB
/
nvs_config.h
File metadata and controls
64 lines (54 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* @file nvs_config.h
* @brief Runtime configuration via NVS (Non-Volatile Storage).
*
* Reads WiFi credentials and aggregator target from NVS.
* Falls back to compile-time Kconfig defaults if NVS keys are absent.
* This allows a single firmware binary to be shipped and configured
* per-device using the provisioning script.
*/
#ifndef NVS_CONFIG_H
#define NVS_CONFIG_H
#include <stdint.h>
/** Maximum lengths for NVS string fields. */
#define NVS_CFG_SSID_MAX 33
#define NVS_CFG_PASS_MAX 65
#define NVS_CFG_IP_MAX 16
/** Maximum channels in the hop list (must match CSI_HOP_CHANNELS_MAX). */
#define NVS_CFG_HOP_MAX 6
/** Runtime configuration loaded from NVS or Kconfig defaults. */
typedef struct {
char wifi_ssid[NVS_CFG_SSID_MAX];
char wifi_password[NVS_CFG_PASS_MAX];
char target_ip[NVS_CFG_IP_MAX];
uint16_t target_port;
uint8_t node_id;
/* ADR-029: Channel hopping and TDM configuration */
uint8_t channel_hop_count; /**< Number of channels to hop (1 = no hop). */
uint8_t channel_list[NVS_CFG_HOP_MAX]; /**< Channel numbers for hopping. */
uint32_t dwell_ms; /**< Dwell time per channel in ms. */
uint8_t tdm_slot_index; /**< This node's TDM slot index (0-based). */
uint8_t tdm_node_count; /**< Total nodes in the TDM schedule. */
/* ADR-039: Edge intelligence configuration */
uint8_t edge_tier; /**< Processing tier (0=raw, 1=basic, 2=full). */
float presence_thresh; /**< Presence threshold (0 = auto-calibrate). */
float fall_thresh; /**< Fall detection threshold (rad/s^2). */
uint16_t vital_window; /**< Phase history window for BPM. */
uint16_t vital_interval_ms; /**< Vitals packet interval (ms). */
uint8_t top_k_count; /**< Number of top subcarriers to track. */
uint8_t power_duty; /**< Power duty cycle (10-100%). */
/* ADR-040: WASM programmable sensing configuration */
uint8_t wasm_max_modules; /**< Max concurrent WASM modules (1-8). */
uint8_t wasm_verify; /**< Require Ed25519 signature for uploads. */
uint8_t wasm_pubkey[32]; /**< Ed25519 public key for WASM signature. */
uint8_t wasm_pubkey_valid; /**< 1 if pubkey was loaded from NVS. */
} nvs_config_t;
/**
* Load configuration from NVS, falling back to Kconfig defaults.
*
* Must be called after nvs_flash_init().
*
* @param cfg Output configuration struct.
*/
void nvs_config_load(nvs_config_t *cfg);
#endif /* NVS_CONFIG_H */