firmware: v16 — sin watchdog ni handshake (prueba simplificada)

Eliminados para diagnostico del problema de ruido electrico:
- Watchdog de motores (tarea FreeRTOS en ESP32)
- Handshake GO/OK bidireccional
- ESP8266 vuelve a delay fijo de 15s para esperar al ESP32

Si el problema de desconexion persiste con v16 -> es hardware (ruido L298N)
Si mejora -> alguna de estas tareas contribuia al problema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Natxo1000
2026-06-02 17:10:56 +02:00
parent e84a69a9d8
commit e0cc1d0908
7 changed files with 7 additions and 112 deletions

View File

@@ -7,7 +7,7 @@
// ================================================================
// OTA CONFIG
// ================================================================
#define FW_VERSION 13
#define FW_VERSION 16
#define GITEA_HOST "https://git.nacho.myds.me"
#define GITEA_OWNER "Natxo"
#define GITEA_REPO "Arduino-Car"
@@ -110,45 +110,6 @@ static void checkOTA() {
WiFi.mode(WIFI_OFF); // apaga radio para ahorrar energía
}
bool espReady = false;
// ── Handshake con ESP32-CAM ──────────────────────────────────────
// Descarta basura del bootloader ROM (115200 baud → bytes aleatorios),
// luego espera exactamente "GO\n" y responde "OK\n".
void waitForReady() {
// Descarta todo lo que haya en el buffer (logs de arranque del ESP32)
delay(300);
while (Serial.available()) Serial.read();
// Espera "GO\n" del ESP32-CAM (máx 90s por si está haciendo OTA)
unsigned long timeout = millis() + 90000UL;
String buf = "";
while (millis() < timeout) {
while (Serial.available()) {
char c = Serial.read();
if (c == '\n') {
buf.trim();
if (buf == "GO") {
Serial.print("OK\n");
delay(50);
while (Serial.available()) Serial.read(); // flush post-handshake
espReady = true;
// 2 pitidos: conexión entre placas establecida
for (int i = 0; i < 2; i++) {
digitalWrite(buzzerPin, HIGH); delay(180);
digitalWrite(buzzerPin, LOW); delay(180);
}
return;
}
buf = "";
} else if (c != '\r') {
if (buf.length() < 8) buf += c;
}
}
delay(10);
}
espReady = true; // timeout: arranca igual
}
void setup() {
// 1. Pines y parada inmediata
@@ -172,27 +133,15 @@ void setup() {
servoX.write(posX);
servoY.write(posY);
// 5. Esperar señal '!' del ESP32-CAM antes de procesar comandos
waitForReady();
// 5. Esperar a que el ESP32-CAM termine de arrancar
unsigned long elapsed = millis();
if (elapsed < 15000) delay(15000 - elapsed);
}
void loop() {
if (Serial.available()) {
char c = Serial.read();
// Detecta re-arranque del ESP32-CAM: envía "GO\n" de nuevo
if (c == 'G') {
Serial.readStringUntil('\n'); // consume "O\n"
Serial.print("OK\n");
delay(50);
while (Serial.available()) Serial.read();
espReady = true;
return;
}
// Ignorar todo hasta completar el handshake
if (!espReady) return;
if (c == 'F') forward();
else if (c == 'B') backward();
else if (c == 'L') left();