|
| 1 | +# Configuration |
| 2 | + |
| 3 | +`umesh_cfg_t` controls network identity, role behavior, routing, power profile, and callbacks. |
| 4 | + |
| 5 | +## Core fields |
| 6 | + |
| 7 | +| Field | Type | Meaning | Typical value / default | |
| 8 | +|---|---|---|---| |
| 9 | +| `net_id` | `uint8_t` | Logical network ID. Nodes join only matching networks. | `0x01` | |
| 10 | +| `node_id` | `uint8_t` | Node address. Use unassigned for auto assignment. | `UMESH_ADDR_UNASSIGNED (0xFE)` | |
| 11 | +| `master_key` | `const uint8_t*` | 16-byte key for AUTH/FULL security. | Required for secure mesh | |
| 12 | +| `role` | `umesh_role_t` | Startup role mode. | `UMESH_ROLE_AUTO` recommended | |
| 13 | +| `security` | `umesh_security_t` | Security level (`NONE`, `AUTH`, `FULL`). | `UMESH_SEC_FULL` | |
| 14 | +| `channel` | `uint8_t` | WiFi channel used for raw frames. | default `6` when `0` | |
| 15 | +| `tx_power` | `uint8_t` | PHY TX power setting. | default `60` when `0` | |
| 16 | + |
| 17 | +## Routing and auto-mesh fields |
| 18 | + |
| 19 | +| Field | Type | Meaning | Default when `0` | |
| 20 | +|---|---|---|---| |
| 21 | +| `routing` | `umesh_routing_mode_t` | `DISTANCE_VECTOR` or `GRADIENT`. | `DISTANCE_VECTOR` | |
| 22 | +| `scan_ms` | `uint32_t` | Auto-role scan window before election. | `2000` | |
| 23 | +| `election_ms` | `uint32_t` | Auto-role election timeout. | `1000` | |
| 24 | +| `gradient_beacon_ms` | `uint32_t` | Coordinator gradient beacon period. | `30000` | |
| 25 | +| `gradient_jitter_max_ms` | `uint32_t` | Randomized beacon jitter cap. | `200` | |
| 26 | + |
| 27 | +## Power fields |
| 28 | + |
| 29 | +| Field | Type | Meaning | Default when `0` | |
| 30 | +|---|---|---|---| |
| 31 | +| `power_mode` | `umesh_power_mode_t` | `ACTIVE`, `LIGHT`, or `DEEP`. | `ACTIVE` | |
| 32 | +| `light_sleep_interval_ms` | `uint32_t` | Sleep interval for LIGHT mode. | `1000` | |
| 33 | +| `light_listen_window_ms` | `uint32_t` | RX listen window for LIGHT mode. | `100` | |
| 34 | +| `deep_sleep_tx_interval_ms` | `uint32_t` | Wake/send interval in DEEP mode. | `30000` | |
| 35 | + |
| 36 | +## Callback fields |
| 37 | + |
| 38 | +| Field | Signature | Trigger | |
| 39 | +|---|---|---| |
| 40 | +| `on_joined` | `void (*)(uint8_t node_id)` | Node gets valid ID and joins network | |
| 41 | +| `on_role_elected` | `void (*)(umesh_role_t role)` | Auto election chooses role | |
| 42 | +| `on_node_joined` | `void (*)(uint8_t node_id)` | Peer joined notification | |
| 43 | +| `on_node_left` | `void (*)(uint8_t node_id)` | Peer timeout/leave notification | |
| 44 | +| `on_gradient_ready` | `void (*)(uint8_t distance)` | First valid gradient distance available | |
| 45 | +| `on_sleep` | `void (*)(void)` | Power subsystem enters sleep | |
| 46 | +| `on_wake` | `void (*)(void)` | Power subsystem wakes | |
| 47 | +| `on_error` | `void (*)(umesh_result_t err)` | Internal error callback | |
| 48 | + |
| 49 | +## Minimal recommended config |
| 50 | + |
| 51 | +```c |
| 52 | +umesh_cfg_t cfg = { |
| 53 | + .net_id = 0x01, |
| 54 | + .node_id = UMESH_ADDR_UNASSIGNED, |
| 55 | + .master_key = KEY, |
| 56 | + .role = UMESH_ROLE_AUTO, |
| 57 | + .security = UMESH_SEC_FULL, |
| 58 | + .channel = 6, |
| 59 | + .routing = UMESH_ROUTING_GRADIENT, |
| 60 | +}; |
| 61 | +``` |
0 commit comments