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:
@@ -10,7 +10,7 @@
|
||||
// ================================================================
|
||||
// OTA CONFIG
|
||||
// ================================================================
|
||||
#define FW_VERSION 15
|
||||
#define FW_VERSION 16
|
||||
#define GITEA_HOST "https://git.nacho.myds.me"
|
||||
#define GITEA_OWNER "Natxo"
|
||||
#define GITEA_REPO "Arduino-Car"
|
||||
@@ -24,31 +24,6 @@ const char *password = "Suprak1llm1ndS23S";
|
||||
void startCameraServer();
|
||||
void setupLedFlash();
|
||||
|
||||
// ── Handshake bidireccional — tarea FreeRTOS (no bloquea setup) ─
|
||||
// Corre en paralelo con el servidor web. Envía "GO\n" cada 300ms
|
||||
// hasta recibir "OK\n" o agotar 30s.
|
||||
static void handshakeTask(void *) {
|
||||
unsigned long deadline = millis() + 30000UL;
|
||||
String buf = "";
|
||||
while (millis() < deadline) {
|
||||
Serial.print("GO\n");
|
||||
unsigned long t = millis();
|
||||
while (millis() - t < 300) {
|
||||
while (Serial.available()) {
|
||||
char c = Serial.read();
|
||||
if (c == '\n') {
|
||||
buf.trim();
|
||||
if (buf == "OK") { vTaskDelete(NULL); return; }
|
||||
buf = "";
|
||||
} else if (c != '\r' && buf.length() < 8) {
|
||||
buf += c;
|
||||
}
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(5));
|
||||
}
|
||||
}
|
||||
vTaskDelete(NULL); // timeout
|
||||
}
|
||||
|
||||
// ── OTA: comprueba si hay firmware nuevo y actualiza si hace falta ──
|
||||
static void checkOTA() {
|
||||
@@ -172,9 +147,6 @@ void setup() {
|
||||
|
||||
// ── Servidor cámara ───────────────────────────────────────────────
|
||||
startCameraServer();
|
||||
|
||||
// Handshake en tarea separada — no bloquea setup() ni el watchdog
|
||||
xTaskCreate(handshakeTask, "handshake", 4096, NULL, 1, NULL);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
@@ -48,21 +48,6 @@ static const char *_STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %
|
||||
httpd_handle_t stream_httpd = NULL;
|
||||
httpd_handle_t camera_httpd = NULL;
|
||||
|
||||
// ── Watchdog de motores ────────────────────────────────────────────
|
||||
// Si no llega ningún comando de movimiento en 400ms → para automáticamente
|
||||
static volatile bool motorMoving = false;
|
||||
static volatile int64_t lastMoveCmdUs = 0;
|
||||
#define WATCHDOG_US 800000LL // 800ms — se retroalimenta con heartbeat JS cada 150ms
|
||||
|
||||
static void motorWatchdogTask(void *) {
|
||||
while (1) {
|
||||
if (motorMoving && (esp_timer_get_time() - lastMoveCmdUs) > WATCHDOG_US) {
|
||||
Serial.print("S\n");
|
||||
motorMoving = false;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(80));
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
size_t size; //number of values used for filtering
|
||||
@@ -371,16 +356,6 @@ static esp_err_t cmd_handler(httpd_req_t *req) {
|
||||
} else {
|
||||
Serial.printf("%s\n", value);
|
||||
}
|
||||
// Watchdog: registra comandos de movimiento
|
||||
if (!strcmp(variable, "car")) {
|
||||
char c = value[0];
|
||||
if (c=='F' || c=='B' || c=='L' || c=='R') {
|
||||
motorMoving = true;
|
||||
lastMoveCmdUs = esp_timer_get_time();
|
||||
} else if (c == 'S') {
|
||||
motorMoving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
@@ -809,7 +784,6 @@ void startCameraServer() {
|
||||
httpd_register_uri_handler(stream_httpd, &stream_uri);
|
||||
}
|
||||
|
||||
xTaskCreate(motorWatchdogTask, "motorWD", 2048, NULL, 1, NULL);
|
||||
}
|
||||
|
||||
void setupLedFlash() {
|
||||
|
||||
Reference in New Issue
Block a user