54 lines
1.5 KiB
C
54 lines
1.5 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include "repeater.h"
|
|
|
|
typedef struct {
|
|
uint32_t revision;
|
|
uint32_t applied_revision;
|
|
repeater_cfg_t values;
|
|
} settings_snapshot_t;
|
|
|
|
typedef enum {
|
|
SETTINGS_REPEAT_DELAY_MS,
|
|
SETTINGS_TX_POWER,
|
|
SETTINGS_REPEAT_ENABLED,
|
|
SETTINGS_VERBOSE,
|
|
SETTINGS_FEM_RX_CSD,
|
|
SETTINGS_PREAMBLE_BITS,
|
|
SETTINGS_DUTY_BUDGET_PPM,
|
|
SETTINGS_TEST_LFIELD,
|
|
SETTINGS_WHITELIST,
|
|
SETTINGS_BEACON_PERIOD_MS,
|
|
} settings_key_t;
|
|
|
|
typedef struct {
|
|
settings_key_t key;
|
|
int32_t value;
|
|
uint32_t whitelist[8];
|
|
uint8_t whitelist_len;
|
|
} settings_change_t;
|
|
|
|
typedef enum {
|
|
SETTINGS_OK,
|
|
SETTINGS_INVALID,
|
|
SETTINGS_CONFLICT,
|
|
SETTINGS_STORAGE_ERROR,
|
|
SETTINGS_BUSY,
|
|
} settings_result_t;
|
|
|
|
// Boot only, after cfg_store_init and before starting any consumer tasks.
|
|
// Restores the two persisted keys after range validation, keeping defaults otherwise.
|
|
void settings_init(void);
|
|
void settings_get_snapshot(settings_snapshot_t *out);
|
|
// expected_revision == 0 is unconditional (local console); network callers use >= 1.
|
|
// On failure the accepted values and revision are unchanged; out may be NULL.
|
|
settings_result_t settings_update(const settings_change_t *change,
|
|
uint32_t expected_revision,
|
|
settings_snapshot_t *out);
|
|
|
|
// Radio owner only, at an RX/processing loop boundary. Never waits on NVS or a mutex.
|
|
bool settings_radio_pending(void);
|
|
bool settings_radio_apply(repeater_cfg_t *active);
|