Controller B updates from A: link_peer (pairing over the wire, encrypted credential handoff, B status + commands), ESP-NOW receive/unicast, Updates page with two cards; shared header maintenance frames; docs + wiki
Firmware / build (push) Successful in 7m1s

This commit is contained in:
2026-09-27 20:26:44 +02:00
parent 8338e4e300
commit 3e86ca3733
20 changed files with 884 additions and 50 deletions
+49
View File
@@ -0,0 +1,49 @@
/*
* Link Peer Module (Controller A) - what A knows about Controller B, 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 "Controller B" 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 <Arduino.h>
#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