firmware: v10 — fix OTA ESP8266 memoria + idioma de pitidos
Fix OTA ESP8266 (pitidos cada arranque):
- BearSSL ocupa ~20KB de heap. El cliente de version.txt y el cliente
de firmware.bin coexistian → sin heap suficiente → descarga falla.
- Ahora el primer cliente se destruye en su scope {} antes de crear
el segundo. setBufferSizes(512,512) reduce uso BearSSL durante descarga.
Idioma de pitidos:
- 2 pitidos: handshake OK, ambas placas conectadas y listas
- 3 pitidos: ESP32-CAM actualizandose via OTA
- 4 pitidos: ESP8266 actualizandose via OTA
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e02a805aa3
commit
b9bd18a568
+22
-11
@@ -7,7 +7,7 @@
|
|||||||
// ================================================================
|
// ================================================================
|
||||||
// OTA CONFIG
|
// OTA CONFIG
|
||||||
// ================================================================
|
// ================================================================
|
||||||
#define FW_VERSION 9
|
#define FW_VERSION 10
|
||||||
#define GITEA_HOST "https://git.nacho.myds.me"
|
#define GITEA_HOST "https://git.nacho.myds.me"
|
||||||
#define GITEA_OWNER "Natxo"
|
#define GITEA_OWNER "Natxo"
|
||||||
#define GITEA_REPO "Arduino-Car"
|
#define GITEA_REPO "Arduino-Car"
|
||||||
@@ -57,24 +57,30 @@ static void checkOTA() {
|
|||||||
return; // sin WiFi, arranque normal
|
return; // sin WiFi, arranque normal
|
||||||
}
|
}
|
||||||
|
|
||||||
BearSSL::WiFiClientSecure client;
|
|
||||||
client.setInsecure(); // cert Let's Encrypt/autofirmado — OK para LAN privada
|
|
||||||
HTTPClient http;
|
|
||||||
|
|
||||||
String base = String(GITEA_HOST) + "/" + GITEA_OWNER + "/" + GITEA_REPO
|
String base = String(GITEA_HOST) + "/" + GITEA_OWNER + "/" + GITEA_REPO
|
||||||
+ "/raw/branch/" + GITEA_BRANCH + "/firmware/esp8266/";
|
+ "/raw/branch/" + GITEA_BRANCH + "/firmware/esp8266/";
|
||||||
String token = "?token=" + String(GITEA_TOKEN);
|
String token = "?token=" + String(GITEA_TOKEN);
|
||||||
|
|
||||||
|
// ── Bloque de scope: libera el cliente BearSSL antes de la descarga ──
|
||||||
|
// BearSSL ocupa ~20KB de heap. Si los dos clientes coexisten el heap
|
||||||
|
// se agota y ESPhttpUpdate falla silenciosamente.
|
||||||
|
int remoteVer = 0;
|
||||||
|
{
|
||||||
|
BearSSL::WiFiClientSecure client;
|
||||||
|
client.setInsecure();
|
||||||
|
client.setBufferSizes(512, 512); // buffers mínimos — suficiente para la respuesta
|
||||||
|
HTTPClient http;
|
||||||
http.begin(client, base + "version.txt" + token);
|
http.begin(client, base + "version.txt" + token);
|
||||||
http.setTimeout(10000);
|
http.setTimeout(10000);
|
||||||
int code = http.GET();
|
int code = http.GET();
|
||||||
String body;
|
|
||||||
if (code == HTTP_CODE_OK) body = http.getString();
|
|
||||||
http.end();
|
|
||||||
|
|
||||||
if (code == HTTP_CODE_OK) {
|
if (code == HTTP_CODE_OK) {
|
||||||
|
String body = http.getString();
|
||||||
body.trim();
|
body.trim();
|
||||||
int remoteVer = body.toInt();
|
remoteVer = body.toInt();
|
||||||
|
}
|
||||||
|
http.end();
|
||||||
|
} // ← client y http se destruyen aquí, ~20KB liberados
|
||||||
|
|
||||||
if (remoteVer > FW_VERSION) {
|
if (remoteVer > FW_VERSION) {
|
||||||
// 4 pitidos = ESP8266 actualizando
|
// 4 pitidos = ESP8266 actualizando
|
||||||
pinMode(buzzerPin, OUTPUT);
|
pinMode(buzzerPin, OUTPUT);
|
||||||
@@ -93,12 +99,12 @@ static void checkOTA() {
|
|||||||
|
|
||||||
BearSSL::WiFiClientSecure updateClient;
|
BearSSL::WiFiClientSecure updateClient;
|
||||||
updateClient.setInsecure();
|
updateClient.setInsecure();
|
||||||
|
updateClient.setBufferSizes(512, 512); // reduce heap BearSSL durante descarga
|
||||||
ESPhttpUpdate.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
ESPhttpUpdate.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
ESPhttpUpdate.rebootOnUpdate(true);
|
ESPhttpUpdate.rebootOnUpdate(true);
|
||||||
ESPhttpUpdate.update(updateClient, base + "firmware.bin" + token);
|
ESPhttpUpdate.update(updateClient, base + "firmware.bin" + token);
|
||||||
// Si llega aquí, el update falló — continúa arranque normal
|
// Si llega aquí, el update falló — continúa arranque normal
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
WiFi.mode(WIFI_OFF); // apaga radio para ahorrar energía
|
WiFi.mode(WIFI_OFF); // apaga radio para ahorrar energía
|
||||||
@@ -127,6 +133,11 @@ void waitForReady() {
|
|||||||
delay(50);
|
delay(50);
|
||||||
while (Serial.available()) Serial.read(); // flush post-handshake
|
while (Serial.available()) Serial.read(); // flush post-handshake
|
||||||
espReady = true;
|
espReady = true;
|
||||||
|
// 2 pitidos: conexión entre placas establecida
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
digitalWrite(buzzerPin, HIGH); delay(100);
|
||||||
|
digitalWrite(buzzerPin, LOW); delay(100);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf = "";
|
buf = "";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
// ================================================================
|
// ================================================================
|
||||||
// OTA CONFIG
|
// OTA CONFIG
|
||||||
// ================================================================
|
// ================================================================
|
||||||
#define FW_VERSION 9
|
#define FW_VERSION 10
|
||||||
#define GITEA_HOST "https://git.nacho.myds.me"
|
#define GITEA_HOST "https://git.nacho.myds.me"
|
||||||
#define GITEA_OWNER "Natxo"
|
#define GITEA_OWNER "Natxo"
|
||||||
#define GITEA_REPO "Arduino-Car"
|
#define GITEA_REPO "Arduino-Car"
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
9
|
10
|
||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
9
|
10
|
||||||
Reference in New Issue
Block a user