Unify cache polling on CACHE_STATUS and split API docs.

Replace separate accel/tap snapshot UART commands with one clients[] response
that omits unsubscribed fields; remove snapshot handlers and CLI commands.
Add goTool/docs for WebSocket streams and REST; tap-snapshot REST uses CACHE_STATUS.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-29 21:23:09 +02:00
co-authored by Cursor
parent a85d48320e
commit 31e539052a
25 changed files with 1243 additions and 1269 deletions
+29 -20
View File
@@ -28,8 +28,7 @@ static void fill_cache_status(alox_CacheStatusResponse *out) {
return;
}
out->accel_count = 0;
out->taps_count = 0;
out->clients_count = 0;
size_t count = client_registry_count();
for (size_t i = 0; i < count; i++) {
@@ -38,31 +37,41 @@ static void fill_cache_status(alox_CacheStatusResponse *out) {
continue;
}
if (client->accel_stream_enabled &&
out->accel_count < sizeof(out->accel) / sizeof(out->accel[0])) {
alox_AccelSample *sample = &out->accel[out->accel_count++];
sample->client_id = client->id;
sample->valid = client->accel_valid;
sample->x = client->accel_x;
sample->y = client->accel_y;
sample->z = client->accel_z;
const bool want_accel = client->accel_stream_enabled;
const bool want_tap = tap_notify_any(client);
if (!want_accel && !want_tap) {
continue;
}
if (out->clients_count >=
sizeof(out->clients) / sizeof(out->clients[0])) {
break;
}
alox_CacheClientStatus *entry = &out->clients[out->clients_count++];
entry->client_id = client->id;
entry->has_accel = false;
entry->has_tap = false;
if (want_accel) {
entry->has_accel = true;
entry->accel.valid = client->accel_valid;
if (client->accel_valid) {
sample->age_ms = client_registry_ms_since(client->accel_updated_at);
entry->accel.x = client->accel_x;
entry->accel.y = client->accel_y;
entry->accel.z = client->accel_z;
entry->accel.age_ms =
client_registry_ms_since(client->accel_updated_at);
}
}
if (tap_notify_any(client) &&
out->taps_count < sizeof(out->taps) / sizeof(out->taps[0])) {
if (want_tap) {
uint32_t kind = 0;
uint32_t age_ms = 0;
if (!client_registry_take_tap(client->id, &kind, &age_ms)) {
continue;
if (client_registry_take_tap(client->id, &kind, &age_ms)) {
entry->has_tap = true;
entry->tap.kind = tap_kind_from_registry(kind);
entry->tap.age_ms = age_ms;
}
alox_TapEvent *event = &out->taps[out->taps_count++];
event->client_id = client->id;
event->valid = true;
event->kind = tap_kind_from_registry(kind);
event->age_ms = age_ms;
}
}
}