142 lines
4.9 KiB
C
142 lines
4.9 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "esp_err.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// ---------- platform_bootstrap ----------
|
|
esp_err_t platform_bootstrap_init(void);
|
|
|
|
// ---------- wifi_manager ----------
|
|
esp_err_t wifi_manager_start(void);
|
|
esp_err_t wifi_manager_stop(void);
|
|
|
|
bool wifi_manager_is_ready(void);
|
|
void wifi_manager_get_ip(char *buf, size_t buf_len);
|
|
|
|
// ---------- ble_printer_client ----------
|
|
typedef void (*ble_frame_rx_cb_t)(const uint8_t *data, size_t len);
|
|
|
|
typedef struct {
|
|
bool connected;
|
|
bool notify_ready;
|
|
uint16_t mtu;
|
|
} ble_link_state_t;
|
|
|
|
esp_err_t ble_printer_client_init(ble_frame_rx_cb_t rx_cb);
|
|
esp_err_t ble_printer_client_connect(const char *target_name, uint32_t timeout_ms);
|
|
void ble_printer_client_disconnect(void);
|
|
|
|
bool ble_printer_client_is_connected(void);
|
|
void ble_printer_client_get_link_state(ble_link_state_t *out_state);
|
|
esp_err_t ble_printer_client_write(const uint8_t *data, size_t len);
|
|
|
|
// ---------- voice_audio ----------
|
|
typedef struct {
|
|
uint32_t sample_rate;
|
|
uint8_t channels;
|
|
uint8_t bits_per_sample;
|
|
int output_volume;
|
|
float input_gain_db;
|
|
} voice_audio_open_config_t;
|
|
|
|
esp_err_t voice_audio_open(const voice_audio_open_config_t *cfg, char *err, size_t err_len);
|
|
void voice_audio_close(void);
|
|
|
|
bool voice_audio_is_open(void);
|
|
|
|
esp_err_t voice_audio_read_pcm(int16_t *pcm,
|
|
size_t samples,
|
|
uint32_t timeout_ms,
|
|
char *err,
|
|
size_t err_len);
|
|
esp_err_t voice_audio_write_pcm(const int16_t *pcm,
|
|
size_t samples,
|
|
uint32_t timeout_ms,
|
|
char *err,
|
|
size_t err_len);
|
|
|
|
// ---------- runtime_policy ----------
|
|
uint32_t runtime_policy_wifi_connect_timeout_ms(void);
|
|
|
|
uint32_t runtime_policy_lifecycle_start_retry_count(void);
|
|
uint32_t runtime_policy_lifecycle_retry_backoff_ms(uint32_t attempt);
|
|
bool runtime_policy_is_retryable_error(esp_err_t err);
|
|
|
|
uint32_t runtime_policy_printer_control_lock_timeout_ms(void);
|
|
uint32_t runtime_policy_printer_worker_queue_wait_ms(void);
|
|
uint32_t runtime_policy_printer_queue_retry_delay_ms(void);
|
|
uint32_t runtime_policy_printer_status_poll_interval_ms(void);
|
|
uint32_t runtime_policy_printer_stop_timeout_ms(void);
|
|
|
|
uint32_t runtime_policy_rest_printer_connect_timeout_ms(void);
|
|
uint32_t runtime_policy_rest_label_timeout_ms(void);
|
|
uint32_t runtime_policy_rest_ota_timeout_ms(void);
|
|
|
|
uint32_t runtime_policy_image_generation_timeout_default_ms(void);
|
|
uint32_t runtime_policy_image_generation_timeout_min_ms(void);
|
|
uint32_t runtime_policy_image_generation_timeout_max_ms(void);
|
|
|
|
uint32_t runtime_policy_image_download_timeout_default_ms(void);
|
|
uint32_t runtime_policy_image_download_timeout_min_ms(void);
|
|
uint32_t runtime_policy_image_download_timeout_max_ms(void);
|
|
|
|
// ---------- runtime_diagnostics ----------
|
|
typedef enum {
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_ATTEMPT = 0,
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_SUCCESS,
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_FAILED,
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_START_RETRY,
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_STOP_ATTEMPT,
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_STOP_SUCCESS,
|
|
RUNTIME_DIAG_COUNTER_LIFECYCLE_STOP_FAILED,
|
|
RUNTIME_DIAG_COUNTER_WIFI_CONNECT_SUCCESS,
|
|
RUNTIME_DIAG_COUNTER_WIFI_CONNECT_FAILED,
|
|
RUNTIME_DIAG_COUNTER_WIFI_CONNECT_TIMEOUT,
|
|
RUNTIME_DIAG_COUNTER_PRINTER_JOB_SUBMITTED,
|
|
RUNTIME_DIAG_COUNTER_PRINTER_JOB_SUCCESS,
|
|
RUNTIME_DIAG_COUNTER_PRINTER_JOB_FAILED,
|
|
RUNTIME_DIAG_COUNTER_PRINTER_JOB_CANCELED,
|
|
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_ATTEMPT,
|
|
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_SUCCESS,
|
|
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_FAILED,
|
|
RUNTIME_DIAG_COUNTER_IMAGE_GENERATE_TIMEOUT,
|
|
RUNTIME_DIAG_COUNTER_REST_RESPONSES_TOTAL,
|
|
RUNTIME_DIAG_COUNTER_REST_ERRORS_TOTAL,
|
|
RUNTIME_DIAG_COUNTER_MAX,
|
|
} runtime_diag_counter_t;
|
|
|
|
typedef enum {
|
|
RUNTIME_DIAG_GAUGE_LIFECYCLE_STATE = 0,
|
|
RUNTIME_DIAG_GAUGE_STATUS_POLL_PAUSE_DEPTH,
|
|
RUNTIME_DIAG_GAUGE_PRINTER_QUEUE_DEPTH,
|
|
RUNTIME_DIAG_GAUGE_MAX,
|
|
} runtime_diag_gauge_t;
|
|
|
|
typedef struct {
|
|
uint64_t counters[RUNTIME_DIAG_COUNTER_MAX];
|
|
int32_t gauges[RUNTIME_DIAG_GAUGE_MAX];
|
|
int64_t last_error_ms;
|
|
esp_err_t last_error_code;
|
|
char last_error_source[32];
|
|
char last_error_message[96];
|
|
} runtime_diag_snapshot_t;
|
|
|
|
void runtime_diag_counter_add(runtime_diag_counter_t counter, uint32_t delta);
|
|
void runtime_diag_set_gauge(runtime_diag_gauge_t gauge, int32_t value);
|
|
void runtime_diag_record_error(const char *source, esp_err_t code, const char *message);
|
|
void runtime_diag_get_snapshot(runtime_diag_snapshot_t *out_snapshot);
|
|
|
|
const char *runtime_diag_counter_name(runtime_diag_counter_t counter);
|
|
const char *runtime_diag_gauge_name(runtime_diag_gauge_t gauge);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|