2017-06-01 23:04:48 +00:00
|
|
|
#ifndef _CONFIG_FLASH_H_
|
|
|
|
#define _CONFIG_FLASH_H_
|
|
|
|
|
|
|
|
#include "c_types.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "ets_sys.h"
|
|
|
|
#include "osapi.h"
|
|
|
|
#include "gpio.h"
|
|
|
|
#include "os_type.h"
|
|
|
|
#include "spi_flash.h"
|
|
|
|
|
|
|
|
#include "user_config.h"
|
|
|
|
|
|
|
|
#define FLASH_BLOCK_NO 0xc
|
|
|
|
|
2017-08-16 09:04:31 +00:00
|
|
|
#define MAGIC_NUMBER 0x015005fd
|
2017-06-01 23:04:48 +00:00
|
|
|
|
2017-11-30 20:54:38 +00:00
|
|
|
#define SYSTEM_OUTPUT_INFO 2
|
|
|
|
#define SYSTEM_OUTPUT_CMD 1
|
|
|
|
#define SYSTEM_OUTPUT_NONE 0
|
|
|
|
|
2018-02-11 09:09:03 +00:00
|
|
|
#define MQTT_PORT 1883
|
|
|
|
|
2017-06-01 23:04:48 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
// To check if the structure is initialized or not in flash
|
|
|
|
uint32_t magic_number;
|
|
|
|
|
|
|
|
// Length of the structure, since this is a evolving library, the variant may change
|
|
|
|
// hence used for verification
|
|
|
|
uint16_t length;
|
|
|
|
|
|
|
|
/* Below variables are specific to my code */
|
|
|
|
uint8_t ssid[32]; // SSID of the AP to connect to
|
|
|
|
uint8_t password[64]; // Password of the network
|
|
|
|
uint8_t auto_connect; // Should we auto connect
|
|
|
|
|
|
|
|
uint8_t ap_ssid[32]; // SSID of the own AP
|
|
|
|
uint8_t ap_password[64]; // Password of the own network
|
|
|
|
uint8_t ap_open; // Should we use no WPA?
|
|
|
|
uint8_t ap_on; // AP enabled?
|
|
|
|
|
|
|
|
uint8_t locked; // Should we allow for config changes
|
2017-07-21 14:35:45 +00:00
|
|
|
uint8_t lock_password[32]; // Password of config lock
|
2017-06-01 23:04:48 +00:00
|
|
|
ip_addr_t network_addr; // Address of the internal network
|
|
|
|
ip_addr_t dns_addr; // Optional: address of the dns server
|
|
|
|
|
|
|
|
ip_addr_t my_addr; // Optional (if not DHCP): IP address of the uplink side
|
|
|
|
ip_addr_t my_netmask; // Optional (if not DHCP): IP netmask of the uplink side
|
|
|
|
ip_addr_t my_gw; // Optional (if not DHCP): Gateway of the uplink side
|
|
|
|
|
2017-08-21 07:37:28 +00:00
|
|
|
uint8_t mdns_mode; // Selects, which interface should be announced via mDNS (default: none)
|
|
|
|
|
2017-06-01 23:04:48 +00:00
|
|
|
uint16_t clock_speed; // Freq of the CPU
|
|
|
|
uint16_t config_port; // Port on which the concole listenes (0 if no access)
|
2017-08-16 12:00:51 +00:00
|
|
|
uint8_t config_access; // Controls the interfaces that allow config access (default LOCAL_ACCESS | REMOTE_ACCESS)
|
2017-06-03 13:44:03 +00:00
|
|
|
|
2017-11-30 07:54:59 +00:00
|
|
|
uint8_t system_output; // Disable system info and warnings
|
|
|
|
uint32_t bit_rate; // Bit rate of serial link
|
|
|
|
|
2018-02-11 09:09:03 +00:00
|
|
|
uint16_t mqtt_broker_port; // Port where the MQTT broker listens (1883 default)
|
2017-11-05 14:36:06 +00:00
|
|
|
uint16_t max_subscriptions; // Upper limit on subscribed topics
|
|
|
|
uint16_t max_retained_messages; // Upper limit on stored retained messages
|
2017-11-08 20:34:36 +00:00
|
|
|
uint16_t max_clients; // Upper limit on concurrently connected clients (0: mem is the limit)
|
2017-10-20 12:50:51 +00:00
|
|
|
uint8_t auto_retained; // Automatically save retained messages to flash (default: off)
|
2017-08-16 09:04:31 +00:00
|
|
|
uint8_t mqtt_broker_user[32]; // Username for client login, "none" if empty
|
|
|
|
uint8_t mqtt_broker_password[32]; // Password for client login
|
2017-08-21 12:27:07 +00:00
|
|
|
uint8_t mqtt_broker_access; // Controls the interfaces that allow MQTT access (default LOCAL_ACCESS | REMOTE_ACCESS)
|
2017-08-16 09:04:31 +00:00
|
|
|
|
2017-06-03 13:44:03 +00:00
|
|
|
#ifdef MQTT_CLIENT
|
|
|
|
uint8_t mqtt_host[32]; // IP or hostname of the MQTT broker, "none" if empty
|
|
|
|
uint16_t mqtt_port; // Port of the MQTT broker
|
2017-10-20 12:50:51 +00:00
|
|
|
uint8_t mqtt_ssl; // Use SSL (default: no)
|
2017-06-03 13:44:03 +00:00
|
|
|
|
|
|
|
uint8_t mqtt_user[32]; // Username for broker login, "none" if empty
|
|
|
|
uint8_t mqtt_password[32]; // Password for broker login
|
|
|
|
uint8_t mqtt_id[32]; // MQTT clientId
|
|
|
|
#endif
|
2017-07-12 20:04:02 +00:00
|
|
|
#ifdef NTP
|
|
|
|
uint8_t ntp_server[32]; // IP or hostname of the MQTT broker, "none" if empty
|
|
|
|
uint32_t ntp_interval; // Sync interval in usec
|
|
|
|
int16_t ntp_timezone; // Timezone (hour offset to GMT)
|
|
|
|
#endif
|
2018-06-22 10:51:04 +00:00
|
|
|
#ifdef DNS_RESP
|
|
|
|
uint8_t broker_dns_name[32]; // DNS name of the MQTT broker in the SoftAP network, "none" if empty
|
|
|
|
#endif
|
2017-09-28 23:46:42 +00:00
|
|
|
#ifdef GPIO
|
|
|
|
#ifdef GPIO_PWM
|
|
|
|
uint32_t pwm_period; // PWM period
|
|
|
|
#endif
|
|
|
|
#endif
|
2017-06-01 23:04:48 +00:00
|
|
|
} sysconfig_t, *sysconfig_p;
|
|
|
|
|
2017-09-28 23:46:42 +00:00
|
|
|
// The global config
|
|
|
|
extern sysconfig_t config;
|
|
|
|
|
2017-06-01 23:04:48 +00:00
|
|
|
int config_load(sysconfig_p config);
|
|
|
|
void config_save(sysconfig_p config);
|
|
|
|
|
|
|
|
void blob_save(uint8_t blob_no, uint32_t *data, uint16_t len);
|
|
|
|
void blob_load(uint8_t blob_no, uint32_t *data, uint16_t len);
|
|
|
|
void blob_zero(uint8_t blob_no, uint16_t len);
|
|
|
|
|
|
|
|
#endif
|