80 lines
2.1 KiB
C
80 lines
2.1 KiB
C
#ifndef CONFIG_MANAGER_H
|
|
#define CONFIG_MANAGER_H
|
|
|
|
#include "esp_err.h"
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// WiFi AP Configuration
|
|
typedef struct {
|
|
char ssid[32];
|
|
char password[64];
|
|
uint8_t channel;
|
|
uint8_t max_connections;
|
|
char ip[16];
|
|
char gateway[16];
|
|
char netmask[16];
|
|
} custom_wifi_ap_config_t;
|
|
|
|
// Ethernet Configuration
|
|
typedef struct {
|
|
bool dhcp_enabled;
|
|
char static_ip[16];
|
|
char gateway[16];
|
|
char netmask[16];
|
|
char dns[16];
|
|
} ethernet_config_t;
|
|
|
|
// Web Server Configuration
|
|
typedef struct {
|
|
uint16_t port;
|
|
bool auth_enabled;
|
|
char username[32];
|
|
char password[64];
|
|
} web_server_config_t;
|
|
|
|
// Scanner Configuration
|
|
typedef struct {
|
|
uint32_t arp_timeout_ms;
|
|
uint32_t ping_timeout_ms;
|
|
uint32_t port_scan_timeout_ms;
|
|
uint16_t max_ports_per_scan;
|
|
uint32_t scan_interval_ms;
|
|
} scanner_config_t;
|
|
|
|
// Main Configuration Structure
|
|
typedef struct {
|
|
custom_wifi_ap_config_t wifi_ap;
|
|
ethernet_config_t ethernet;
|
|
web_server_config_t web_server;
|
|
scanner_config_t scanner;
|
|
} config_t;
|
|
|
|
// Function prototypes
|
|
esp_err_t config_manager_init(void);
|
|
esp_err_t config_manager_load(void);
|
|
esp_err_t config_manager_save(void);
|
|
const config_t* config_manager_get_config(void);
|
|
|
|
esp_err_t config_manager_update_wifi_ap(const custom_wifi_ap_config_t *config);
|
|
esp_err_t config_manager_update_ethernet(const ethernet_config_t *config);
|
|
esp_err_t config_manager_update_web_server(const web_server_config_t *config);
|
|
esp_err_t config_manager_update_scanner(const scanner_config_t *config);
|
|
|
|
esp_err_t config_manager_reset_to_defaults(void);
|
|
|
|
// Password management functions
|
|
esp_err_t config_manager_is_first_boot(bool* is_first_boot);
|
|
esp_err_t config_manager_change_password(const char* username, const char* old_password,
|
|
const char* new_password, bool* success);
|
|
esp_err_t config_manager_change_wifi_password(const char* new_password, bool* success);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // CONFIG_MANAGER_H
|