Track ESP-NOW slaves in a shared registry and respond to CLIENT_INFO with protobuf ClientInfoResponse; ESP-NOW path upserts registry entries. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
889 B
C
34 lines
889 B
C
#ifndef CLIENT_REGISTRY_H
|
|
#define CLIENT_REGISTRY_H
|
|
|
|
#include "esp_err.h"
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#define CLIENT_REGISTRY_MAX 16
|
|
#define CLIENT_MAC_LEN 6
|
|
|
|
typedef struct {
|
|
uint32_t id;
|
|
bool available;
|
|
bool used;
|
|
uint8_t mac[CLIENT_MAC_LEN];
|
|
uint32_t last_ping;
|
|
uint32_t last_success_ping;
|
|
uint32_t version;
|
|
} client_info_t;
|
|
|
|
void client_registry_init(void);
|
|
|
|
/** Register or refresh a client; sets last_ping and last_success_ping to now. */
|
|
esp_err_t client_registry_upsert(const uint8_t mac[CLIENT_MAC_LEN], uint32_t id,
|
|
uint32_t version, bool available, bool used,
|
|
bool *out_is_new);
|
|
|
|
size_t client_registry_count(void);
|
|
const client_info_t *client_registry_at(size_t index);
|
|
const client_info_t *client_registry_find_by_mac(const uint8_t mac[CLIENT_MAC_LEN]);
|
|
|
|
#endif
|