feat(control_plane): add light standby coordinator
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -89,6 +90,35 @@ typedef struct {
|
||||
esp_err_t last_error;
|
||||
} control_plane_ota_snapshot_t;
|
||||
|
||||
typedef enum {
|
||||
CONTROL_PLANE_LIGHT_STANDBY_STATE_DISABLED = 0,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_STATE_ACTIVE,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_STATE_ENTERING,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_STATE_STANDBY,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_STATE_WAKING,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_STATE_STOPPED,
|
||||
} control_plane_light_standby_state_t;
|
||||
|
||||
typedef enum {
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_UNSPECIFIED = 0,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_KEY,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_LOCAL_WAKE,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_VOICE_INPUT,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_VOICE_OUTPUT,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_MODEL_COMMAND,
|
||||
CONTROL_PLANE_LIGHT_STANDBY_ACTIVITY_EXTERNAL,
|
||||
} control_plane_light_standby_activity_t;
|
||||
|
||||
typedef struct {
|
||||
control_plane_light_standby_state_t state;
|
||||
control_plane_light_standby_activity_t last_activity;
|
||||
bool running;
|
||||
uint32_t idle_timeout_ms;
|
||||
uint64_t last_activity_ms;
|
||||
uint64_t standby_since_ms;
|
||||
uint32_t transition_count;
|
||||
} control_plane_light_standby_snapshot_t;
|
||||
|
||||
esp_err_t control_plane_init(void);
|
||||
|
||||
/**
|
||||
@@ -109,6 +139,38 @@ esp_err_t control_plane_battery_service_start(void);
|
||||
*/
|
||||
esp_err_t control_plane_prepare_runtime_storage(void);
|
||||
|
||||
/**
|
||||
* @brief Start the control-plane owned light-standby coordinator.
|
||||
*
|
||||
* The coordinator tracks one inactivity deadline for the full runtime. Phase
|
||||
* one records state transitions only; hardware power policies are attached in
|
||||
* later phases. Repeated starts are idempotent.
|
||||
*/
|
||||
esp_err_t control_plane_light_standby_start(void);
|
||||
|
||||
/**
|
||||
* @brief Stop the light-standby coordinator with bounded teardown.
|
||||
*
|
||||
* Zero requests asynchronous stop. Positive values wait up to the supplied
|
||||
* timeout and apply deterministic task teardown if necessary.
|
||||
*/
|
||||
esp_err_t control_plane_light_standby_stop(int timeout_ms);
|
||||
|
||||
/**
|
||||
* @brief Record user activity and return the coordinator to ACTIVE state.
|
||||
*
|
||||
* This call is non-blocking and safe from control-plane worker tasks. It must
|
||||
* not be called directly from an ISR.
|
||||
*/
|
||||
esp_err_t control_plane_light_standby_record_activity(
|
||||
control_plane_light_standby_activity_t activity);
|
||||
|
||||
/**
|
||||
* @brief Copy the current light-standby state snapshot.
|
||||
*/
|
||||
esp_err_t control_plane_light_standby_get_snapshot(
|
||||
control_plane_light_standby_snapshot_t *out_snapshot);
|
||||
|
||||
/**
|
||||
* @brief Parse one direction command without side effects.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user