Prepare for LAN adapter settings

* Fix radio pin settings where the old values were being set to the config then reloaded.  This meant that the new pin settings were not being saved.
* Disable the radio when the radio cannot be configured.  This stops the microcontroller from hitting a hard halt and allows the pin settings to be changed.
* Add ethernet configuration options in preparation for boards with ethernet connections.
This commit is contained in:
Robert Strouse 2023-02-23 17:41:58 -08:00
parent 028cce5d8f
commit 7f5463250f
10 changed files with 255 additions and 57 deletions

View file

@ -2,7 +2,7 @@
#ifndef configsettings_h
#define configsettings_h
#define FW_VERSION "v1.2.2"
#define FW_VERSION "v1.2.3"
enum DeviceStatus {
DS_OK = 0,
DS_ERROR = 1,
@ -14,6 +14,7 @@ class BaseSettings {
bool loadFile(const char* filename);
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
bool parseIPAddress(JsonObject &obj, const char *prop, IPAddress *);
bool parseValueString(JsonObject &obj, const char *prop, char *dest, size_t size);
int parseValueInt(JsonObject &obj, const char *prop, int defVal);
double parseValueDouble(JsonObject &obj, const char *prop, double defVal);
@ -36,11 +37,10 @@ class NTPSettings: BaseSettings {
class WifiSettings: BaseSettings {
public:
WifiSettings();
char serverId[10] = "";
char hostname[32] = "ESPSomfyRTS";
// char hostname[32] = "ESPSomfyRTS";
char ssid[64] = "";
char passphrase[32] = "";
bool ssdpBroadcast = true;
//bool ssdpBroadcast = true;
bool begin();
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
@ -51,6 +51,21 @@ class WifiSettings: BaseSettings {
bool load();
void print();
};
class EthernetSettings: BaseSettings {
public:
EthernetSettings();
IPAddress subnet = IPAddress(255,255,255,0);
IPAddress gateway;
IPAddress dns1;
IPAddress dns2;
bool begin();
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
bool load();
bool save();
void print();
};
class MQTTSettings: BaseSettings {
public:
bool enabled = false;
@ -66,13 +81,26 @@ class MQTTSettings: BaseSettings {
bool toJSON(JsonObject &obj);
bool fromJSON(JsonObject &obj);
};
enum class conn_types : byte {
unset = 0x00,
wifi = 0x1,
ethernet = 0x2
};
class ConfigSettings: BaseSettings {
public:
char serverId[10] = "";
char hostname[32] = "ESPSomfyRTS";
conn_types connType = conn_types::wifi;
const char* fwVersion = FW_VERSION;
bool ssdpBroadcast = true;
uint8_t status;
WifiSettings WIFI;
EthernetSettings Ethernet;
NTPSettings NTP;
MQTTSettings MQTT;
bool fromJSON(JsonObject &obj);
bool toJSON(JsonObject &obj);
bool begin();
bool save();
bool load();