/* * Link Peer Module (Main CTRL) - what A knows about Inst. Cluster, and the * maintenance traffic that keeps B updatable. See * ESP32-S3-LCD-1.3/wiki/pages/controller-b-ota.md (B's wiki). * * STATUS B -> A ESP-NOW unicast every 5 s: B's version, OTA phase, uptime. * Shown on Settings -> Updates as the "Inst. Cluster" card. * PAIR A -> B `link pair` on the console, UART WIRE ONLY: a fresh random * key, kept in NVS on both sides. Both repos are public, so * this is the only secret and it never travels by radio. * SECURE A -> B ESP-NOW unicast, AES-256-GCM under the pairing key: * the remembered Wi-Fi credentials (pushed automatically * whenever B lacks them or they change) and OTA commands. * * Console: link status | pair | unpair | creds | ota check | ota install [force] | ota rollback */ #pragma once #include #include "protocol/automotive_data.h" namespace LinkPeer { /** Load the pairing key, hook the ESP-NOW receive path. After EspNowLink::init(). */ void init(); /** Credential sync + logging. Call from loop(). */ void tick(); typedef struct { bool heard; // STATUS within LINK_STATUS_TIMEOUT_MS uint32_t age_ms; // since the last STATUS uint8_t mac[6]; // B's STA MAC link_status_t st; // last STATUS as received bool paired; // this controller holds a pairing key bool key_match; // B reports the fingerprint of OUR key uint16_t key_fp; // our key's fingerprint (0 = none) } peer_status_t; peer_status_t getStatus(); /** Ask B to check / install (behind the same parking gate as A's own update). */ bool requestCheck(char* why, size_t n); bool requestInstall(char* why, size_t n); bool handleCommand(const char* line); } // namespace LinkPeer