Add BLE host transport selectable via DIP8 alongside UART.
Master can speak the same framed protobuf protocol over NimBLE or UART; goTool gains -ble, ble-rtt, and ble-stream timing checks for ESP-NOW coexistence. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "client_registry.h"
|
||||
#include "cmd_accel_stream.h"
|
||||
#include "ble_stream.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "uart_cmd.h"
|
||||
@@ -50,6 +51,10 @@ static void handle_accel_stream(const uint8_t *data, size_t len) {
|
||||
}
|
||||
|
||||
if (req.write) {
|
||||
if (req.period_ms != 0) {
|
||||
ble_stream_set_period_ms(req.period_ms);
|
||||
}
|
||||
|
||||
if (req.all_clients) {
|
||||
size_t n = client_registry_set_accel_stream_all(req.enable);
|
||||
uint32_t sent = 0;
|
||||
@@ -65,8 +70,10 @@ static void handle_accel_stream(const uint8_t *data, size_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "accel stream %s for %u/%u slaves",
|
||||
req.enable ? "on" : "off", (unsigned)sent, (unsigned)n);
|
||||
ESP_LOGI(TAG, "accel stream %s for %u/%u slaves period_ms=%lu",
|
||||
req.enable ? "on" : "off", (unsigned)sent, (unsigned)n,
|
||||
(unsigned long)ble_stream_period_ms());
|
||||
ble_stream_update();
|
||||
reply(req.enable, 0, sent > 0, sent);
|
||||
return;
|
||||
}
|
||||
@@ -85,6 +92,7 @@ static void handle_accel_stream(const uint8_t *data, size_t len) {
|
||||
}
|
||||
|
||||
esp_err_t err = push_stream_to_slave(client, req.enable);
|
||||
ble_stream_update();
|
||||
reply(req.enable, req.client_id, err == ESP_OK, err == ESP_OK ? 1u : 0u);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cmd_ota.h"
|
||||
#include "app_config.h"
|
||||
#include "led_ring.h"
|
||||
#include "ota_espnow.h"
|
||||
#include "ota_uart.h"
|
||||
@@ -103,10 +104,24 @@ static void ota_prepare_task(void *param) {
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
static bool ota_host_is_uart(void) {
|
||||
const app_config_t *cfg = app_config_get();
|
||||
if (cfg != NULL && cfg->host_ble) {
|
||||
ESP_LOGW(TAG, "OTA requires UART host (DIP8=0); BLE host active");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void handle_ota_start(const uint8_t *data, size_t len) {
|
||||
alox_UartMessage uart_msg;
|
||||
alox_OtaStartPayload req = alox_OtaStartPayload_init_zero;
|
||||
|
||||
if (!ota_host_is_uart()) {
|
||||
send_ota_failed(20);
|
||||
return;
|
||||
}
|
||||
|
||||
if (uart_cmd_decode(data, len, &uart_msg) != ESP_OK) {
|
||||
send_ota_failed( 2);
|
||||
return;
|
||||
@@ -334,6 +349,10 @@ static void ota_start_espnow_task(void *param) {
|
||||
}
|
||||
|
||||
static void handle_ota_start_espnow(const uint8_t *data, size_t len) {
|
||||
if (!ota_host_is_uart()) {
|
||||
send_ota_failed(20);
|
||||
return;
|
||||
}
|
||||
(void)data;
|
||||
(void)len;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user