Raise host frame payload limit so multi-client UART replies fit.
Use a uint16 LE length and 1024-byte max payload so CLIENT_INFO and BATTERY_STATUS no longer fail encoding past ~10 connected pods. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,18 +1,26 @@
|
||||
#include "uart_proto.h"
|
||||
#include "esp_log.h"
|
||||
#include "pb_encode.h"
|
||||
#include "uart.h"
|
||||
#include <string.h>
|
||||
|
||||
static const char *TAG = "[UART_PROTO]";
|
||||
|
||||
esp_err_t uart_send_uart_message(const alox_UartMessage *msg) {
|
||||
uint8_t pb_buf[MAX_PAYLOAD_SIZE];
|
||||
pb_ostream_t stream = pb_ostream_from_buffer(pb_buf, sizeof(pb_buf));
|
||||
|
||||
if (!pb_encode(&stream, alox_UartMessage_fields, msg)) {
|
||||
ESP_LOGE(TAG, "pb_encode failed type=%u (%s)", (unsigned)msg->type,
|
||||
PB_GET_ERROR(&stream));
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
uint8_t payload[MAX_PAYLOAD_SIZE];
|
||||
if (stream.bytes_written + 1 > sizeof(payload)) {
|
||||
ESP_LOGE(TAG, "payload too large type=%u need=%u max=%u",
|
||||
(unsigned)msg->type, (unsigned)(stream.bytes_written + 1),
|
||||
(unsigned)sizeof(payload));
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user