feat: implement Wi-Fi provisioning and persistent configuration
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#ifndef MAZE32_CONFIG_STORE_H
|
||||
#define MAZE32_CONFIG_STORE_H
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "maze32_wifi_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
esp_err_t maze32_config_store_init(void);
|
||||
esp_err_t maze32_config_store_load(maze32_wifi_credentials_t *credentials);
|
||||
esp_err_t maze32_config_store_save(const maze32_wifi_credentials_t *credentials);
|
||||
esp_err_t maze32_config_store_clear(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef MAZE32_WIFI_CONFIG_H
|
||||
#define MAZE32_WIFI_CONFIG_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAZE32_WIFI_CONFIG_SCHEMA_VERSION 1U
|
||||
#define MAZE32_WIFI_SSID_MAX_BYTES 32U
|
||||
#define MAZE32_WIFI_PASSWORD_MAX_BYTES 63U
|
||||
|
||||
typedef struct {
|
||||
char ssid[MAZE32_WIFI_SSID_MAX_BYTES + 1U];
|
||||
char password[MAZE32_WIFI_PASSWORD_MAX_BYTES + 1U];
|
||||
} maze32_wifi_credentials_t;
|
||||
|
||||
typedef enum {
|
||||
MAZE32_WIFI_CONFIG_VALID = 0,
|
||||
MAZE32_WIFI_CONFIG_INVALID_SSID,
|
||||
MAZE32_WIFI_CONFIG_INVALID_PASSWORD,
|
||||
} maze32_wifi_config_validation_t;
|
||||
|
||||
typedef int (*maze32_reconfiguration_guard_fn)(void *context);
|
||||
typedef int (*maze32_credentials_save_fn)(const maze32_wifi_credentials_t *credentials,
|
||||
void *context);
|
||||
typedef int (*maze32_credentials_clear_fn)(void *context);
|
||||
|
||||
maze32_wifi_config_validation_t maze32_wifi_credentials_validate(
|
||||
const maze32_wifi_credentials_t *credentials);
|
||||
int maze32_wifi_config_apply(const maze32_wifi_credentials_t *credentials,
|
||||
maze32_reconfiguration_guard_fn guard,
|
||||
maze32_credentials_save_fn save,
|
||||
void *context);
|
||||
int maze32_wifi_config_reset(maze32_reconfiguration_guard_fn guard,
|
||||
maze32_credentials_clear_fn clear,
|
||||
void *context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user