STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
self_test_port.h
Go to the documentation of this file.
1#ifndef STAR_SELF_TEST_PORT_H
2#define STAR_SELF_TEST_PORT_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define SELF_TEST_MAX_DEVICES 8U
12
21
26
27/* Negative diagnostics are reserved for the coordinator. */
28#define SELF_TEST_DIAG_BAD_REPLY (-1)
29#define SELF_TEST_DIAG_STALE_BATTERY (-2)
30#define SELF_TEST_DIAG_SESSION_TIMEOUT (-3)
31
39
46
47typedef struct {
48 uint32_t now_ms;
49 uint8_t device_count;
51 /* Required probes only; neither battery health nor link health. */
53 /* All inventory entries terminal, regardless of pass/fail or required.
54 * This does not assert report delivery/storage or authorize arming. */
58 /* Result of the previous publication when passed to publish_status. */
62
63/*
64 * All callbacks must return within budget_ms and release bus locks/resources
65 * before returning. PENDING permits later polling, not a retained transaction.
66 * Drivers own context; NULL context is allowed for stateless implementations.
67 * No callback may re-enter the coordinator or retain a status pointer.
68 */
69typedef struct {
70 /* attempt is one-based and remains unchanged while polling PENDING. */
71 self_test_reply_t (*probe)(void* context, uint16_t device_id,
72 uint8_t attempt, uint32_t now_ms,
73 uint32_t budget_ms);
74 /* Stamp fresh samples with now_ms; cached samples retain their old stamp.
75 */
76 self_test_battery_t (*read_battery)(void* context, uint32_t now_ms,
77 uint32_t budget_ms);
78 /*
79 * PASS requires LoRa TxDone within the adapter deadline, not merely
80 * enqueueing bytes. No ground-station ACK is required. PENDING/FAIL/TIMEOUT
81 * consume bounded retry attempts. Every call receives a fresh snapshot;
82 * coalesce superseded queued status.
83 */
85 const self_test_status_t* status,
86 uint32_t budget_ms);
88
89#ifdef __cplusplus
90}
91#endif
92#endif
#define SELF_TEST_MAX_DEVICES
self_test_result_t
@ SELF_TEST_FAIL
@ SELF_TEST_NOT_CONFIGURED
@ SELF_TEST_NOT_IMPLEMENTED
@ SELF_TEST_PENDING
@ SELF_TEST_PASS
@ SELF_TEST_TIMEOUT
self_test_reply_t reply
self_test_reply_t reply
self_test_reply_t(* probe)(void *context, uint16_t device_id, uint8_t attempt, uint32_t now_ms, uint32_t budget_ms)
self_test_reply_t(* publish_status)(void *context, const self_test_status_t *status, uint32_t budget_ms)
self_test_battery_t(* read_battery)(void *context, uint32_t now_ms, uint32_t budget_ms)
self_test_result_t result
self_test_result_t probes_outcome
self_test_reply_t publication
self_test_battery_t battery
self_test_device_status_t devices[SELF_TEST_MAX_DEVICES]