forked from electro/esp-irblaster
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.1 KiB
98 lines
3.1 KiB
3 years ago
|
//
|
||
|
// Created by MightyPork on 2018/11/18.
|
||
|
//
|
||
|
|
||
|
#ifndef CSPEMU_SETTINGS_H
|
||
|
#define CSPEMU_SETTINGS_H
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <nvs.h>
|
||
|
#include <driver/uart.h>
|
||
|
#include <sdkconfig.h>
|
||
|
|
||
|
#define CONSOLE_TELNET_PORT CONFIG_CONSOLE_TELNET_PORT
|
||
|
#define CONSOLE_PW_LEN CONFIG_CONSOLE_PW_LEN
|
||
|
#define USE_CAPTIVE_PORTAL 0
|
||
|
|
||
|
extern nvs_handle g_nvs_storage;
|
||
|
|
||
|
#define NTP_SRV_LEN 32
|
||
|
#define DEF_NTP_SRV "pool.ntp.org"
|
||
|
|
||
|
/* type , name , suffix , defval , generate load/save funcs
|
||
|
* , , save fn - use 'none' if unused to avoid build errors
|
||
|
* , , , save fn var prefix */
|
||
|
#define SETTINGS_XTABLE() \
|
||
|
X(bool , wifi_enabled , , 1 , true , bool , &) /* ssid and pass are stored in flash by SDK funcs */ \
|
||
|
X(bool , sta_enabled , , 1 , true , bool , &) \
|
||
|
X(bool , ap_enabled , , 0 , true , bool , &) \
|
||
|
X(bool , console_echo , , 1 , true , bool , &) /* Console modes */ \
|
||
|
X(bool , console_ansi , , 1 , true , bool , &) \
|
||
|
X(char , console_pw, [CONSOLE_PW_LEN], "" , false , none , ) \
|
||
|
X(bool , ntp_enable , , 1 , true , bool , &) \
|
||
|
X(char , ntp_srv ,[NTP_SRV_LEN], DEF_NTP_SRV , false, none , ) \
|
||
|
X(bool , dhcp_wd_enable , , 1 , true , bool , &) \
|
||
|
X(bool , dhcp_enable , , 1 , true , bool , &) \
|
||
|
X(uint32_t , static_ip , , 0 , true , u32 , &) \
|
||
|
X(uint32_t , static_ip_mask , , 0x00ffffff , true , u32 , &) /* 255.255.255.0 */ \
|
||
|
X(uint32_t , static_ip_gw , , 0x0100a8c0 , true , u32 , &) /* 192.168.0.1 */ \
|
||
|
X(uint32_t , ap_ip , , 0x0100a8c0 , true , u32 , &) /* 192.168.0.1 */ \
|
||
|
X(uint32_t , static_dns , , 0x08080808 , true , u32 , &) /* 8.8.8.8 */
|
||
|
|
||
|
enum settings_key_enum {
|
||
|
#undef X
|
||
|
#define X(pre,name,post,def,gen_nvs,nvs_format,save_prefix) \
|
||
|
SETTINGS_##name,
|
||
|
|
||
|
SETTINGS_ALL,
|
||
|
SETTINGS_XTABLE() // unfortunately the last bit is lowercase
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Init the NVS namespace
|
||
|
*/
|
||
|
void settings_init(void);
|
||
|
|
||
|
/**
|
||
|
* Load settings from the NVS
|
||
|
*/
|
||
|
void settings_load(void);
|
||
|
|
||
|
/**
|
||
|
* Save the settings object to NVS
|
||
|
*/
|
||
|
void settings_persist(enum settings_key_enum what);
|
||
|
|
||
|
/**
|
||
|
* Load default rtable into the settings struct
|
||
|
* (called when the saved config is rejected by CSP)
|
||
|
*/
|
||
|
void settings_load_default_rtable(void);
|
||
|
|
||
|
/**
|
||
|
* Save the current CSP rtable into the settings object (can then be persisted)
|
||
|
*/
|
||
|
void cspemu_settings_store_rtable(void);
|
||
|
|
||
|
extern struct cspemu_settings g_Settings;
|
||
|
extern struct cspemu_globals g_State;
|
||
|
|
||
|
|
||
|
struct cspemu_globals {
|
||
|
bool wifi_inited;
|
||
|
};
|
||
|
|
||
|
struct cspemu_settings {
|
||
|
#undef X
|
||
|
|
||
|
#define X(pre,name,post,def,gen_nvs,nvs_format,save_prefix) \
|
||
|
pre name post;
|
||
|
|
||
|
SETTINGS_XTABLE()
|
||
|
};
|
||
|
|
||
|
uint16_t app_get_bootcount();
|
||
|
|
||
|
#endif //CSPEMU_SETTINGS_H
|