Send ESP-NOW accel only on deadzone change and harden BLE+WiFi OTA coex.
Quiet pods no longer spam 100 Hz samples; mute wifi logs and throttle BLE notifies during slave distribution so the wifi task stack does not panic. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+12
-2
@@ -3,6 +3,7 @@
|
||||
#include "esp_timer.h"
|
||||
#include "host_transport.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "ota_espnow.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -26,9 +27,12 @@ static const char *DEVICE_NAME = "Powerpod";
|
||||
/** Prefer large ATT MTU so CLIENT_INFO / BATTERY fit in fewer notify chunks. */
|
||||
#define BLE_PREFERRED_ATT_MTU 517
|
||||
#define BLE_NOTIFY_CHUNK_RETRIES 24
|
||||
/** During ESP-NOW OTA dist, fail notify sooner so WiFi/ESP-NOW keeps airtime. */
|
||||
#define BLE_NOTIFY_CHUNK_RETRIES_OTA_DIST 4
|
||||
#define BLE_NOTIFY_CHUNK_RETRY_MS 5
|
||||
/** Pace multi-chunk notifies so the central parser sees contiguous frame bytes. */
|
||||
#define BLE_NOTIFY_CHUNK_GAP_MS 8
|
||||
#define BLE_NOTIFY_CHUNK_GAP_OTA_DIST_MS 2
|
||||
|
||||
/*
|
||||
* Nordic UART style:
|
||||
@@ -73,7 +77,10 @@ uint16_t ble_host_max_payload(void) {
|
||||
* One ATT notification (≤ MTU-3). Retries on transient NimBLE buffer pressure.
|
||||
*/
|
||||
static esp_err_t ble_notify_chunk(const uint8_t *data, uint16_t len) {
|
||||
for (int attempt = 0; attempt < BLE_NOTIFY_CHUNK_RETRIES; attempt++) {
|
||||
const int max_retries = ota_espnow_distribution_active()
|
||||
? BLE_NOTIFY_CHUNK_RETRIES_OTA_DIST
|
||||
: BLE_NOTIFY_CHUNK_RETRIES;
|
||||
for (int attempt = 0; attempt < max_retries; attempt++) {
|
||||
struct os_mbuf *om = ble_hs_mbuf_from_flat(data, len);
|
||||
if (om == NULL) {
|
||||
vTaskDelay(pdMS_TO_TICKS(BLE_NOTIFY_CHUNK_RETRY_MS));
|
||||
@@ -140,7 +147,10 @@ static esp_err_t ble_host_tx(const uint8_t *frame, size_t frame_len) {
|
||||
}
|
||||
off += n;
|
||||
if (off < frame_len) {
|
||||
vTaskDelay(pdMS_TO_TICKS(BLE_NOTIFY_CHUNK_GAP_MS));
|
||||
const uint32_t gap_ms = ota_espnow_distribution_active()
|
||||
? BLE_NOTIFY_CHUNK_GAP_OTA_DIST_MS
|
||||
: BLE_NOTIFY_CHUNK_GAP_MS;
|
||||
vTaskDelay(pdMS_TO_TICKS(gap_ms));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user