generated from CubeCraft-Creations/Tracehound
firmware: fix C6 filesystem provisioning (LittleFS) + ESP-01S env
The C6 never loaded its /config.json, so it fell back to defaults
(SSID RemoteRig, empty password) and couldn't join Wi-Fi. Two bugs:
- Data file was named esp32-config.json but the firmware reads
/config.json → renamed to config.json.
- Firmware used SPIFFS while pioarduino's uploadfs builds a LittleFS
image; the SPIFFS mount then reformatted it empty. Switch the C6 to
LittleFS (matches the toolchain default and the ESP-01S).
Also:
- log loaded ssid/broker/camera_id on config load (not the password)
- platformio.ini: land the ESP-01S env retarget (board d1_mini ->
esp01_1m, dout, upload_speed 115200) that was missed in 403e1d9
- committed config.json keeps wifi_password blank; the real value is
flashed to the device, not stored in git
Verified: C6 loads config and associates (got a DHCP lease). MQTT to
the broker is a separate network issue (hub IP / subnet).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -30,12 +30,12 @@
|
||||
#include <WiFiClient.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <SPIFFS.h>
|
||||
#include <LittleFS.h>
|
||||
#include <Wire.h>
|
||||
#include <U8g2lib.h>
|
||||
|
||||
// ────────────────────────────────────────────
|
||||
// Configuration (SPIFFS)
|
||||
// Configuration (LittleFS)
|
||||
// ────────────────────────────────────────────
|
||||
|
||||
struct Config {
|
||||
@@ -54,8 +54,8 @@ struct Config {
|
||||
} cfg;
|
||||
|
||||
bool loadConfig() {
|
||||
if (!SPIFFS.begin(true)) { Serial.println("[CFG] SPIFFS mount failed"); return false; }
|
||||
File f = SPIFFS.open("/config.json", "r");
|
||||
if (!LittleFS.begin(true)) { Serial.println("[CFG] LittleFS mount failed"); return false; }
|
||||
File f = LittleFS.open("/config.json", "r");
|
||||
if (!f) { Serial.println("[CFG] No config — using defaults"); return false; }
|
||||
|
||||
JsonDocument doc;
|
||||
@@ -71,11 +71,14 @@ bool loadConfig() {
|
||||
cfg.heartbeat_sec = doc["heartbeat_interval_sec"] | cfg.heartbeat_sec;
|
||||
cfg.bat_raw_min = doc["bat_raw_min"] | cfg.bat_raw_min;
|
||||
cfg.bat_raw_max = doc["bat_raw_max"] | cfg.bat_raw_max;
|
||||
Serial.printf("[CFG] Loaded: ssid=%s broker=%s:%d cam=%s\n",
|
||||
cfg.wifi_ssid.c_str(), cfg.mqtt_broker.c_str(), cfg.mqtt_port,
|
||||
cfg.camera_id.length() ? cfg.camera_id.c_str() : "-");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool saveConfig() {
|
||||
File f = SPIFFS.open("/config.json", "w");
|
||||
File f = LittleFS.open("/config.json", "w");
|
||||
if (!f) return false;
|
||||
JsonDocument doc;
|
||||
doc["wifi_ssid"] = cfg.wifi_ssid;
|
||||
|
||||
Reference in New Issue
Block a user