fix(network): pre-merge review fixes

- Guard the boot-time link bootstrap to observer ESP32 builds. It ran
  unconditionally in MyMesh::begin(), breaking every non-observer
  repeater/room server build (ESP32 and nRF52).
- Rename NetworkInterface -> NetworkLink (class, accessor, files).
  Arduino-ESP32 3.x ships its own NetworkInterface class and header,
  which broke the ESP32-C6 builds. Drop WiFi.setAutoConnect(), a no-op
  on 2.x and removed in 3.x.
- Refresh stored Wi-Fi credentials every bridge tick so the STA
  reconnect loop picks up `set wifi.ssid` / `set wifi.pwd` without a
  reboot, as the bridge did before the link moved out of it. Skip
  reconnects while the SSID is empty.
- Restore the "WiFi connected: <ip>" / "WiFi disconnected: reason N"
  debug lines the bridge used to print.
- Alert on Ethernet only once it has held a lease this boot or when no
  Wi-Fi is configured; Wi-Fi-only installs of an Ethernet-preferred
  image keep Wi-Fi alerts instead of reporting "Ethernet down".
- Record wifi.setup_complete only for Ethernet LAN onboarding, so
  Wi-Fi builds keep the SSID-based first-boot portal rule.
- Use seq_cst for the route-switch lock/mutation flag handshake.
- Docs: SNMP RSSI sentinel is -127; describe link-return vs medium-switch
  reconnect behavior accurately; note runtime credential pickup.
- Test: unknown keys inside a known /mqtt.json group are ignored, which
  keeps wifi.setup_complete downgrade-safe.
This commit is contained in:
agessaman committed 2026-09-19 10:14:16 -07:00
1 parent 8ab6a988aa
commit a129420804
14 files changed
+149 -95

No files matched your search

+13 -13
View File
@@ -15,7 +15,7 @@
#include "TxtDataHelpers.h"
#include "AlertReporter.h" // for alertReporterBannedChannelMatch[Hex]()
#include "MQTTObserverValidation.h" // pure input validators (host-testable)
#include "NetworkInterface.h"
#include "NetworkLink.h"
#include <Utils.h>
#include <climits>
#include <new>
@@ -416,9 +416,9 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
// runs on the Arduino loop task, shared with mesh/radio processing and the
// web config batch, so a synchronous wait of up to 30 s would stall the
// node. The sync runs in the background; verify with `get mqtt.ntp.diag`.
if (!activeNetworkInterface().isConnected()) {
if (!activeNetworkLink().isConnected()) {
snprintf(reply, 160, "OK - saved (%s not connected; NTP sync pending)",
activeNetworkInterface().mediumName());
activeNetworkLink().mediumName());
} else if (!_callbacks->isMqttBridgeRunning()) {
strcpy(reply, "OK - saved (MQTT bridge not running)");
} else if (_callbacks->syncMqttNtp()) {
@@ -460,8 +460,8 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
_mqtt_prefs.wifi_power_save = ps_value;
if (!persistObserverPrefs(reply)) return true;
#ifdef ESP_PLATFORM
if (strcmp(activeNetworkInterface().mediumName(), "wifi") == 0 &&
activeNetworkInterface().isConnected()) {
if (strcmp(activeNetworkLink().mediumName(), "wifi") == 0 &&
activeNetworkLink().isConnected()) {
wifi_ps_type_t ps_mode = (ps_value == 1) ? WIFI_PS_NONE :
(ps_value == 2) ? WIFI_PS_MAX_MODEM : WIFI_PS_MIN_MODEM;
esp_err_t ps_result = esp_wifi_set_ps(ps_mode);
@@ -962,9 +962,9 @@ bool CommonCLI::handleObserverGetCmd(uint32_t sender_timestamp, const char* conf
#ifdef ESP_PLATFORM
// Connectivity probe across all configured NTP servers; never updates the clock.
// Serial console (sender_timestamp == 0) gets a detailed table; LoRa gets a compact list.
if (!activeNetworkInterface().isConnected()) {
if (!activeNetworkLink().isConnected()) {
snprintf(reply, 160, "Error: %s not connected",
activeNetworkInterface().mediumName());
activeNetworkLink().mediumName());
} else if (!_callbacks->isMqttBridgeRunning()) {
strcpy(reply, "Error: MQTT bridge not running");
} else if (!_callbacks->runMqttNtpDiag(reply, 160, sender_timestamp == 0)) {
@@ -1039,10 +1039,10 @@ bool CommonCLI::handleObserverGetCmd(uint32_t sender_timestamp, const char* conf
strcpy(reply, _mqtt_prefs.wifi_password[0] ? "> ******** (serial only)" : "> (not set)");
}
} else if (strcmp(config, "link.diag") == 0) {
activeNetworkInterface().formatDiagnostics(reply, 160);
activeNetworkLink().formatDiagnostics(reply, 160);
} else if (memcmp(config, "link.status", 11) == 0 ||
memcmp(config, "wifi.status", 11) == 0) {
NetworkInterface& network = activeNetworkInterface();
NetworkLink& network = activeNetworkLink();
const bool wifi_alias = config[0] == 'w';
if (wifi_alias && strcmp(network.mediumName(), "wifi") != 0) {
snprintf(reply, 160, "> n/a (%s selected; use get link.status)",
@@ -1181,9 +1181,9 @@ bool CommonCLI::handleObserverCommand(uint32_t sender_timestamp, char* command,
#ifdef WITH_MQTT_BRIDGE
if (memcmp(command, "tls.bundletest ", 15) == 0) {
#ifdef ESP_PLATFORM
if (!activeNetworkInterface().isConnected()) {
if (!activeNetworkLink().isConnected()) {
snprintf(reply, 160, "ERR: %s not connected",
activeNetworkInterface().mediumName());
activeNetworkLink().mediumName());
} else {
size_t bundle_len = 0;
if (rootca_crt_bundle_start != nullptr &&
@@ -1228,9 +1228,9 @@ bool CommonCLI::handleObserverCommand(uint32_t sender_timestamp, char* command,
// ota check -> report available build, do not flash
// ota update -> download and flash, then reboot
#if defined(WITH_MQTT_BRIDGE) && defined(OTA_MANIFEST_BASE)
if (!activeNetworkInterface().isConnected()) {
if (!activeNetworkLink().isConnected()) {
snprintf(reply, 160, "ERR: %s not connected",
activeNetworkInterface().mediumName());
activeNetworkLink().mediumName());
} else if (memcmp(command, "ota check", 9) == 0) {
// Check is synchronous so its result lands in this reply, and runs with the
// MQTT bridge UP: the slim per-variant manifest is tiny, so the fetch only