Add find-me LED locate on master and slaves via ESP-NOW.
UART FIND_ME (client_id 0 = local ring, >0 = unicast), ESPNOW_FIND_ME payload, CLI/dashboard buttons per slave. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,6 +19,7 @@ idf_component_register(
|
||||
"cmd_client_info.c"
|
||||
"cmd_accel_deadzone.c"
|
||||
"cmd_espnow_unicast_test.c"
|
||||
"cmd_espnow_find_me.c"
|
||||
"cmd_led_ring.c"
|
||||
"cmd_ota.c"
|
||||
"cmd_ota_slave_progress.c"
|
||||
|
||||
+20
-1
@@ -110,6 +110,8 @@ Schema: `proto/esp_now_messages.proto`. Encode/decode: `esp_now_proto.c`. The ES
|
||||
| `ESPNOW_SLAVE_INFO` | Slave → master | `EspNowSlavePresence` |
|
||||
| `ESPNOW_HEARTBEAT` | Slave → master | `EspNowSlavePresence` (same fields) |
|
||||
| `ESPNOW_SET_ACCEL_DEADZONE` | Master → slave | `EspNowAccelDeadzone` (`deadzone` LSB) |
|
||||
| `ESPNOW_UNICAST_TEST` | Master → slave | `EspNowUnicastTest` (`seq`) |
|
||||
| `ESPNOW_FIND_ME` | Master → slave | `EspNowFindMe` (`client_id` filter) — LED locate sequence |
|
||||
| `ESPNOW_OTA_START` | Master → slave (unicast) | `EspNowOtaStart` (`total_size`) |
|
||||
| `ESPNOW_OTA_PAYLOAD` | Master → slave | `EspNowOtaPayload` (`seq`, up to 200 B `data`) |
|
||||
| `ESPNOW_OTA_END` | Master → slave | `EspNowOtaEnd` |
|
||||
@@ -210,6 +212,7 @@ Host and master speak nanopb-encoded `UartMessage` inside UART frames (byte 0 =
|
||||
| 19 | `OTA_STATUS` | Device → host (prepare/ready/block ACK/success/failed) |
|
||||
| 20 | `OTA_START_ESPNOW` | Implemented — re-distribute staged image to slaves only |
|
||||
| 21 | `OTA_SLAVE_PROGRESS` | Implemented (`cmd_ota_slave_progress.c`) — query per-slave ESP-NOW OTA progress |
|
||||
| 22 | `FIND_ME` | Implemented (`cmd_espnow_find_me.c`) — `client_id=0` local ring, `>0` ESP-NOW to slave |
|
||||
|
||||
Regenerate C code:
|
||||
|
||||
@@ -313,6 +316,19 @@ Minimal master→slave ESP-NOW unicast check (no BMA456). Use this before debugg
|
||||
|
||||
**Firmware logs:** master `unicast TEST to … seq=N`; slave `UNICAST TEST OK from master … seq=N`.
|
||||
|
||||
### FIND_ME command
|
||||
|
||||
Locate a pod: the LED ring blinks **3× red, 3× green, 3× blue** at full brightness.
|
||||
|
||||
**Request:** framed `22` + `espnow_find_me_request` (`client_id`: `0` = master only, `>0` = ESP-NOW unicast to that slave).
|
||||
|
||||
**Response:** `espnow_find_me_response` (`success`, `client_id`).
|
||||
|
||||
```bash
|
||||
go run . -port /dev/ttyUSB0 find-me
|
||||
go run . -port /dev/ttyUSB0 find-me -client 16
|
||||
```
|
||||
|
||||
### LED_RING command
|
||||
|
||||
Control the 95-LED ring from the host. The firmware **does not** animate digits locally; only UART updates the display.
|
||||
@@ -321,7 +337,7 @@ Control the 95-LED ring from the host. The firmware **does not** animate digits
|
||||
|
||||
| Field | Meaning |
|
||||
|-------|---------|
|
||||
| `mode` | `0` = clear, `1` = progress bar, `2` = digit, `3` = blink full ring |
|
||||
| `mode` | `0` = clear, `1` = progress bar, `2` = digit, `3` = blink full ring, `4` = find-me (R/G/B ×3 @ full brightness) |
|
||||
| `progress` | 0–100 (% of ring lit, mode `1`) |
|
||||
| `digit` | 0–10 (mode `2`, same segment maps as built-in digits) |
|
||||
| `r`, `g`, `b` | Color 0–255 |
|
||||
@@ -335,6 +351,9 @@ go run . -port /dev/ttyUSB0 led-ring -mode progress -progress 75 -g 80 -b 255
|
||||
go run . -port /dev/ttyUSB0 led-ring -mode digit -digit 7 -r 255 -g 200
|
||||
go run . -port /dev/ttyUSB0 led-ring -mode clear
|
||||
go run . -port /dev/ttyUSB0 led-ring -mode blink -g 255 -blink-count 2
|
||||
go run . -port /dev/ttyUSB0 find-me
|
||||
go run . -port /dev/ttyUSB0 find-me -client 16
|
||||
go run . -port /dev/ttyUSB0 led-ring -mode find-me
|
||||
```
|
||||
|
||||
### CLIENT_INFO command
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "client_registry.h"
|
||||
#include "cmd_espnow_find_me.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "led_ring.h"
|
||||
#include "uart_cmd.h"
|
||||
|
||||
static const char *TAG = "[FIND_ME]";
|
||||
|
||||
static void reply(bool success, uint32_t client_id) {
|
||||
alox_UartMessage response;
|
||||
uart_cmd_init_response(&response, alox_MessageType_FIND_ME,
|
||||
alox_UartMessage_espnow_find_me_response_tag);
|
||||
response.payload.espnow_find_me_response.success = success;
|
||||
response.payload.espnow_find_me_response.client_id = client_id;
|
||||
uart_cmd_send(&response, TAG);
|
||||
}
|
||||
|
||||
static void handle_find_me(const uint8_t *data, size_t len) {
|
||||
alox_UartMessage uart_msg;
|
||||
|
||||
if (uart_cmd_decode(data, len, &uart_msg) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "decode failed");
|
||||
reply(false, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
const alox_EspNowFindMeRequest *req = UART_CMD_REQ(
|
||||
&uart_msg, alox_UartMessage_espnow_find_me_request_tag,
|
||||
espnow_find_me_request);
|
||||
if (req == NULL) {
|
||||
ESP_LOGW(TAG, "missing find_me request");
|
||||
reply(false, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req->client_id == 0) {
|
||||
led_ring_find_me();
|
||||
ESP_LOGI(TAG, "find-me on master");
|
||||
reply(true, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
const client_info_t *client = client_registry_find_by_id(req->client_id);
|
||||
if (client == NULL) {
|
||||
ESP_LOGW(TAG, "client id %lu not in registry",
|
||||
(unsigned long)req->client_id);
|
||||
reply(false, req->client_id);
|
||||
return;
|
||||
}
|
||||
|
||||
esp_err_t err = esp_now_comm_send_find_me(client->mac, req->client_id);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "find-me sent to slave %lu", (unsigned long)req->client_id);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "find-me to slave %lu failed: %s",
|
||||
(unsigned long)req->client_id, esp_err_to_name(err));
|
||||
}
|
||||
reply(err == ESP_OK, req->client_id);
|
||||
}
|
||||
|
||||
void cmd_espnow_find_me_register(void) {
|
||||
uart_cmd_register(alox_MessageType_FIND_ME, handle_find_me);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef CMD_ESPNOW_FIND_ME_H
|
||||
#define CMD_ESPNOW_FIND_ME_H
|
||||
|
||||
void cmd_espnow_find_me_register(void);
|
||||
|
||||
#endif
|
||||
@@ -44,6 +44,8 @@ static const char *message_type_name(uint16_t id) {
|
||||
return "OTA_START_ESPNOW";
|
||||
case alox_MessageType_OTA_SLAVE_PROGRESS:
|
||||
return "OTA_SLAVE_PROGRESS";
|
||||
case alox_MessageType_FIND_ME:
|
||||
return "FIND_ME";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ static const char *TAG = "[LED_RING_CMD]";
|
||||
#define LED_RING_MODE_PROGRESS 1
|
||||
#define LED_RING_MODE_DIGIT 2
|
||||
#define LED_RING_MODE_BLINK 3
|
||||
#define LED_RING_MODE_FIND_ME 4
|
||||
|
||||
static uint8_t clamp_u8(uint32_t v) {
|
||||
if (v > 255) {
|
||||
@@ -109,6 +110,12 @@ static void handle_led_ring(const uint8_t *data, size_t len) {
|
||||
return;
|
||||
}
|
||||
|
||||
case LED_RING_MODE_FIND_ME:
|
||||
led_ring_find_me();
|
||||
ESP_LOGI(TAG, "find-me");
|
||||
reply(true, mode, 0, 0);
|
||||
return;
|
||||
|
||||
case LED_RING_MODE_BLINK: {
|
||||
cmd.mode = LED_CMD_BLINK;
|
||||
cmd.r = r;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "bosch456.h"
|
||||
#include "client_registry.h"
|
||||
#include "esp_now_comm.h"
|
||||
#include "led_ring.h"
|
||||
#include "ota_espnow.h"
|
||||
#include "esp_now_proto.h"
|
||||
#include "esp_err.h"
|
||||
@@ -171,6 +172,16 @@ static esp_err_t send_unicast_test(const uint8_t *dest_mac, uint32_t seq) {
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_find_me(const uint8_t *dest_mac, uint32_t client_id) {
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
|
||||
msg.type = alox_EspNowMessageType_ESPNOW_FIND_ME;
|
||||
msg.which_payload = alox_EspNowMessage_find_me_tag;
|
||||
msg.payload.find_me.client_id = client_id;
|
||||
|
||||
return send_message(dest_mac, &msg);
|
||||
}
|
||||
|
||||
static esp_err_t send_ota_start(const uint8_t *dest_mac, uint32_t total_size) {
|
||||
alox_EspNowMessage msg = alox_EspNowMessage_init_zero;
|
||||
|
||||
@@ -261,6 +272,25 @@ bool esp_now_comm_get_master_mac(uint8_t mac_out[CLIENT_MAC_LEN]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
esp_err_t esp_now_comm_send_find_me(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id) {
|
||||
if (mac == NULL || !s_config.master) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
char mac_str[18];
|
||||
mac_to_str(mac, mac_str, sizeof(mac_str));
|
||||
esp_err_t err = send_find_me(mac, client_id);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "unicast FIND_ME to %s client_id=%lu", mac_str,
|
||||
(unsigned long)client_id);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "unicast FIND_ME to %s failed: %s", mac_str,
|
||||
esp_err_to_name(err));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_now_comm_send_unicast_test(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t seq) {
|
||||
if (mac == NULL || !s_config.master) {
|
||||
@@ -330,6 +360,24 @@ static void handle_slave_unicast_test(const uint8_t *master_mac,
|
||||
mac_str, (unsigned long)test->seq, (int)s_slave_joined);
|
||||
}
|
||||
|
||||
static void handle_slave_find_me(const uint8_t *master_mac,
|
||||
const alox_EspNowFindMe *req) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
|
||||
if (req->client_id != 0 && req->client_id != my_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_slave_joined && !mac_equal(master_mac, s_master_mac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
char mac_str[18];
|
||||
mac_to_str(master_mac, mac_str, sizeof(mac_str));
|
||||
ESP_LOGI(TAG, "FIND_ME from master %s (id=%lu)", mac_str, (unsigned long)my_id);
|
||||
led_ring_find_me();
|
||||
}
|
||||
|
||||
static void handle_slave_accel_deadzone(const uint8_t *master_mac,
|
||||
const alox_EspNowAccelDeadzone *cfg) {
|
||||
uint32_t my_id = s_own_mac[5];
|
||||
@@ -492,6 +540,12 @@ static void espnow_recv_cb(const esp_now_recv_info_t *info, const uint8_t *data,
|
||||
case alox_EspNowMessage_accel_deadzone_tag:
|
||||
handle_slave_accel_deadzone(info->src_addr, &msg.payload.accel_deadzone);
|
||||
break;
|
||||
case alox_EspNowMessage_find_me_tag:
|
||||
if (!s_slave_joined || !mac_equal(info->src_addr, s_master_mac)) {
|
||||
break;
|
||||
}
|
||||
handle_slave_find_me(info->src_addr, &msg.payload.find_me);
|
||||
break;
|
||||
case alox_EspNowMessage_ota_start_tag:
|
||||
case alox_EspNowMessage_ota_payload_tag:
|
||||
case alox_EspNowMessage_ota_end_tag:
|
||||
|
||||
@@ -15,6 +15,10 @@ esp_err_t esp_now_comm_send_accel_deadzone(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
esp_err_t esp_now_comm_send_unicast_test(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t seq);
|
||||
|
||||
/** Master: trigger find-me LED sequence on one slave. */
|
||||
esp_err_t esp_now_comm_send_find_me(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t client_id);
|
||||
|
||||
/** Master → slave OTA (unicast). */
|
||||
esp_err_t esp_now_comm_send_ota_start(const uint8_t mac[CLIENT_MAC_LEN],
|
||||
uint32_t total_size);
|
||||
|
||||
+36
-9
@@ -20,6 +20,9 @@ static led_strip_handle_t led_ring;
|
||||
#define LED_RING_PIN 7
|
||||
#define LED_RING_BLINK_ON_MS 350
|
||||
#define LED_RING_BLINK_OFF_MS 150
|
||||
#define LED_RING_FIND_ME_ON_MS 300
|
||||
#define LED_RING_FIND_ME_OFF_MS 150
|
||||
#define LED_RING_FIND_ME_BLINKS_PER_COLOR 3
|
||||
|
||||
static QueueHandle_t led_queue;
|
||||
|
||||
@@ -67,6 +70,21 @@ static void ring_fill_color(uint8_t r, uint8_t g, uint8_t b) {
|
||||
}
|
||||
}
|
||||
|
||||
static void ring_blink_scaled(uint8_t r, uint8_t g, uint8_t b, uint8_t intensity,
|
||||
uint8_t count, uint16_t on_ms, uint16_t off_ms) {
|
||||
led_ring_scale_rgb(&r, &g, &b, intensity);
|
||||
for (uint8_t n = 0; n < count; n++) {
|
||||
ring_fill_color(r, g, b);
|
||||
led_strip_refresh(led_ring);
|
||||
vTaskDelay(pdMS_TO_TICKS(on_ms));
|
||||
led_strip_clear(led_ring);
|
||||
led_strip_refresh(led_ring);
|
||||
if (n + 1 < count) {
|
||||
vTaskDelay(pdMS_TO_TICKS(off_ms));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void vTaskLedRing(void *pvParameters) {
|
||||
led_strip_config_t ring_config = {
|
||||
.strip_gpio_num = LED_RING_PIN,
|
||||
@@ -109,15 +127,19 @@ void vTaskLedRing(void *pvParameters) {
|
||||
} else if (cmd.mode == LED_CMD_BLINK) {
|
||||
uint16_t on_ms = cmd.blink_ms > 0 ? cmd.blink_ms : LED_RING_BLINK_ON_MS;
|
||||
uint8_t count = cmd.blink_count > 0 ? cmd.blink_count : 1;
|
||||
|
||||
for (uint8_t n = 0; n < count; n++) {
|
||||
ring_fill_color(r, g, b);
|
||||
led_strip_refresh(led_ring);
|
||||
vTaskDelay(pdMS_TO_TICKS(on_ms));
|
||||
led_strip_clear(led_ring);
|
||||
led_strip_refresh(led_ring);
|
||||
if (n + 1 < count) {
|
||||
vTaskDelay(pdMS_TO_TICKS(LED_RING_BLINK_OFF_MS));
|
||||
ring_blink_scaled(cmd.r, cmd.g, cmd.b, cmd.intensity, count, on_ms,
|
||||
LED_RING_BLINK_OFF_MS);
|
||||
continue;
|
||||
} else if (cmd.mode == LED_CMD_FIND_ME) {
|
||||
static const struct {
|
||||
uint8_t r, g, b;
|
||||
} colors[] = {{255, 0, 0}, {0, 255, 0}, {0, 0, 255}};
|
||||
for (size_t c = 0; c < sizeof(colors) / sizeof(colors[0]); c++) {
|
||||
ring_blink_scaled(colors[c].r, colors[c].g, colors[c].b,
|
||||
LED_RING_FULL_INTENSITY, LED_RING_FIND_ME_BLINKS_PER_COLOR,
|
||||
LED_RING_FIND_ME_ON_MS, LED_RING_FIND_ME_OFF_MS);
|
||||
if (c + 1 < sizeof(colors) / sizeof(colors[0])) {
|
||||
vTaskDelay(pdMS_TO_TICKS(LED_RING_FIND_ME_OFF_MS));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -195,3 +217,8 @@ void led_ring_blink_once(uint8_t r, uint8_t g, uint8_t b) {
|
||||
void led_ring_ota_success(void) { led_ring_blink_once(0, 255, 0); }
|
||||
|
||||
void led_ring_ota_failed(void) { led_ring_blink_once(255, 0, 0); }
|
||||
|
||||
void led_ring_find_me(void) {
|
||||
led_command_t cmd = {.mode = LED_CMD_FIND_ME};
|
||||
led_ring_send_command(&cmd);
|
||||
}
|
||||
|
||||
+7
-1
@@ -5,13 +5,16 @@
|
||||
|
||||
/** Default RGB scale (~5 % of full brightness). */
|
||||
#define LED_RING_DEFAULT_INTENSITY 13
|
||||
/** Full brightness for find-me and similar alerts. */
|
||||
#define LED_RING_FULL_INTENSITY 255
|
||||
|
||||
typedef enum {
|
||||
LED_CMD_CLEAR,
|
||||
LED_CMD_SET_DIGIT,
|
||||
LED_CMD_SET_COLOR,
|
||||
LED_CMD_PROGRESS,
|
||||
LED_CMD_BLINK
|
||||
LED_CMD_BLINK,
|
||||
LED_CMD_FIND_ME
|
||||
} led_mode_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -39,4 +42,7 @@ void led_ring_blink_once(uint8_t r, uint8_t g, uint8_t b);
|
||||
void led_ring_ota_success(void);
|
||||
void led_ring_ota_failed(void);
|
||||
|
||||
/** Red / green / blue: 3 blinks each at full intensity. */
|
||||
void led_ring_find_me(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "cmd_handler.h"
|
||||
#include "cmd_accel_deadzone.h"
|
||||
#include "cmd_espnow_unicast_test.h"
|
||||
#include "cmd_espnow_find_me.h"
|
||||
#include "cmd_client_info.h"
|
||||
#include "cmd_version.h"
|
||||
#include "cmd_ota.h"
|
||||
@@ -169,6 +170,7 @@ void app_main(void) {
|
||||
cmd_client_info_register();
|
||||
cmd_accel_deadzone_register();
|
||||
cmd_espnow_unicast_test_register();
|
||||
cmd_espnow_find_me_register();
|
||||
cmd_led_ring_register();
|
||||
cmd_ota_register();
|
||||
cmd_ota_slave_progress_register();
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
PB_BIND(alox_EspNowUnicastTest, alox_EspNowUnicastTest, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowFindMe, alox_EspNowFindMe, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowDiscover, alox_EspNowDiscover, AUTO)
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* Automatically generated nanopb header */
|
||||
/* Generated by nanopb-1.0.0-dev */
|
||||
|
||||
#ifndef PB_ALOX_MAIN_PROTO_ESP_NOW_MESSAGES_PB_H_INCLUDED
|
||||
#define PB_ALOX_MAIN_PROTO_ESP_NOW_MESSAGES_PB_H_INCLUDED
|
||||
#ifndef PB_ALOX_ESP_NOW_MESSAGES_PB_H_INCLUDED
|
||||
#define PB_ALOX_ESP_NOW_MESSAGES_PB_H_INCLUDED
|
||||
#include <pb.h>
|
||||
|
||||
#if PB_PROTO_HEADER_VERSION != 40
|
||||
@@ -20,7 +20,8 @@ typedef enum _alox_EspNowMessageType {
|
||||
alox_EspNowMessageType_ESPNOW_OTA_START = 6,
|
||||
alox_EspNowMessageType_ESPNOW_OTA_PAYLOAD = 7,
|
||||
alox_EspNowMessageType_ESPNOW_OTA_END = 8,
|
||||
alox_EspNowMessageType_ESPNOW_OTA_STATUS = 9
|
||||
alox_EspNowMessageType_ESPNOW_OTA_STATUS = 9,
|
||||
alox_EspNowMessageType_ESPNOW_FIND_ME = 10
|
||||
} alox_EspNowMessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -28,6 +29,12 @@ typedef struct _alox_EspNowUnicastTest {
|
||||
uint32_t seq;
|
||||
} alox_EspNowUnicastTest;
|
||||
|
||||
/* * Master → slave: locate pod (LED ring R/G/B ×3 @ full brightness). */
|
||||
typedef struct _alox_EspNowFindMe {
|
||||
/* * 0 = any slave; otherwise only slave_id must match */
|
||||
uint32_t client_id;
|
||||
} alox_EspNowFindMe;
|
||||
|
||||
typedef struct _alox_EspNowDiscover {
|
||||
uint32_t network;
|
||||
} alox_EspNowDiscover;
|
||||
@@ -83,6 +90,7 @@ typedef struct _alox_EspNowMessage {
|
||||
alox_EspNowOtaPayload ota_payload;
|
||||
alox_EspNowOtaEnd ota_end;
|
||||
alox_EspNowOtaStatus ota_status;
|
||||
alox_EspNowFindMe find_me;
|
||||
} payload;
|
||||
} alox_EspNowMessage;
|
||||
|
||||
@@ -93,8 +101,9 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_EspNowMessageType_MIN alox_EspNowMessageType_ESPNOW_UNKNOWN
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_OTA_STATUS
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_OTA_STATUS+1))
|
||||
#define _alox_EspNowMessageType_MAX alox_EspNowMessageType_ESPNOW_FIND_ME
|
||||
#define _alox_EspNowMessageType_ARRAYSIZE ((alox_EspNowMessageType)(alox_EspNowMessageType_ESPNOW_FIND_ME+1))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -109,6 +118,7 @@ extern "C" {
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define alox_EspNowUnicastTest_init_default {0}
|
||||
#define alox_EspNowFindMe_init_default {0}
|
||||
#define alox_EspNowDiscover_init_default {0}
|
||||
#define alox_EspNowSlavePresence_init_default {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_default {0, 0}
|
||||
@@ -118,6 +128,7 @@ extern "C" {
|
||||
#define alox_EspNowOtaStatus_init_default {0, 0, 0}
|
||||
#define alox_EspNowMessage_init_default {_alox_EspNowMessageType_MIN, 0, {alox_EspNowDiscover_init_default}}
|
||||
#define alox_EspNowUnicastTest_init_zero {0}
|
||||
#define alox_EspNowFindMe_init_zero {0}
|
||||
#define alox_EspNowDiscover_init_zero {0}
|
||||
#define alox_EspNowSlavePresence_init_zero {0, {{NULL}, NULL}, 0, 0, 0, 0}
|
||||
#define alox_EspNowAccelDeadzone_init_zero {0, 0}
|
||||
@@ -129,6 +140,7 @@ extern "C" {
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define alox_EspNowUnicastTest_seq_tag 1
|
||||
#define alox_EspNowFindMe_client_id_tag 1
|
||||
#define alox_EspNowDiscover_network_tag 1
|
||||
#define alox_EspNowSlavePresence_network_tag 1
|
||||
#define alox_EspNowSlavePresence_mac_tag 2
|
||||
@@ -154,6 +166,7 @@ extern "C" {
|
||||
#define alox_EspNowMessage_ota_payload_tag 8
|
||||
#define alox_EspNowMessage_ota_end_tag 9
|
||||
#define alox_EspNowMessage_ota_status_tag 10
|
||||
#define alox_EspNowMessage_find_me_tag 11
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_EspNowUnicastTest_FIELDLIST(X, a) \
|
||||
@@ -161,6 +174,11 @@ X(a, STATIC, SINGULAR, UINT32, seq, 1)
|
||||
#define alox_EspNowUnicastTest_CALLBACK NULL
|
||||
#define alox_EspNowUnicastTest_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowFindMe_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowFindMe_CALLBACK NULL
|
||||
#define alox_EspNowFindMe_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowDiscover_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, network, 1)
|
||||
#define alox_EspNowDiscover_CALLBACK NULL
|
||||
@@ -215,7 +233,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,unicast_test,payload.unicast_test),
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_start,payload.ota_start), 7) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_payload,payload.ota_payload), 8) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_end,payload.ota_end), 9) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_status,payload.ota_status), 10)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_status,payload.ota_status), 10) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,find_me,payload.find_me), 11)
|
||||
#define alox_EspNowMessage_CALLBACK NULL
|
||||
#define alox_EspNowMessage_DEFAULT NULL
|
||||
#define alox_EspNowMessage_payload_discover_MSGTYPE alox_EspNowDiscover
|
||||
@@ -227,8 +246,10 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,ota_status,payload.ota_status), 10)
|
||||
#define alox_EspNowMessage_payload_ota_payload_MSGTYPE alox_EspNowOtaPayload
|
||||
#define alox_EspNowMessage_payload_ota_end_MSGTYPE alox_EspNowOtaEnd
|
||||
#define alox_EspNowMessage_payload_ota_status_MSGTYPE alox_EspNowOtaStatus
|
||||
#define alox_EspNowMessage_payload_find_me_MSGTYPE alox_EspNowFindMe
|
||||
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMe_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowDiscover_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowSlavePresence_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowAccelDeadzone_msg;
|
||||
@@ -240,6 +261,7 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
|
||||
/* Defines for backwards compatibility with code written before nanopb-0.4.0 */
|
||||
#define alox_EspNowUnicastTest_fields &alox_EspNowUnicastTest_msg
|
||||
#define alox_EspNowFindMe_fields &alox_EspNowFindMe_msg
|
||||
#define alox_EspNowDiscover_fields &alox_EspNowDiscover_msg
|
||||
#define alox_EspNowSlavePresence_fields &alox_EspNowSlavePresence_msg
|
||||
#define alox_EspNowAccelDeadzone_fields &alox_EspNowAccelDeadzone_msg
|
||||
@@ -252,9 +274,10 @@ extern const pb_msgdesc_t alox_EspNowMessage_msg;
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
/* alox_EspNowSlavePresence_size depends on runtime parameters */
|
||||
/* alox_EspNowMessage_size depends on runtime parameters */
|
||||
#define ALOX_MAIN_PROTO_ESP_NOW_MESSAGES_PB_H_MAX_SIZE alox_EspNowOtaPayload_size
|
||||
#define ALOX_ESP_NOW_MESSAGES_PB_H_MAX_SIZE alox_EspNowOtaPayload_size
|
||||
#define alox_EspNowAccelDeadzone_size 12
|
||||
#define alox_EspNowDiscover_size 6
|
||||
#define alox_EspNowFindMe_size 6
|
||||
#define alox_EspNowOtaEnd_size 0
|
||||
#define alox_EspNowOtaPayload_size 209
|
||||
#define alox_EspNowOtaStart_size 6
|
||||
|
||||
@@ -15,12 +15,19 @@ enum EspNowMessageType {
|
||||
ESPNOW_OTA_PAYLOAD = 7;
|
||||
ESPNOW_OTA_END = 8;
|
||||
ESPNOW_OTA_STATUS = 9;
|
||||
ESPNOW_FIND_ME = 10;
|
||||
}
|
||||
|
||||
message EspNowUnicastTest {
|
||||
uint32 seq = 1;
|
||||
}
|
||||
|
||||
/** Master → slave: locate pod (LED ring R/G/B ×3 @ full brightness). */
|
||||
message EspNowFindMe {
|
||||
/** 0 = any slave; otherwise only slave_id must match */
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
message EspNowDiscover {
|
||||
uint32 network = 1;
|
||||
}
|
||||
@@ -72,5 +79,6 @@ message EspNowMessage {
|
||||
EspNowOtaPayload ota_payload = 8;
|
||||
EspNowOtaEnd ota_end = 9;
|
||||
EspNowOtaStatus ota_status = 10;
|
||||
EspNowFindMe find_me = 11;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ PB_BIND(alox_LedRingProgressRequest, alox_LedRingProgressRequest, AUTO)
|
||||
PB_BIND(alox_LedRingProgressResponse, alox_LedRingProgressResponse, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowFindMeRequest, alox_EspNowFindMeRequest, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_EspNowFindMeResponse, alox_EspNowFindMeResponse, AUTO)
|
||||
|
||||
|
||||
PB_BIND(alox_OtaStartPayload, alox_OtaStartPayload, AUTO)
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ typedef enum _alox_MessageType {
|
||||
alox_MessageType_OTA_END = 18,
|
||||
alox_MessageType_OTA_STATUS = 19,
|
||||
alox_MessageType_OTA_START_ESPNOW = 20,
|
||||
alox_MessageType_OTA_SLAVE_PROGRESS = 21
|
||||
alox_MessageType_OTA_SLAVE_PROGRESS = 21,
|
||||
alox_MessageType_FIND_ME = 22
|
||||
} alox_MessageType;
|
||||
|
||||
/* Struct definitions */
|
||||
@@ -96,8 +97,8 @@ typedef struct _alox_EspNowUnicastTestResponse {
|
||||
uint32_t seq;
|
||||
} alox_EspNowUnicastTestResponse;
|
||||
|
||||
/* Host → device: LED ring display (progress bar, digit, clear, or blink).
|
||||
mode: 0=clear, 1=progress (0–100 %), 2=digit (0–10), 3=blink full ring. */
|
||||
/* Host → device: LED ring display (progress bar, digit, clear, blink, or find-me).
|
||||
mode: 0=clear, 1=progress (0–100 %), 2=digit (0–10), 3=blink full ring, 4=find-me (R/G/B ×3 @ full brightness). */
|
||||
typedef struct _alox_LedRingProgressRequest {
|
||||
uint32_t mode;
|
||||
/* * 0–100: fraction of ring LEDs to light (mode=progress) */
|
||||
@@ -122,6 +123,16 @@ typedef struct _alox_LedRingProgressResponse {
|
||||
uint32_t digit;
|
||||
} alox_LedRingProgressResponse;
|
||||
|
||||
/* * Host → master: find-me on local ring (client_id=0) or ESP-NOW unicast to one slave. */
|
||||
typedef struct _alox_EspNowFindMeRequest {
|
||||
uint32_t client_id;
|
||||
} alox_EspNowFindMeRequest;
|
||||
|
||||
typedef struct _alox_EspNowFindMeResponse {
|
||||
bool success;
|
||||
uint32_t client_id;
|
||||
} alox_EspNowFindMeResponse;
|
||||
|
||||
/* Host → device: begin UART OTA (erase inactive OTA slot; device replies OTA_STATUS). */
|
||||
typedef struct _alox_OtaStartPayload {
|
||||
uint32_t total_size;
|
||||
@@ -192,6 +203,8 @@ typedef struct _alox_UartMessage {
|
||||
alox_OtaSlaveProgressResponse ota_slave_progress_response;
|
||||
alox_LedRingProgressRequest led_ring_progress_request;
|
||||
alox_LedRingProgressResponse led_ring_progress_response;
|
||||
alox_EspNowFindMeRequest espnow_find_me_request;
|
||||
alox_EspNowFindMeResponse espnow_find_me_response;
|
||||
} payload;
|
||||
} alox_UartMessage;
|
||||
|
||||
@@ -202,8 +215,8 @@ extern "C" {
|
||||
|
||||
/* Helper constants for enums */
|
||||
#define _alox_MessageType_MIN alox_MessageType_UNKNOWN
|
||||
#define _alox_MessageType_MAX alox_MessageType_OTA_SLAVE_PROGRESS
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_OTA_SLAVE_PROGRESS+1))
|
||||
#define _alox_MessageType_MAX alox_MessageType_FIND_ME
|
||||
#define _alox_MessageType_ARRAYSIZE ((alox_MessageType)(alox_MessageType_FIND_ME+1))
|
||||
|
||||
#define alox_UartMessage_type_ENUMTYPE alox_MessageType
|
||||
|
||||
@@ -225,6 +238,8 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -243,6 +258,8 @@ extern "C" {
|
||||
#define alox_EspNowUnicastTestResponse_init_default {0, 0}
|
||||
#define alox_LedRingProgressRequest_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_LedRingProgressResponse_init_default {0, 0, 0, 0}
|
||||
#define alox_EspNowFindMeRequest_init_default {0}
|
||||
#define alox_EspNowFindMeResponse_init_default {0, 0}
|
||||
#define alox_OtaStartPayload_init_default {0}
|
||||
#define alox_OtaPayload_init_default {0, {0, {0}}}
|
||||
#define alox_OtaEndPayload_init_default {0}
|
||||
@@ -264,6 +281,8 @@ extern "C" {
|
||||
#define alox_EspNowUnicastTestResponse_init_zero {0, 0}
|
||||
#define alox_LedRingProgressRequest_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define alox_LedRingProgressResponse_init_zero {0, 0, 0, 0}
|
||||
#define alox_EspNowFindMeRequest_init_zero {0}
|
||||
#define alox_EspNowFindMeResponse_init_zero {0, 0}
|
||||
#define alox_OtaStartPayload_init_zero {0}
|
||||
#define alox_OtaPayload_init_zero {0, {0, {0}}}
|
||||
#define alox_OtaEndPayload_init_zero {0}
|
||||
@@ -315,6 +334,9 @@ extern "C" {
|
||||
#define alox_LedRingProgressResponse_mode_tag 2
|
||||
#define alox_LedRingProgressResponse_progress_tag 3
|
||||
#define alox_LedRingProgressResponse_digit_tag 4
|
||||
#define alox_EspNowFindMeRequest_client_id_tag 1
|
||||
#define alox_EspNowFindMeResponse_success_tag 1
|
||||
#define alox_EspNowFindMeResponse_client_id_tag 2
|
||||
#define alox_OtaStartPayload_total_size_tag 1
|
||||
#define alox_OtaPayload_seq_tag 1
|
||||
#define alox_OtaPayload_data_tag 2
|
||||
@@ -351,6 +373,8 @@ extern "C" {
|
||||
#define alox_UartMessage_ota_slave_progress_response_tag 16
|
||||
#define alox_UartMessage_led_ring_progress_request_tag 17
|
||||
#define alox_UartMessage_led_ring_progress_response_tag 18
|
||||
#define alox_UartMessage_espnow_find_me_request_tag 19
|
||||
#define alox_UartMessage_espnow_find_me_response_tag 20
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
#define alox_UartMessage_FIELDLIST(X, a) \
|
||||
@@ -371,7 +395,9 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_unicast_test_response,payload
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_slave_progress_request,payload.ota_slave_progress_request), 15) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,ota_slave_progress_response,payload.ota_slave_progress_response), 16) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_request,payload.led_ring_progress_request), 17) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_response,payload.led_ring_progress_response), 18)
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_response,payload.led_ring_progress_response), 18) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_request,payload.espnow_find_me_request), 19) \
|
||||
X(a, STATIC, ONEOF, MESSAGE, (payload,espnow_find_me_response,payload.espnow_find_me_response), 20)
|
||||
#define alox_UartMessage_CALLBACK NULL
|
||||
#define alox_UartMessage_DEFAULT NULL
|
||||
#define alox_UartMessage_payload_ack_payload_MSGTYPE alox_Ack
|
||||
@@ -391,6 +417,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload,led_ring_progress_response,payload.l
|
||||
#define alox_UartMessage_payload_ota_slave_progress_response_MSGTYPE alox_OtaSlaveProgressResponse
|
||||
#define alox_UartMessage_payload_led_ring_progress_request_MSGTYPE alox_LedRingProgressRequest
|
||||
#define alox_UartMessage_payload_led_ring_progress_response_MSGTYPE alox_LedRingProgressResponse
|
||||
#define alox_UartMessage_payload_espnow_find_me_request_MSGTYPE alox_EspNowFindMeRequest
|
||||
#define alox_UartMessage_payload_espnow_find_me_response_MSGTYPE alox_EspNowFindMeResponse
|
||||
|
||||
#define alox_Ack_FIELDLIST(X, a) \
|
||||
|
||||
@@ -489,6 +517,17 @@ X(a, STATIC, SINGULAR, UINT32, digit, 4)
|
||||
#define alox_LedRingProgressResponse_CALLBACK NULL
|
||||
#define alox_LedRingProgressResponse_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowFindMeRequest_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 1)
|
||||
#define alox_EspNowFindMeRequest_CALLBACK NULL
|
||||
#define alox_EspNowFindMeRequest_DEFAULT NULL
|
||||
|
||||
#define alox_EspNowFindMeResponse_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, BOOL, success, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, client_id, 2)
|
||||
#define alox_EspNowFindMeResponse_CALLBACK NULL
|
||||
#define alox_EspNowFindMeResponse_DEFAULT NULL
|
||||
|
||||
#define alox_OtaStartPayload_FIELDLIST(X, a) \
|
||||
X(a, STATIC, SINGULAR, UINT32, total_size, 1)
|
||||
#define alox_OtaStartPayload_CALLBACK NULL
|
||||
@@ -551,6 +590,8 @@ extern const pb_msgdesc_t alox_EspNowUnicastTestRequest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowUnicastTestResponse_msg;
|
||||
extern const pb_msgdesc_t alox_LedRingProgressRequest_msg;
|
||||
extern const pb_msgdesc_t alox_LedRingProgressResponse_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMeRequest_msg;
|
||||
extern const pb_msgdesc_t alox_EspNowFindMeResponse_msg;
|
||||
extern const pb_msgdesc_t alox_OtaStartPayload_msg;
|
||||
extern const pb_msgdesc_t alox_OtaPayload_msg;
|
||||
extern const pb_msgdesc_t alox_OtaEndPayload_msg;
|
||||
@@ -574,6 +615,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_EspNowUnicastTestResponse_fields &alox_EspNowUnicastTestResponse_msg
|
||||
#define alox_LedRingProgressRequest_fields &alox_LedRingProgressRequest_msg
|
||||
#define alox_LedRingProgressResponse_fields &alox_LedRingProgressResponse_msg
|
||||
#define alox_EspNowFindMeRequest_fields &alox_EspNowFindMeRequest_msg
|
||||
#define alox_EspNowFindMeResponse_fields &alox_EspNowFindMeResponse_msg
|
||||
#define alox_OtaStartPayload_fields &alox_OtaStartPayload_msg
|
||||
#define alox_OtaPayload_fields &alox_OtaPayload_msg
|
||||
#define alox_OtaEndPayload_fields &alox_OtaEndPayload_msg
|
||||
@@ -594,6 +637,8 @@ extern const pb_msgdesc_t alox_OtaSlaveProgressResponse_msg;
|
||||
#define alox_AccelDeadzoneResponse_size 20
|
||||
#define alox_Ack_size 0
|
||||
#define alox_ClientInput_size 22
|
||||
#define alox_EspNowFindMeRequest_size 6
|
||||
#define alox_EspNowFindMeResponse_size 8
|
||||
#define alox_EspNowUnicastTestRequest_size 12
|
||||
#define alox_EspNowUnicastTestResponse_size 8
|
||||
#define alox_LedRingProgressRequest_size 54
|
||||
|
||||
@@ -20,6 +20,7 @@ enum MessageType {
|
||||
OTA_STATUS = 19;
|
||||
OTA_START_ESPNOW = 20;
|
||||
OTA_SLAVE_PROGRESS = 21;
|
||||
FIND_ME = 22;
|
||||
}
|
||||
|
||||
message UartMessage {
|
||||
@@ -42,6 +43,8 @@ message UartMessage {
|
||||
OtaSlaveProgressResponse ota_slave_progress_response = 16;
|
||||
LedRingProgressRequest led_ring_progress_request = 17;
|
||||
LedRingProgressResponse led_ring_progress_response = 18;
|
||||
EspNowFindMeRequest espnow_find_me_request = 19;
|
||||
EspNowFindMeResponse espnow_find_me_response = 20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +113,8 @@ message EspNowUnicastTestResponse {
|
||||
uint32 seq = 2;
|
||||
}
|
||||
|
||||
// Host → device: LED ring display (progress bar, digit, clear, or blink).
|
||||
// mode: 0=clear, 1=progress (0–100 %), 2=digit (0–10), 3=blink full ring.
|
||||
// Host → device: LED ring display (progress bar, digit, clear, blink, or find-me).
|
||||
// mode: 0=clear, 1=progress (0–100 %), 2=digit (0–10), 3=blink full ring, 4=find-me (R/G/B ×3 @ full brightness).
|
||||
message LedRingProgressRequest {
|
||||
uint32 mode = 1;
|
||||
/** 0–100: fraction of ring LEDs to light (mode=progress) */
|
||||
@@ -136,6 +139,16 @@ message LedRingProgressResponse {
|
||||
uint32 digit = 4;
|
||||
}
|
||||
|
||||
/** Host → master: find-me on local ring (client_id=0) or ESP-NOW unicast to one slave. */
|
||||
message EspNowFindMeRequest {
|
||||
uint32 client_id = 1;
|
||||
}
|
||||
|
||||
message EspNowFindMeResponse {
|
||||
bool success = 1;
|
||||
uint32 client_id = 2;
|
||||
}
|
||||
|
||||
// Host → device: begin UART OTA (erase inactive OTA slot; device replies OTA_STATUS).
|
||||
message OtaStartPayload {
|
||||
uint32 total_size = 1;
|
||||
|
||||
Reference in New Issue
Block a user