|
TB2026-YDS Firmware
|
Autonomy test service: run lifecycle, discharge-curve logging, SD export. More...
#include "autonomy.h"#include "power.h"#include "storage.h"#include "sdcard.h"#include "player.h"#include "playlist.h"#include "volume.h"#include "bluetooth.h"#include "track_meta.h"#include "esp_timer.h"#include "esp_app_desc.h"#include "esp_system.h"#include "esp_private/esp_clk.h"#include "esp_log.h"#include "nvs.h"#include <stddef.h>#include <stdio.h>#include <string.h>#include <strings.h>Macros | |
| #define | NVS_NS "autonomy" |
| #define | NVS_KEY_RUN "run" |
| #define | NVS_KEY_SEQ "seq" /* monotonic run counter, for unique CSV file names */ |
| #define | RUN_MAGIC 0xA5D50001u |
| #define | RUN_VERSION 4 /* v4 added per-sample BT flag + min-heap, and run-start SD/CPU freq (v3: firmware version; v2: workload header) */ |
| #define | MAX_SAMPLES 256 /* blob stays ~2.5 KB — the NVS partition is only 24 KB */ |
| #define | SAMPLE_S_0 60 /* initial seconds between samples ("every minute") */ |
| #define | JACK_VOL_PCT 50 |
| #define | BT_VOL_PCT 1 |
| #define | FMT_NONE 0 |
| #define | FMT_MP3 1 |
| #define | FMT_WAV 2 |
| #define | FILE_MAX 48 /* stored track name, truncated (header only, once per run) */ |
Functions | |
| struct | __attribute__ ((packed)) |
| esp_err_t | autonomy_start (autonomy_test_t type) |
| Start an autonomy run with the given workload. | |
| void | autonomy_cancel (void) |
| Cancel the running test, keeping it as the last (cancelled) result. No-op if idle. | |
| bool | autonomy_is_running (void) |
| Whether a run is currently in progress. | |
| void | autonomy_get_status (autonomy_status_t *out) |
| Copy the running test's snapshot. | |
| void | autonomy_tick (void) |
| Periodic hook, called from the maintenance task (after power_tick()). | |
| esp_err_t | autonomy_boot_export (void) |
| Export a stored (not-yet-exported) run to a CSV on the SD card. Call once at boot. | |
| esp_err_t | autonomy_redump (void) |
| Re-export the last stored run to a fresh CSV on the SD card (without rebooting). | |
| autonomy_result_t | autonomy_get_last_result (void) |
| Outcome of the most recent run (AUTONOMY_RESULT_NONE until one happens). | |
| autonomy_test_t | autonomy_get_last_type (void) |
| Workload of the most recent run (valid when the last result is not NONE). | |
| uint32_t | autonomy_get_last_duration_s (void) |
| Duration of the most recent run in seconds (0 if none). | |
| bool | autonomy_get_last_dump_ok (void) |
| Whether the most recent run has been successfully written to the SD card. | |
Variables | |
| sample_t | |
| run_t | |
Autonomy test service: run lifecycle, discharge-curve logging, SD export.
| #define BT_VOL_PCT 1 |
| #define FILE_MAX 48 /* stored track name, truncated (header only, once per run) */ |
| #define FMT_MP3 1 |
| #define FMT_NONE 0 |
| #define FMT_WAV 2 |
| #define JACK_VOL_PCT 50 |
| #define MAX_SAMPLES 256 /* blob stays ~2.5 KB — the NVS partition is only 24 KB */ |
| #define NVS_KEY_RUN "run" |
| #define NVS_KEY_SEQ "seq" /* monotonic run counter, for unique CSV file names */ |
| #define NVS_NS "autonomy" |
| #define RUN_MAGIC 0xA5D50001u |
| #define RUN_VERSION 4 /* v4 added per-sample BT flag + min-heap, and run-start SD/CPU freq (v3: firmware version; v2: workload header) */ |
| #define SAMPLE_S_0 60 /* initial seconds between samples ("every minute") */ |
| struct __attribute__ | ( | (packed) | ) |
| run_t |
| sample_t |