|
IoT25S IoT Klocka 0.1
Grupparbete för IoT25S på Jensen YH
|
Thread-safe application state and persisted configuration APIs. More...
#include <stdbool.h>#include <stdint.h>#include "esp_err.h"
Include dependency graph for app_state.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | alarm_entry_t |
| Single alarm entry. More... | |
| struct | app_config_t |
| Persisted configuration model. More... | |
| struct | app_runtime_t |
| Runtime state model. More... | |
| struct | app_state_snapshot_t |
| Snapshot of full app state. More... | |
Macros | |
| #define | APP_WIFI_SSID_MAX_LEN 32 |
| Maximum Wi-Fi SSID length (without null terminator). | |
| #define | APP_WIFI_PASSWORD_MAX_LEN 64 |
| Maximum Wi-Fi password length (without null terminator). | |
| #define | APP_AP_SSID_MAX_LEN 32 |
| Maximum provisioning AP SSID length (without null terminator). | |
| #define | APP_AP_PASSWORD_MAX_LEN 16 |
| Maximum provisioning AP password length (without null terminator). | |
| #define | APP_TIMEZONE_LOCATION_MAX_LEN 32 |
| Maximum timezone location identifier length (without null terminator). | |
| #define | APP_IP_ADDRESS_MAX_LEN 16 |
| Maximum IPv4 address string length including null terminator. | |
| #define | APP_ALARM_MAX_COUNT 8 |
| Maximum number of configurable alarms. | |
Functions | |
| esp_err_t | app_state_init (void) |
| Initialize state, defaults, and NVS-backed values. | |
| void | app_state_get_snapshot (app_state_snapshot_t *snapshot) |
| Get a thread-safe snapshot of the full state. | |
| void | app_state_get_config (app_config_t *config) |
| Get current persisted configuration. | |
| esp_err_t | app_state_update_config (const app_config_t *config) |
| Replace persisted configuration with provided values. | |
| void | app_state_get_time_epoch (int64_t *epoch, bool *valid) |
| Get stored epoch value and validity flag. | |
| esp_err_t | app_state_set_time_epoch (int64_t epoch, bool valid) |
| Update stored epoch and validity flag. | |
| void | app_state_set_portal_mode (bool portal_mode) |
| Update runtime portal mode flag. | |
| void | app_state_set_wifi_connected (bool connected, const char *ip_address) |
| Update runtime Wi-Fi status and optional station IP. | |
| void | app_state_set_alarm_active (bool active) |
| Update runtime alarm active flag. | |
| esp_err_t | app_state_reset_wifi_credentials (void) |
| Clear persisted Wi-Fi credentials. | |
| void | app_state_get_alarms (alarm_entry_t *out, uint8_t *count) |
| Get current alarm list. | |
| esp_err_t | app_state_add_alarm (uint8_t hour, uint8_t minute, bool enabled) |
| Add a new alarm. | |
| esp_err_t | app_state_update_alarm (uint8_t index, uint8_t hour, uint8_t minute, bool enabled) |
| Replace an existing alarm entry by index. | |
| esp_err_t | app_state_delete_alarm (uint8_t index) |
| Delete an alarm by index (subsequent alarms shift down). | |
| esp_err_t | app_state_toggle_alarm (uint8_t index) |
| Toggle the enabled flag of an alarm by index. | |
Thread-safe application state and persisted configuration APIs.
Definition in file app_state.h.
| #define APP_ALARM_MAX_COUNT 8 |
Maximum number of configurable alarms.
Definition at line 26 of file app_state.h.
| #define APP_AP_PASSWORD_MAX_LEN 16 |
Maximum provisioning AP password length (without null terminator).
Definition at line 20 of file app_state.h.
| #define APP_AP_SSID_MAX_LEN 32 |
Maximum provisioning AP SSID length (without null terminator).
Definition at line 18 of file app_state.h.
| #define APP_IP_ADDRESS_MAX_LEN 16 |
Maximum IPv4 address string length including null terminator.
Definition at line 24 of file app_state.h.
| #define APP_TIMEZONE_LOCATION_MAX_LEN 32 |
Maximum timezone location identifier length (without null terminator).
Definition at line 22 of file app_state.h.
| #define APP_WIFI_PASSWORD_MAX_LEN 64 |
Maximum Wi-Fi password length (without null terminator).
Definition at line 16 of file app_state.h.
| #define APP_WIFI_SSID_MAX_LEN 32 |
Maximum Wi-Fi SSID length (without null terminator).
Definition at line 14 of file app_state.h.
| esp_err_t app_state_add_alarm | ( | uint8_t | hour, |
| uint8_t | minute, | ||
| bool | enabled | ||
| ) |
Add a new alarm.
Fails if APP_ALARM_MAX_COUNT is already reached.
Definition at line 304 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| esp_err_t app_state_delete_alarm | ( | uint8_t | index | ) |
Delete an alarm by index (subsequent alarms shift down).
Definition at line 338 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void app_state_get_alarms | ( | alarm_entry_t * | out, |
| uint8_t * | count | ||
| ) |
Get current alarm list.
| [out] | out | Buffer of at least APP_ALARM_MAX_COUNT entries. |
| [out] | count | Number of configured alarms. |
Definition at line 296 of file app_state.c.
Here is the caller graph for this function:| void app_state_get_config | ( | app_config_t * | config | ) |
Get current persisted configuration.
| [out] | config | Destination configuration buffer. |
Definition at line 214 of file app_state.c.
Here is the caller graph for this function:| void app_state_get_snapshot | ( | app_state_snapshot_t * | snapshot | ) |
Get a thread-safe snapshot of the full state.
| [out] | snapshot | Destination snapshot buffer. |
Definition at line 207 of file app_state.c.
Here is the caller graph for this function:| void app_state_get_time_epoch | ( | int64_t * | epoch, |
| bool * | valid | ||
| ) |
Get stored epoch value and validity flag.
| [out] | epoch | Stored epoch seconds. |
| [out] | valid | Stored validity state. |
Definition at line 234 of file app_state.c.
Here is the caller graph for this function:| esp_err_t app_state_init | ( | void | ) |
Initialize state, defaults, and NVS-backed values.
Definition at line 123 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| esp_err_t app_state_reset_wifi_credentials | ( | void | ) |
Clear persisted Wi-Fi credentials.
Definition at line 282 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void app_state_set_alarm_active | ( | bool | active | ) |
Update runtime alarm active flag.
| active | true when alarm is active. |
Definition at line 275 of file app_state.c.
Here is the caller graph for this function:| void app_state_set_portal_mode | ( | bool | portal_mode | ) |
Update runtime portal mode flag.
| portal_mode | true for provisioning AP mode, false otherwise. |
Definition at line 256 of file app_state.c.
Here is the caller graph for this function:| esp_err_t app_state_set_time_epoch | ( | int64_t | epoch, |
| bool | valid | ||
| ) |
Update stored epoch and validity flag.
| epoch | Epoch seconds to store. |
| valid | Validity flag to store. |
Definition at line 242 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void app_state_set_wifi_connected | ( | bool | connected, |
| const char * | ip_address | ||
| ) |
Update runtime Wi-Fi status and optional station IP.
| connected | true if connected. |
| ip_address | Optional station IP string when connected. |
Definition at line 263 of file app_state.c.
Here is the caller graph for this function:| esp_err_t app_state_toggle_alarm | ( | uint8_t | index | ) |
Toggle the enabled flag of an alarm by index.
Definition at line 356 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| esp_err_t app_state_update_alarm | ( | uint8_t | index, |
| uint8_t | hour, | ||
| uint8_t | minute, | ||
| bool | enabled | ||
| ) |
Replace an existing alarm entry by index.
Definition at line 322 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function:| esp_err_t app_state_update_config | ( | const app_config_t * | config | ) |
Replace persisted configuration with provided values.
| config | Source configuration. |
Definition at line 221 of file app_state.c.
Here is the call graph for this function:
Here is the caller graph for this function: