Make controller input best-effort and harden OTA rollback.
Accel/tap use fire-and-forget ESP-NOW with a 10 ms FreeRTOS-safe cadence, OTA recovers from seq gaps and auto-reboots after success, and bootloader app rollback confirms after a stable boot. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+22
-7
@@ -204,10 +204,11 @@ esp_err_t esp_now_core_send_reliable(const uint8_t *dest_mac,
|
||||
ESPNOW_SEND_RETRY_DELAY_MS, true);
|
||||
}
|
||||
|
||||
esp_err_t esp_now_core_send_fast(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg) {
|
||||
static esp_err_t send_fast_internal(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg,
|
||||
bool quiet) {
|
||||
if (s_send_lock == NULL ||
|
||||
xSemaphoreTake(s_send_lock, pdMS_TO_TICKS(5000)) != pdTRUE) {
|
||||
xSemaphoreTake(s_send_lock, pdMS_TO_TICKS(5)) != pdTRUE) {
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
@@ -216,14 +217,18 @@ esp_err_t esp_now_core_send_fast(const uint8_t *dest_mac,
|
||||
|
||||
esp_err_t err = esp_now_proto_encode(msg, buf, sizeof(buf), &len);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "encode failed");
|
||||
if (!quiet) {
|
||||
ESP_LOGW(TAG, "encode failed");
|
||||
}
|
||||
xSemaphoreGive(s_send_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
if (len > ESP_NOW_MAX_DATA_LEN) {
|
||||
ESP_LOGW(TAG, "encoded len %u > ESP-NOW max %u", (unsigned)len,
|
||||
(unsigned)ESP_NOW_MAX_DATA_LEN);
|
||||
if (!quiet) {
|
||||
ESP_LOGW(TAG, "encoded len %u > ESP-NOW max %u", (unsigned)len,
|
||||
(unsigned)ESP_NOW_MAX_DATA_LEN);
|
||||
}
|
||||
xSemaphoreGive(s_send_lock);
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
@@ -234,7 +239,7 @@ esp_err_t esp_now_core_send_fast(const uint8_t *dest_mac,
|
||||
}
|
||||
|
||||
err = esp_now_send(dest_mac, buf, len);
|
||||
if (err != ESP_OK) {
|
||||
if (err != ESP_OK && !quiet) {
|
||||
ESP_LOGW(TAG, "send type=%u failed: %s", (unsigned)msg->type,
|
||||
esp_err_to_name(err));
|
||||
}
|
||||
@@ -242,6 +247,16 @@ esp_err_t esp_now_core_send_fast(const uint8_t *dest_mac,
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_now_core_send_fast(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg) {
|
||||
return send_fast_internal(dest_mac, msg, false);
|
||||
}
|
||||
|
||||
esp_err_t esp_now_core_send_best_effort(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg) {
|
||||
return send_fast_internal(dest_mac, msg, true);
|
||||
}
|
||||
|
||||
esp_err_t esp_now_core_send(const uint8_t *dest_mac,
|
||||
const alox_EspNowMessage *msg) {
|
||||
return esp_now_core_send_wait(dest_mac, msg);
|
||||
|
||||
Reference in New Issue
Block a user