feat: prepare v1.16.07 firmware release
This commit is contained in:
1 parent
129e687c02
commit
ccce0c8d75
95 files changed
+5550
-278
No files matched your search
@@ -65,6 +65,7 @@ public:
|
||||
virtual bool getBootloaderVersion(char* version, size_t max_len) { return false; }
|
||||
virtual bool startOTAUpdate(const char* id, char reply[]) { return false; } // not supported
|
||||
virtual bool stopOTAUpdate(char reply[]) { return false; } // not supported
|
||||
virtual bool isOTAUpdateRunning() const { return false; }
|
||||
// Pull-based OTA: fetch the firmware build for this variant from a baked-in manifest and flash it.
|
||||
// current_ver is the running firmware version string (used to skip if already up to date); when
|
||||
// dry_run is true the build is only reported, not flashed. Observer (ESP32+WiFi) builds only.
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
namespace mesh {
|
||||
namespace cli {
|
||||
|
||||
// Mobile keyboards commonly capitalize the first word entered into a CLI
|
||||
// field. Command verbs are identifiers, so normalize only that first token and
|
||||
// leave every argument (names, passwords, keys, and other values) untouched.
|
||||
inline void normalizeCommandVerb(char* command) {
|
||||
if (command == nullptr) return;
|
||||
|
||||
while (*command == ' ' || *command == '\t') command++;
|
||||
while (*command != 0 && *command != ' ' && *command != '\t') {
|
||||
if (*command >= 'A' && *command <= 'Z') {
|
||||
*command = static_cast<char>(*command - 'A' + 'a');
|
||||
}
|
||||
command++;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace mesh
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include "CommonCLI.h"
|
||||
#include "CLICommandUtils.h"
|
||||
#include "TxtDataHelpers.h"
|
||||
#include "AdvertDataHelpers.h"
|
||||
#include "AlertReporter.h" // for alertReporterBannedChannelMatch()
|
||||
@@ -1751,6 +1752,8 @@ uint8_t CommonCLI::buildAdvertData(uint8_t node_type, uint8_t* app_data) {
|
||||
}
|
||||
|
||||
void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* reply) {
|
||||
mesh::cli::normalizeCommandVerb(command);
|
||||
|
||||
// Observer-only top-level commands (ota check/update, tls.bundletest, alert test)
|
||||
// live in CommonCLI_Observer.cpp.
|
||||
if (handleObserverCommand(sender_timestamp, command, reply)) return;
|
||||
@@ -1787,6 +1790,20 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
} else {
|
||||
strcpy(reply, "ERR: clock cannot go backwards");
|
||||
}
|
||||
#if defined(ESP_PLATFORM) && defined(ADMIN_PASSWORD) && !defined(WEBCONFIG_DISABLED)
|
||||
} else if (memcmp(command, "start webconfig", 15) == 0
|
||||
&& (command[15] == 0 || command[15] == ' ')) {
|
||||
const bool force_ap = command[15] == ' ' && strcmp(&command[16], "ap") == 0;
|
||||
if (command[15] == ' ' && !force_ap) {
|
||||
strcpy(reply, "ERR: usage start webconfig [ap]");
|
||||
} else if (!_callbacks->startWebConfig(force_ap, reply)) {
|
||||
strcpy(reply, "ERR: webconfig not supported on this build");
|
||||
}
|
||||
} else if (strcmp(command, "stop webconfig") == 0) {
|
||||
if (!_callbacks->stopWebConfig(reply)) {
|
||||
strcpy(reply, "ERR: webconfig not supported on this build");
|
||||
}
|
||||
#endif
|
||||
#ifdef ESP_PLATFORM
|
||||
} else if (memcmp(command, "memory", 6) == 0) {
|
||||
sprintf(reply, "Free: %d, Min: %d, Max: %d, Queue: %d, IntFree: %d, IntMax: %d, PSRAM: %d/%d",
|
||||
@@ -1799,6 +1816,11 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
#endif
|
||||
} else if (memcmp(command, "start ota", 9) == 0 && (command[9] == 0 || command[9] == ' ')) {
|
||||
// Manual OTA: bring up the board's browser server for a hand-uploaded binary.
|
||||
#if defined(ESP_PLATFORM) && defined(ADMIN_PASSWORD) && !defined(WEBCONFIG_DISABLED)
|
||||
if (_callbacks->isWebConfigActive()) {
|
||||
strcpy(reply, "ERR: stop webconfig first");
|
||||
} else
|
||||
#endif
|
||||
if (!_board->startOTAUpdate(_prefs->node_name, reply)) {
|
||||
strcpy(reply, "Error");
|
||||
}
|
||||
@@ -1977,7 +1999,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
}
|
||||
} else if (memcmp(command, "gps sync", 8) == 0) {
|
||||
LocationProvider * l = _sensors->getLocationProvider();
|
||||
if (l != NULL) {
|
||||
if (!_prefs->gps_enabled) {
|
||||
strcpy(reply, "gps is off");
|
||||
} else if (l != NULL) {
|
||||
l->syncTime();
|
||||
strcpy(reply, "scheduled");
|
||||
} else {
|
||||
@@ -2157,6 +2181,22 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
|
||||
void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* reply) {
|
||||
const char* config = &command[4];
|
||||
#if defined(ESP_PLATFORM) && defined(ADMIN_PASSWORD) && !defined(WEBCONFIG_DISABLED)
|
||||
if (memcmp(config, "webui ", 6) == 0) {
|
||||
const char* value = &config[6];
|
||||
bool enabled;
|
||||
if (strcmp(value, "on") == 0) enabled = true;
|
||||
else if (strcmp(value, "off") == 0) enabled = false;
|
||||
else {
|
||||
strcpy(reply, "Error: usage set webui on|off");
|
||||
return;
|
||||
}
|
||||
if (!_callbacks->setWebUIEnabled(enabled, reply)) {
|
||||
strcpy(reply, "Error: webui not supported on this build");
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// Observer/MQTT/WiFi/timezone/alert/SNMP commands live in CommonCLI_Observer.cpp.
|
||||
if (handleObserverSetCmd(sender_timestamp, config, reply)) return;
|
||||
if (isAdvancedRetryConfig(config) && !_callbacks->supportsAdvancedRetryConfig()) {
|
||||
@@ -2967,6 +3007,14 @@ void CommonCLI::handleSetCmd(uint32_t sender_timestamp, char* command, char* rep
|
||||
|
||||
void CommonCLI::handleGetCmd(uint32_t sender_timestamp, char* command, char* reply) {
|
||||
const char* config = &command[4];
|
||||
#if defined(ESP_PLATFORM) && defined(ADMIN_PASSWORD) && !defined(WEBCONFIG_DISABLED)
|
||||
if (strcmp(config, "webui") == 0) {
|
||||
if (!_callbacks->getWebUIStatus(reply)) {
|
||||
strcpy(reply, "Error: webui not supported on this build");
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// Observer/MQTT/WiFi/timezone/alert/SNMP commands live in CommonCLI_Observer.cpp.
|
||||
if (handleObserverGetCmd(sender_timestamp, config, reply)) return;
|
||||
if (isAdvancedRetryConfig(config) && !_callbacks->supportsAdvancedRetryConfig()) {
|
||||
|
||||
@@ -466,6 +466,32 @@ public:
|
||||
return false;
|
||||
};
|
||||
|
||||
// Browser-based configuration portal. ESP32 infrastructure roles override
|
||||
// these; force_ap=true asks for the captive SoftAP even when WiFi is set.
|
||||
#if defined(ESP_PLATFORM) && defined(ADMIN_PASSWORD) && !defined(WEBCONFIG_DISABLED)
|
||||
virtual bool startWebConfig(bool force_ap, char* reply) {
|
||||
(void)force_ap;
|
||||
(void)reply;
|
||||
return false;
|
||||
};
|
||||
virtual bool stopWebConfig(char* reply) {
|
||||
(void)reply;
|
||||
return false;
|
||||
};
|
||||
virtual bool isWebConfigActive() const {
|
||||
return false;
|
||||
};
|
||||
virtual bool setWebUIEnabled(bool enabled, char* reply) {
|
||||
(void)enabled;
|
||||
(void)reply;
|
||||
return false;
|
||||
};
|
||||
virtual bool getWebUIStatus(char* reply) const {
|
||||
(void)reply;
|
||||
return false;
|
||||
};
|
||||
#endif
|
||||
|
||||
virtual int getQueueSize() {
|
||||
return 0; // no op by default
|
||||
};
|
||||
|
||||
@@ -385,12 +385,14 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
|
||||
} else if (memcmp(subcmd, "server ", 7) == 0) {
|
||||
StrHelper::strncpy(_mqtt_prefs.mqtt_slot_host[slot], &subcmd[7], sizeof(_mqtt_prefs.mqtt_slot_host[slot]));
|
||||
savePrefs();
|
||||
_callbacks->restartBridgeSlot(slot);
|
||||
strcpy(reply, "OK");
|
||||
} else if (memcmp(subcmd, "port ", 5) == 0) {
|
||||
int port = atoi(&subcmd[5]);
|
||||
if (port > 0 && port <= 65535) {
|
||||
_mqtt_prefs.mqtt_slot_port[slot] = port;
|
||||
savePrefs();
|
||||
_callbacks->restartBridgeSlot(slot);
|
||||
strcpy(reply, "OK");
|
||||
} else {
|
||||
strcpy(reply, "Error: port must be between 1 and 65535");
|
||||
@@ -457,6 +459,10 @@ bool CommonCLI::handleObserverSetCmd(uint32_t sender_timestamp, const char* conf
|
||||
savePrefs();
|
||||
_callbacks->restartBridgeSlot(slot);
|
||||
strcpy(reply, "OK");
|
||||
} else if (strcmp(config, "mqtt.owner") == 0 || strcmp(config, "mqtt.owner ") == 0) {
|
||||
_mqtt_prefs.mqtt_owner_public_key[0] = '\0';
|
||||
savePrefs();
|
||||
strcpy(reply, "OK - owner cleared");
|
||||
} else if (memcmp(config, "mqtt.owner ", 11) == 0) {
|
||||
const char* owner_key = &config[11];
|
||||
int key_len = strlen(owner_key);
|
||||
|
||||
@@ -177,6 +177,7 @@ public:
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
bool stopOTAUpdate(char reply[]) override;
|
||||
bool isOTAUpdateRunning() const override { return ota_server != nullptr; }
|
||||
bool otaFromManifest(const char* current_ver, bool dry_run, char reply[]) override;
|
||||
// Heavy body (TLS + JSON / HTTPUpdate). Runs in a dedicated large-stack task
|
||||
// spawned by otaFromManifest() — public only so that task entry point can call
|
||||
|
||||
@@ -260,6 +260,36 @@ void MQTTBridge::formatMqttStatusReply(char* buf, size_t bufsize, const MQTTPref
|
||||
snprintf(buf + pos, bufsize - pos, ", q:%d", q);
|
||||
}
|
||||
|
||||
bool MQTTBridge::getSlotStatusSnapshot(int slot_index, SlotStatusSnapshot* out) {
|
||||
if (!out || slot_index < 0 || slot_index >= RUNTIME_MQTT_SLOTS) return false;
|
||||
if (!s_mqtt_bridge_instance || !s_mqtt_bridge_instance->_initialized) return false;
|
||||
|
||||
MQTTBridge* bridge = s_mqtt_bridge_instance;
|
||||
const MQTTSlot& slot = bridge->_slots[slot_index];
|
||||
if (!slot.enabled && slot.preset) {
|
||||
out->name = slot.preset->name;
|
||||
out->state = "inactive";
|
||||
} else if (!slot.enabled) {
|
||||
return false;
|
||||
} else {
|
||||
out->name = slot.preset ? slot.preset->name : MQTT_PRESET_CUSTOM;
|
||||
if (!bridge->isSlotReady(slot_index)) {
|
||||
out->state = "wait";
|
||||
} else if (slot.connected) {
|
||||
out->state = "ok";
|
||||
} else if (slot.circuit_breaker_tripped) {
|
||||
out->state = "fail";
|
||||
} else {
|
||||
out->state = "disc";
|
||||
}
|
||||
}
|
||||
|
||||
out->has_publish_counts = false;
|
||||
out->publish_ok = 0;
|
||||
out->publish_err = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t MQTTBridge::getLastWifiDisconnectReason() { return s_wifi_disconnect_reason; }
|
||||
unsigned long MQTTBridge::getLastWifiDisconnectTime() { return s_wifi_disconnect_time; }
|
||||
|
||||
@@ -2097,7 +2127,7 @@ bool MQTTBridge::handleWiFiConnection(unsigned long now) {
|
||||
} else if (ps_pref == 2) {
|
||||
ps_mode = WIFI_PS_MAX_MODEM;
|
||||
} else {
|
||||
ps_mode = WIFI_PS_NONE; // default: no power save; eliminates DTIM wake latency on mains-powered bridges
|
||||
ps_mode = WIFI_PS_MIN_MODEM;
|
||||
}
|
||||
esp_wifi_set_ps(ps_mode);
|
||||
#ifdef MQTT_WIFI_TX_POWER
|
||||
|
||||
@@ -502,6 +502,17 @@ public:
|
||||
/** True after this bridge has successfully set the RTC from NTP this boot. */
|
||||
bool hasNtpTime() const { return _ntp_synced; }
|
||||
static void formatMqttStatusReply(char* buf, size_t bufsize, const MQTTPrefs* obs);
|
||||
// Structured status used by the browser configuration page. Publish
|
||||
// counters are optional because not every supported PsychicMqttClient
|
||||
// version exposes them.
|
||||
struct SlotStatusSnapshot {
|
||||
const char* name;
|
||||
const char* state;
|
||||
bool has_publish_counts;
|
||||
unsigned long publish_ok;
|
||||
unsigned long publish_err;
|
||||
};
|
||||
static bool getSlotStatusSnapshot(int slot_index, SlotStatusSnapshot* out);
|
||||
/** True when WiFi is set and at least one MQTT slot can run (preset + custom host if needed). */
|
||||
static bool isConfigValid(const MQTTPrefs* obs);
|
||||
static void formatSlotDiagReply(char* buf, size_t bufsize, int slot_index);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,237 @@
|
||||
#pragma once
|
||||
|
||||
// Shared browser configuration portal for ESP32 infrastructure and WiFi
|
||||
// companion builds. The UI removes MQTT controls when no bridge is present.
|
||||
//
|
||||
// Two modes:
|
||||
// - SETUP: open SoftAP + captive portal, raised automatically on first boot
|
||||
// when no WiFi is configured (wifi_ssid empty), or manually via
|
||||
// `start webconfig ap`. Save -> reboot; auto-stops after an idle timeout.
|
||||
// - LAN: bound to an existing or portal-owned STA connection. Infrastructure
|
||||
// roles require the node admin password; companions use their trusted LAN.
|
||||
//
|
||||
// Concurrency model: AsyncWebServer handlers run on the async_tcp task and
|
||||
// must never touch the CLI, prefs persistence, or the radio. Config writes
|
||||
// are marshaled into a single-slot command batch that tick() - called from
|
||||
// MyMesh::loop() on the Arduino loop task - drains through the existing CLI
|
||||
// `set` handlers. Prefs-struct reads and batch state are guarded by _mux.
|
||||
//
|
||||
// The master switch and standalone WiFi credentials use independent NVS
|
||||
// namespaces, so role-specific prefs-file layouts remain untouched.
|
||||
|
||||
#if defined(ESP_PLATFORM) && !defined(WEBCONFIG_DISABLED)
|
||||
|
||||
#define WITH_WEBCONFIG 1
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
|
||||
class AsyncWebServer;
|
||||
class AsyncWebServerRequest;
|
||||
class DNSServer;
|
||||
|
||||
#ifndef WEBCONFIG_AP_IDLE_TIMEOUT_MS
|
||||
#define WEBCONFIG_AP_IDLE_TIMEOUT_MS (10UL * 60UL * 1000UL)
|
||||
#endif
|
||||
#ifndef WEBCONFIG_SESSION_TTL_MS
|
||||
#define WEBCONFIG_SESSION_TTL_MS (20UL * 60UL * 1000UL)
|
||||
#endif
|
||||
|
||||
class WebConfigServer {
|
||||
public:
|
||||
enum Mode : uint8_t { MODE_OFF = 0, MODE_SETUP, MODE_CONNECTING, MODE_LAN };
|
||||
|
||||
enum Capability : uint32_t {
|
||||
CAP_LOCATION = 1UL << 0,
|
||||
CAP_AIRTIME = 1UL << 1,
|
||||
CAP_RX_DELAY = 1UL << 2,
|
||||
CAP_CAD = 1UL << 3,
|
||||
CAP_RX_GAIN = 1UL << 4,
|
||||
CAP_REPEAT = 1UL << 5,
|
||||
CAP_ADVERT = 1UL << 6,
|
||||
CAP_FLOOD = 1UL << 7,
|
||||
CAP_LOOP = 1UL << 8,
|
||||
CAP_TX_DELAY = 1UL << 9,
|
||||
CAP_WIFI_POWER_SAVE = 1UL << 10,
|
||||
CAP_DELAYS = CAP_RX_DELAY | CAP_TX_DELAY,
|
||||
};
|
||||
|
||||
// Role-neutral snapshot. Infrastructure and companion builds have different
|
||||
// persisted NodePrefs layouts, so the portal never casts either one or
|
||||
// assumes their member offsets match.
|
||||
struct NodeSnapshot {
|
||||
char name[32];
|
||||
char admin_password[32]; // empty = trusted LAN/no login prompt
|
||||
double lat;
|
||||
double lon;
|
||||
float freq;
|
||||
float bw;
|
||||
float airtime_factor;
|
||||
float rx_delay;
|
||||
float tx_delay;
|
||||
int8_t tx_power;
|
||||
uint8_t sf;
|
||||
uint8_t cr;
|
||||
uint8_t cad;
|
||||
uint8_t rx_gain;
|
||||
uint8_t repeat;
|
||||
uint16_t advert_interval;
|
||||
uint8_t flood_advert_interval;
|
||||
uint8_t flood_max;
|
||||
uint8_t flood_max_advert;
|
||||
uint8_t flood_max_unscoped;
|
||||
uint8_t loop_detect;
|
||||
uint32_t capabilities;
|
||||
};
|
||||
|
||||
class Callbacks {
|
||||
public:
|
||||
virtual void getNodeSnapshot(NodeSnapshot& snapshot) = 0;
|
||||
// Run one CLI command. Called from tick() only (loop task); reply is 160 bytes.
|
||||
virtual void execCommand(char* cmd, char* reply) = 0;
|
||||
virtual void rebootNow() = 0;
|
||||
// Bracket a config batch so bridge restarts triggered by individual
|
||||
// `set` handlers can be coalesced into one.
|
||||
virtual void onConfigBatchStart() {}
|
||||
virtual void onConfigBatchEnd() {}
|
||||
// Fill buf with the stats JSON snapshot. Called from tick() (loop task).
|
||||
virtual void buildStatsJson(char* buf, size_t buf_size) = 0;
|
||||
// Teardown finished (server + DNS freed, WiFi mode restored).
|
||||
virtual void onWebConfigStopped() {}
|
||||
};
|
||||
|
||||
// mqtt_prefs is an MQTTPrefs* on WITH_MQTT_BRIDGE builds and NULL otherwise.
|
||||
// owns_wifi is true when the portal itself brought up STA/AP (normal
|
||||
// repeater/room-server builds), false when the companion/MQTT runtime owns it.
|
||||
WebConfigServer(Callbacks* callbacks, void* mqtt_prefs, bool owns_wifi,
|
||||
const uint8_t* pub_key, const char* fw_ver,
|
||||
const char* role, const char* board_name);
|
||||
~WebConfigServer();
|
||||
|
||||
// For the device display: true while a setup-mode portal is active.
|
||||
// Fills the AP SSID and portal IP; either buffer may be NULL to just poll.
|
||||
// Call from the loop task only (same task that changes the mode).
|
||||
static bool getSetupInfo(char* ssid, size_t ssid_len, char* ip, size_t ip_len);
|
||||
|
||||
// For the device display: true once a config save completed and the node is
|
||||
// about to reboot — ground truth for the user even if the browser lost its
|
||||
// connection before the confirmation arrived. Loop task only.
|
||||
static bool isRebootPending();
|
||||
|
||||
// Persistent master switch and standalone WiFi credentials use separate NVS
|
||||
// namespaces. This avoids changing NodePrefs or MQTTPrefs file layouts.
|
||||
static bool loadEnabled(bool default_value = false);
|
||||
static bool saveEnabled(bool enabled);
|
||||
static bool loadStandaloneWiFi(char* ssid, size_t ssid_len,
|
||||
char* password, size_t password_len,
|
||||
uint8_t* power_save = NULL);
|
||||
static bool saveStandaloneWiFi(const char* ssid, const char* password,
|
||||
uint8_t power_save);
|
||||
|
||||
// UI tasks use an otherwise-unused multi-click gesture without reaching into
|
||||
// MyMesh directly. The mesh loop consumes the request and performs the NVS /
|
||||
// WiFi transition on its own task.
|
||||
static void requestToggleFromButton();
|
||||
static bool takeButtonToggleRequest();
|
||||
|
||||
bool startSetupMode(char reply[]); // open SoftAP + DNS captive portal
|
||||
bool startLanMode(char reply[]); // bind to existing STA connection
|
||||
bool startAutoMode(char reply[]); // use saved WiFi, or setup AP when absent
|
||||
void requestStop(); // stop listening now, free after grace period
|
||||
void tick(uint32_t now); // call every loop iteration
|
||||
|
||||
Mode mode() const { return _mode; }
|
||||
bool isRunning() const { return _mode != MODE_OFF; }
|
||||
bool isStopping() const { return _stopping; }
|
||||
|
||||
private:
|
||||
static const int MAX_BATCH = 24;
|
||||
static const size_t MAX_BODY = 4096;
|
||||
enum BatchState : uint8_t { BATCH_IDLE = 0, BATCH_PENDING, BATCH_DONE };
|
||||
struct BatchEntry {
|
||||
char key[24]; // allowlisted `set` key (echoed back to the UI)
|
||||
char cmd[160]; // full CLI command (may contain secrets - never echoed)
|
||||
char reply[160];
|
||||
};
|
||||
|
||||
Callbacks* _cb;
|
||||
void* _mqtt_prefs;
|
||||
bool _owns_wifi;
|
||||
const uint8_t* _pub_key;
|
||||
const char* _fw_ver;
|
||||
const char* _role;
|
||||
const char* _board_name;
|
||||
|
||||
AsyncWebServer* _server = NULL;
|
||||
DNSServer* _dns = NULL;
|
||||
SemaphoreHandle_t _mux;
|
||||
Mode _mode = MODE_OFF;
|
||||
bool _stopping = false;
|
||||
bool _was_setup_ap = false;
|
||||
uint32_t _connect_deadline = 0;
|
||||
char _wifi_ssid[32] = {0};
|
||||
char _wifi_password[64] = {0};
|
||||
uint8_t _wifi_power_save = 1;
|
||||
char _ap_ssid[33] = {0};
|
||||
|
||||
// Most-recently-created instance, for the display's getSetupInfo() poll.
|
||||
static WebConfigServer* _active;
|
||||
|
||||
// Command batch: filled by async_tcp under _mux, drained by tick().
|
||||
volatile BatchState _batch_state = BATCH_IDLE;
|
||||
uint8_t _batch_count = 0;
|
||||
uint8_t _batch_next = 0; // drain progress (one command per tick)
|
||||
uint32_t _batch_last_cmd = 0;
|
||||
bool _batch_reboot = false;
|
||||
bool _batch_reboot_armed = false;
|
||||
bool _standalone_wifi_dirty = false;
|
||||
BatchEntry _batch[MAX_BATCH];
|
||||
|
||||
// LAN-mode session (single slot; new login evicts the old session)
|
||||
char _session_token[33] = {0};
|
||||
uint32_t _session_last_seen = 0;
|
||||
uint8_t _login_fails = 0;
|
||||
uint32_t _login_lock_until = 0;
|
||||
|
||||
// Once set (via /api/portal/exit), OS captive probes get native "success"
|
||||
// replies so the phone's sign-in sheet can be dismissed without dropping the
|
||||
// WiFi, letting the user continue in their real browser. async_tcp-task only.
|
||||
volatile bool _captive_release = false;
|
||||
|
||||
// Save-path diagnostics: 1 Hz serial trace for 60 s after each config POST
|
||||
// (AP station count, heap, batch state) to pinpoint client drops on hardware.
|
||||
volatile uint32_t _diag_until = 0;
|
||||
uint32_t _diag_last = 0;
|
||||
|
||||
volatile uint32_t _last_activity = 0;
|
||||
uint32_t _reboot_at = 0; // 0 = none scheduled
|
||||
uint32_t _delete_at = 0; // deferred teardown deadline
|
||||
volatile uint32_t _stats_wanted_until = 0;
|
||||
uint32_t _stats_built_at = 0;
|
||||
char _stats_json[1024] = {0};
|
||||
|
||||
void createServer();
|
||||
void registerRoutes();
|
||||
void drainBatch(uint32_t now);
|
||||
void finalizeTeardown();
|
||||
bool checkAuth(AsyncWebServerRequest* req);
|
||||
static void collectBody(AsyncWebServerRequest* req, uint8_t* data, size_t len,
|
||||
size_t index, size_t total);
|
||||
|
||||
void handleRoot(AsyncWebServerRequest* req);
|
||||
void handleStatus(AsyncWebServerRequest* req);
|
||||
void handleLogin(AsyncWebServerRequest* req);
|
||||
void handleLogout(AsyncWebServerRequest* req);
|
||||
void handleConfigGet(AsyncWebServerRequest* req);
|
||||
void handleConfigPost(AsyncWebServerRequest* req);
|
||||
void handleConfigResult(AsyncWebServerRequest* req);
|
||||
void handleStats(AsyncWebServerRequest* req);
|
||||
void handleScan(AsyncWebServerRequest* req);
|
||||
void handlePresets(AsyncWebServerRequest* req);
|
||||
void handleReboot(AsyncWebServerRequest* req);
|
||||
void handlePortalExit(AsyncWebServerRequest* req);
|
||||
void handleNotFound(AsyncWebServerRequest* req);
|
||||
};
|
||||
|
||||
#endif // ESP_PLATFORM && !WEBCONFIG_DISABLED
|
||||
@@ -94,6 +94,9 @@ void SerialEthernetInterface::enable() {
|
||||
|
||||
void SerialEthernetInterface::disable() {
|
||||
_isEnabled = false;
|
||||
deviceConnected = false;
|
||||
if (client) client.stop();
|
||||
clearBuffers();
|
||||
}
|
||||
|
||||
size_t SerialEthernetInterface::writeFrame(const uint8_t src[], size_t len) {
|
||||
@@ -153,9 +156,8 @@ size_t SerialEthernetInterface::checkRecvFrame(uint8_t dest[]) {
|
||||
ETHERNET_DEBUG_PRINTLN("Closing previous client");
|
||||
client.stop();
|
||||
}
|
||||
_state = RECV_STATE_IDLE;
|
||||
_frame_len = 0;
|
||||
_rx_len = 0;
|
||||
// Queued replies and partial input belong to the previous TCP session.
|
||||
clearBuffers();
|
||||
client = newClient;
|
||||
ETHERNET_DEBUG_PRINTLN("Switched to new client");
|
||||
}
|
||||
@@ -172,9 +174,13 @@ size_t SerialEthernetInterface::checkRecvFrame(uint8_t dest[]) {
|
||||
deviceConnected = true;
|
||||
}
|
||||
} else {
|
||||
if (deviceConnected) {
|
||||
bool wasConnected = deviceConnected;
|
||||
if (wasConnected || send_queue_len > 0 || _state != RECV_STATE_IDLE) {
|
||||
deviceConnected = false;
|
||||
ETHERNET_DEBUG_PRINTLN("Disconnected");
|
||||
clearBuffers();
|
||||
if (wasConnected) {
|
||||
ETHERNET_DEBUG_PRINTLN("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
// AUTO-GENERATED by tools/mota/gen_targets.py — do not edit by hand.
|
||||
// 514 OTA-capable PlatformIO envs. Maps target_id (= sha2-256:4 of the env name, LE uint32)
|
||||
// 545 OTA-capable PlatformIO envs. Maps target_id (= sha2-256:4 of the env name, LE uint32)
|
||||
// to the human-readable env name, so a node/tool can name a target seen over the air WITHOUT
|
||||
// transmitting the string in the .mota / LoRa protocol. Regenerate when the OTA env set changes.
|
||||
|
||||
@@ -59,6 +59,22 @@ inline const char* ota_target_env_name(uint32_t target_id) {
|
||||
{ 0x9e40157c, "Heltec_E290_repeater_bridge_espnow" },
|
||||
{ 0xb12e6e01, "Heltec_E290_room_server" },
|
||||
{ 0xf6f835ec, "Heltec_mesh_solar_repeater" },
|
||||
{ 0x7fab017f, "heltec_rc32_companion_radio_ble" },
|
||||
{ 0xf310a4d1, "heltec_rc32_companion_radio_usb" },
|
||||
{ 0xdd5953ec, "heltec_rc32_companion_radio_wifi" },
|
||||
{ 0x97574bc2, "heltec_rc32_kiss_modem" },
|
||||
{ 0x2d918a3c, "heltec_rc32_repeater" },
|
||||
{ 0xd1755faa, "heltec_rc32_repeater_bridge_espnow" },
|
||||
{ 0x8a6ceaf0, "heltec_rc32_room_server" },
|
||||
{ 0x57f69746, "heltec_rc32_sensor" },
|
||||
{ 0xbc05d6a7, "heltec_rc32_terminal_chat" },
|
||||
{ 0x5bad80f1, "heltec_rc32_without_display_companion_radio_ble" },
|
||||
{ 0x112d34c4, "heltec_rc32_without_display_companion_radio_usb" },
|
||||
{ 0xf10a26df, "heltec_rc32_without_display_companion_radio_wifi" },
|
||||
{ 0xc5409ced, "heltec_rc32_without_display_repeater" },
|
||||
{ 0xf9022545, "heltec_rc32_without_display_repeater_bridge_espnow" },
|
||||
{ 0x2023036d, "heltec_rc32_without_display_room_server" },
|
||||
{ 0x4abd24af, "heltec_rc32_without_display_sensor" },
|
||||
{ 0x35d42b35, "Heltec_t096_companion_radio_ble_femoff" },
|
||||
{ 0x9f736ca7, "Heltec_t096_companion_radio_ble_femon" },
|
||||
{ 0x3fbb1498, "Heltec_t096_companion_radio_usb_femoff" },
|
||||
@@ -91,8 +107,6 @@ inline const char* ota_target_env_name(uint32_t target_id) {
|
||||
{ 0x85a8c944, "Heltec_tower_v2_repeater" },
|
||||
{ 0xb16009a0, "heltec_tracker_v2_companion_radio_ble_femoff" },
|
||||
{ 0xdc780e80, "heltec_tracker_v2_companion_radio_ble_femon" },
|
||||
{ 0x9b1ab06d, "heltec_tracker_v2_companion_radio_ble_ps_femoff" },
|
||||
{ 0x9cedf289, "heltec_tracker_v2_companion_radio_ble_ps_femon" },
|
||||
{ 0x4aa63180, "heltec_tracker_v2_companion_radio_usb_femoff" },
|
||||
{ 0x6fddcbf1, "heltec_tracker_v2_companion_radio_usb_femon" },
|
||||
{ 0xf4fb5484, "heltec_tracker_v2_companion_radio_wifi_femoff" },
|
||||
@@ -126,24 +140,38 @@ inline const char* ota_target_env_name(uint32_t target_id) {
|
||||
{ 0x21519537, "Heltec_v3_sensor" },
|
||||
{ 0x382bb181, "Heltec_v3_terminal_chat" },
|
||||
{ 0x5a2980e6, "heltec_v4_3_companion_radio_ble_femoff" },
|
||||
{ 0x90581c83, "heltec_v4_3_companion_radio_ble_ps_femoff" },
|
||||
{ 0x356df17c, "heltec_v4_3_companion_radio_usb_femoff" },
|
||||
{ 0x99a084fc, "heltec_v4_3_companion_radio_wifi_femoff" },
|
||||
{ 0x64c9dfc9, "heltec_v4_3_companion_radio_wifi_mqtt_femoff" },
|
||||
{ 0xe65a7dfd, "heltec_v4_3_expansionkit_tft_companion_radio_ble_ps_femoff" },
|
||||
{ 0x2a2ffc92, "heltec_v4_3_expansionkit_tft_companion_radio_ble_femoff" },
|
||||
{ 0x2c13b8e9, "heltec_v4_3_tft_companion_radio_ble_femoff" },
|
||||
{ 0xb016979a, "heltec_v4_3_tft_companion_radio_usb_femoff" },
|
||||
{ 0xb49b6b55, "heltec_v4_3_tft_companion_radio_wifi_femoff" },
|
||||
{ 0x86fb85f0, "heltec_v4_companion_radio_ble_femon" },
|
||||
{ 0xd33b0986, "heltec_v4_companion_radio_ble_ps_femon" },
|
||||
{ 0xa8f5940f, "heltec_v4_companion_radio_usb_femon" },
|
||||
{ 0x86ac3b1b, "heltec_v4_companion_radio_wifi_femon" },
|
||||
{ 0x7af848da, "heltec_v4_companion_radio_wifi_mqtt_femon" },
|
||||
{ 0xd522a14f, "heltec_v4_expansionkit_repeater" },
|
||||
{ 0x76657d76, "heltec_v4_expansionkit_repeater_observer_mqtt" },
|
||||
{ 0x21ee03bd, "heltec_v4_expansionkit_room_server_observer_mqtt" },
|
||||
{ 0x2224a925, "heltec_v4_expansionkit_tft_companion_radio_ble_ps_femon" },
|
||||
{ 0x5977d941, "heltec_v4_expansionkit_tft_companion_radio_ble_femon" },
|
||||
{ 0xf75feb3e, "heltec_v4_kiss_modem" },
|
||||
{ 0xbc9cdc70, "heltec_v4_r8_companion_radio_ble" },
|
||||
{ 0x36c78d86, "heltec_v4_r8_companion_radio_usb" },
|
||||
{ 0xdf722326, "heltec_v4_r8_companion_radio_wifi" },
|
||||
{ 0xfa901c87, "heltec_v4_r8_kiss_modem" },
|
||||
{ 0xeebe3469, "heltec_v4_r8_repeater" },
|
||||
{ 0x5729ad07, "heltec_v4_r8_room_server" },
|
||||
{ 0xb4cb035a, "heltec_v4_r8_sensor" },
|
||||
{ 0xbb429dde, "heltec_v4_r8_terminal_chat" },
|
||||
{ 0x883e3edc, "heltec_v4_r8_tft_companion_radio_ble" },
|
||||
{ 0xa0965a6b, "heltec_v4_r8_tft_companion_radio_usb" },
|
||||
{ 0x59ea25fa, "heltec_v4_r8_tft_companion_radio_wifi" },
|
||||
{ 0x1758bdb9, "heltec_v4_r8_tft_kiss_modem" },
|
||||
{ 0xa2fb4192, "heltec_v4_r8_tft_repeater" },
|
||||
{ 0x7964461c, "heltec_v4_r8_tft_room_server" },
|
||||
{ 0x5fc52bcb, "heltec_v4_r8_tft_sensor" },
|
||||
{ 0x0dacb683, "heltec_v4_r8_tft_terminal_chat" },
|
||||
{ 0xe792a051, "heltec_v4_repeater" },
|
||||
{ 0x2d5ea842, "heltec_v4_repeater_bridge_espnow" },
|
||||
{ 0xab74db9e, "heltec_v4_repeater_observer_mqtt" },
|
||||
@@ -353,12 +381,15 @@ inline const char* ota_target_env_name(uint32_t target_id) {
|
||||
{ 0x6925aaf0, "RAK_3112_terminal_chat" },
|
||||
{ 0x94c5555a, "RAK_3401_repeater" },
|
||||
{ 0x9f4d58ac, "RAK_4631_companion_radio_ble" },
|
||||
{ 0x7a55dec3, "RAK_4631_companion_radio_ethernet" },
|
||||
{ 0x48d3b5d4, "RAK_4631_companion_radio_usb" },
|
||||
{ 0x14e6965d, "RAK_4631_kiss_modem" },
|
||||
{ 0x22ea8497, "RAK_4631_repeater_bridge_rs232_serial1" },
|
||||
{ 0x21bae522, "RAK_4631_repeater_bridge_rs232_serial2" },
|
||||
{ 0x25c20350, "RAK_4631_repeater_ethernet" },
|
||||
{ 0xb876506d, "RAK_4631_repeater_no_external_sensors_lora_ota" },
|
||||
{ 0x626d80ed, "RAK_4631_room_server" },
|
||||
{ 0x6f9c3984, "RAK_4631_room_server_ethernet" },
|
||||
{ 0x8b1d6850, "RAK_4631_sensor" },
|
||||
{ 0xf1d3c5a8, "RAK_4631_terminal_chat" },
|
||||
{ 0xc6d55752, "RAK_WisMesh_Tag_companion_radio_ble" },
|
||||
|
||||
@@ -191,7 +191,18 @@ class RAK12500LocationProvider : public LocationProvider {
|
||||
int _sats = 0;
|
||||
long _epoch = 0;
|
||||
bool _fix = false;
|
||||
mesh::RTCClock* _clock = NULL;
|
||||
unsigned long _next_time_check = 0;
|
||||
unsigned long _last_time_sync = 0;
|
||||
uint8_t _valid_time_samples = 0;
|
||||
static const unsigned long TIME_SYNC_INTERVAL = 1800000;
|
||||
public:
|
||||
void setRTCClock(mesh::RTCClock* clock) { _clock = clock; }
|
||||
mesh::RTCClock* getRTCClock() override { return _clock; }
|
||||
void syncTime() override {
|
||||
_valid_time_samples = 0;
|
||||
LocationProvider::syncTime();
|
||||
}
|
||||
long getLatitude() override { return _lat; }
|
||||
long getLongitude() override { return _lng; }
|
||||
long getAltitude() override { return _alt; }
|
||||
@@ -212,7 +223,32 @@ public:
|
||||
} else {
|
||||
_fix = false;
|
||||
}
|
||||
bool date_valid = ublox_GNSS.getDateValid(2);
|
||||
bool time_valid = ublox_GNSS.getTimeValid(2);
|
||||
_epoch = ublox_GNSS.getUnixEpoch(2);
|
||||
|
||||
unsigned long now = millis();
|
||||
if ((long)(now - _next_time_check) >= 0) {
|
||||
_next_time_check = now + 1000;
|
||||
|
||||
if (_fix && _sats >= 5 && date_valid && time_valid && _epoch > 0) {
|
||||
if (_valid_time_samples < 0xFF) _valid_time_samples++;
|
||||
} else {
|
||||
_valid_time_samples = 0;
|
||||
}
|
||||
|
||||
if (!_time_sync_needed && _clock != NULL
|
||||
&& (unsigned long)(now - _last_time_sync) > TIME_SYNC_INTERVAL) {
|
||||
_time_sync_needed = true;
|
||||
}
|
||||
if (_time_sync_needed && _clock != NULL && _valid_time_samples > 2) {
|
||||
_clock->setCurrentTime((uint32_t)_epoch);
|
||||
markTimeSyncApplied();
|
||||
_time_sync_needed = false;
|
||||
_last_time_sync = now;
|
||||
_last_valid_time_sync = _clock->getCurrentTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
bool isEnabled() override { return true; }
|
||||
};
|
||||
@@ -899,6 +935,7 @@ bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin){
|
||||
gps_active = true;
|
||||
gps_detected = true;
|
||||
|
||||
RAK12500_provider.setRTCClock(_location->getRTCClock());
|
||||
_location = &RAK12500_provider;
|
||||
return true;
|
||||
} else if (Serial1.available()) {
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
virtual void setNextGPSOn(unsigned long _millis) { _next_gps_on = _millis; }
|
||||
virtual unsigned long getNextGPSOn() { return _next_gps_on; }
|
||||
virtual unsigned long getLastValidTimeSync() { return _last_valid_time_sync; }
|
||||
virtual mesh::RTCClock* getRTCClock() { return NULL; }
|
||||
virtual long getLatitude() = 0;
|
||||
virtual long getLongitude() = 0;
|
||||
virtual long getAltitude() = 0;
|
||||
|
||||
@@ -110,6 +110,7 @@ public :
|
||||
}
|
||||
|
||||
void syncTime() override { nmea.clear(); LocationProvider::syncTime(); }
|
||||
mesh::RTCClock* getRTCClock() override { return _clock; }
|
||||
long getLatitude() override { return nmea.getLatitude(); }
|
||||
long getLongitude() override { return nmea.getLongitude(); }
|
||||
long getAltitude() override {
|
||||
|
||||
@@ -405,6 +405,10 @@ static void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
|
||||
static TFT_eSprite *sprite = NULL;
|
||||
|
||||
static bool spriteReady() {
|
||||
return sprite != NULL && sprite->getPointer() != NULL;
|
||||
}
|
||||
|
||||
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
return true;
|
||||
/*
|
||||
@@ -422,18 +426,22 @@ bool ST7735Display::begin() {
|
||||
if (!sprite) {
|
||||
// alloc offscreen canvas
|
||||
sprite = new TFT_eSprite(&lcd);
|
||||
if (sprite) {
|
||||
if (sprite->createSprite(160, 80)) {
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
sprite->setTextColor(curr_color = ST77XX_WHITE);
|
||||
} else {
|
||||
Serial.printf("ST7735Display: failed to alloc canvas pixels");
|
||||
}
|
||||
} else {
|
||||
Serial.printf("ST7735Display: failed to alloc canvas");
|
||||
if (!sprite) {
|
||||
Serial.println("ST7735Display: failed to alloc canvas");
|
||||
return false;
|
||||
}
|
||||
if (!sprite->createSprite(160, 80)) {
|
||||
Serial.println("ST7735Display: failed to alloc canvas pixels");
|
||||
delete sprite;
|
||||
sprite = NULL;
|
||||
return false;
|
||||
}
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
sprite->setTextColor(curr_color = ST77XX_WHITE);
|
||||
}
|
||||
|
||||
if (!spriteReady()) return false;
|
||||
|
||||
if (!_isOn) {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
|
||||
@@ -470,6 +478,8 @@ bool ST7735Display::begin() {
|
||||
}
|
||||
|
||||
void ST7735Display::_resetAndInit() {
|
||||
if (!spriteReady()) return;
|
||||
|
||||
// Pulse Reset low for 10ms
|
||||
digitalWrite(PIN_TFT_RST, HIGH);
|
||||
delay(2);
|
||||
@@ -528,10 +538,12 @@ void ST7735Display::turnOff() {
|
||||
}
|
||||
|
||||
void ST7735Display::clear() {
|
||||
if (!spriteReady()) return;
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
}
|
||||
|
||||
void ST7735Display::startFrame(Color bkg) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
sprite->setTextColor(curr_color = ST77XX_WHITE);
|
||||
sprite->setFreeFont();
|
||||
@@ -540,6 +552,7 @@ void ST7735Display::startFrame(Color bkg) {
|
||||
}
|
||||
|
||||
void ST7735Display::setTextSize(int sz) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->setTextSize(sz);
|
||||
}
|
||||
|
||||
@@ -570,34 +583,41 @@ void ST7735Display::setColor(Color c) {
|
||||
curr_color = ST77XX_WHITE;
|
||||
break;
|
||||
}
|
||||
sprite->setTextColor(curr_color);
|
||||
if (spriteReady()) sprite->setTextColor(curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::setCursor(int x, int y) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->setCursor(x*SCALE_X, y*SCALE_Y);
|
||||
}
|
||||
|
||||
void ST7735Display::print(const char* str) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->print(str);
|
||||
}
|
||||
|
||||
void ST7735Display::fillRect(int x, int y, int w, int h) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::drawRect(int x, int y, int w, int h) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, curr_color);
|
||||
}
|
||||
|
||||
uint16_t ST7735Display::getTextWidth(const char* str) {
|
||||
if (!spriteReady()) return 0;
|
||||
return sprite->textWidth(str) / SCALE_X;
|
||||
}
|
||||
|
||||
void ST7735Display::endFrame() {
|
||||
if (!spriteReady()) return;
|
||||
// blit the canvas buffer to LCD
|
||||
set_CS(LOW);
|
||||
_spi->beginTransaction(_spiSettings);
|
||||
|
||||
Reference in new issue
Block a user