firmware: v3 correcto — fix OTA + timing pitido

Bugs corregidos:
- ESP32-CAM: binario anterior tenia FW_VERSION=2 aunque version.txt=3
  (causaba bucle infinito de actualizaciones). Recompilado con v3 real.
- ESP8266: Serial.begin() movia a ANTES de checkOTA() para que el pitido
  del ESP32-CAM llegue a tiempo. stopMotors() se llama primero para
  evitar movimientos involuntarios.
- Timeout HTTP 5s → 10s para conexiones HTTPS externas lentas.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Natxo1000
2026-06-02 12:01:39 +02:00
co-authored by Claude Sonnet 4.6
parent 8a93578c9f
commit 20666449b8
5 changed files with 12 additions and 17 deletions
+10 -15
View File
@@ -7,7 +7,7 @@
// ================================================================ // ================================================================
// OTA CONFIG // OTA CONFIG
// ================================================================ // ================================================================
#define FW_VERSION 2 #define FW_VERSION 3
#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"
@@ -64,7 +64,7 @@ static void checkOTA() {
+ "/raw/branch/" + GITEA_BRANCH + "/firmware/esp8266/"; + "/raw/branch/" + GITEA_BRANCH + "/firmware/esp8266/";
http.begin(client, base + "version.txt"); http.begin(client, base + "version.txt");
http.setTimeout(5000); http.setTimeout(10000);
int code = http.GET(); int code = http.GET();
String body; String body;
if (code == HTTP_CODE_OK) body = http.getString(); if (code == HTTP_CODE_OK) body = http.getString();
@@ -98,27 +98,22 @@ static void checkOTA() {
} }
void setup() { void setup() {
// OTA primero (usa WiFi) // 1. Pines de motor y parada inmediata — evita que las ruedas giren al arrancar
checkOTA();
// Esperar hasta que hayan pasado ~15s desde el arranque
// para dar tiempo al ESP32-CAM a conectarse y levantar el servidor
unsigned long elapsed = millis();
if (elapsed < 15000) {
delay(15000 - elapsed);
}
Serial.begin(9600);
pinMode(ENA, OUTPUT); pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT); pinMode(ENB, OUTPUT);
pinMode(IN1, OUTPUT); pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT); pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT); pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT); pinMode(IN4, OUTPUT);
stopMotors(); stopMotors();
// 2. Serial antes del OTA — así el ESP32-CAM puede enviar el pitido a tiempo
Serial.begin(9600);
// 3. OTA (WiFi on → check → WiFi off). El ESP32-CAM tarda >20s en enviar
// comandos de motor, así que no hay riesgo de movimiento involuntario.
checkOTA();
analogWriteRange(255); analogWriteRange(255);
analogWriteFreq(1000); analogWriteFreq(1000);
+1 -1
View File
@@ -33,7 +33,7 @@ static void checkOTA() {
+ "/raw/branch/" + GITEA_BRANCH + "/firmware/esp32cam/"; + "/raw/branch/" + GITEA_BRANCH + "/firmware/esp32cam/";
http.begin(client, base + "version.txt"); http.begin(client, base + "version.txt");
http.setTimeout(5000); http.setTimeout(10000);
int code = http.GET(); int code = http.GET();
String body; String body;
if (code == HTTP_CODE_OK) body = http.getString(); if (code == HTTP_CODE_OK) body = http.getString();
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
2 3