Some cleanup, halfway of EEPROM config saving for ESP8266 (required updated aJson lib)

This commit is contained in:
2019-03-23 19:11:09 +03:00
parent 2947a1e53c
commit 6fa661690b
5 changed files with 40 additions and 36 deletions

View File

@@ -129,9 +129,9 @@ class Item
//void setVal(uint8_t n, int par); //void setVal(uint8_t n, int par);
void setVal(long int par); void setVal(long int par);
//void copyPar (aJsonObject *itemV); //void copyPar (aJsonObject *itemV);
inline int On (){Ctrl(CMD_ON);}; inline int On (){return Ctrl(CMD_ON);};
inline int Off(){Ctrl(CMD_OFF);}; inline int Off(){return Ctrl(CMD_OFF);};
inline int Toggle(){Ctrl(CMD_TOGGLE);}; inline int Toggle(){return Ctrl(CMD_TOGGLE);};
int Poll(); int Poll();
int SendStatus(short cmd, short n=0, int * Par=NULL, boolean deferred = false); int SendStatus(short cmd, short n=0, int * Par=NULL, boolean deferred = false);

View File

@@ -87,17 +87,6 @@ NRFFlashStorage EEPROM;
#endif #endif
#ifdef ARDUINO_ARCH_STM32 #ifdef ARDUINO_ARCH_STM32
#include "HttpClient.h"
//#include <EthernetClient.h>
#include "UIPEthernet.h"
//#include "UIPUdp.h"
//#include <SPI.h>
//#include <Ethernet_STM.h>
#include "Dns.h"
//#include "utility/logging.h"
#include <EEPROM.h>
EthernetClient ethClient; EthernetClient ethClient;
#endif #endif
@@ -964,6 +953,7 @@ int mqttConfigRequest(int arg_cnt, char **args)
strncat(buf, "/req/conf", 25); strncat(buf, "/req/conf", 25);
debugSerial<<buf; debugSerial<<buf;
mqttClient.publish(buf, "1"); mqttClient.publish(buf, "1");
return 1;
} }
@@ -1277,6 +1267,10 @@ void setup_main() {
sd_card_w5100_setup(); sd_card_w5100_setup();
#endif #endif
setupMacAddress(); setupMacAddress();
#if defined(ARDUINO_ARCH_ESP8266)
EEPROM.begin(ESP_EEPROM_SIZE);
#endif
loadConfigFromEEPROM(); loadConfigFromEEPROM();
#ifdef _modbus #ifdef _modbus

View File

@@ -16,7 +16,7 @@
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
#include <FS.h> //this needs to be first, or it all crashes and burns... #include <FS.h> //this needs to be first, or it all crashes and burns...
#include <EEPROM.h> #include <ESP_EEPROM.h>
#include <ESP8266HTTPClient.h> #include <ESP8266HTTPClient.h>
#include <WiFiManager.h> #include <WiFiManager.h>
#include <DNSServer.h> #include <DNSServer.h>
@@ -45,14 +45,14 @@
#include <NRFFlashStorage.h> #include <NRFFlashStorage.h>
#endif #endif
#if defined(__SAM3X8E__) #ifdef ARDUINO_ARCH_STM32
#define wdt_res() watchdogReset() #include "HttpClient.h"
#define wdt_en() #include "UIPEthernet.h"
#define wdt_dis() #include <EEPROM.h>
#endif #endif
#if defined(ARDUINO_ARCH_STM32F1) #if defined(__SAM3X8E__)
#define wdt_res() #define wdt_res() watchdogReset()
#define wdt_en() #define wdt_en()
#define wdt_dis() #define wdt_dis()
#endif #endif

View File

@@ -4,6 +4,7 @@
#endif #endif
#define TXEnablePin 13 #define TXEnablePin 13
#define ESP_EEPROM_SIZE 4096
#ifndef AVR_DMXOUT_PIN #ifndef AVR_DMXOUT_PIN
#define AVR_DMXOUT_PIN 3 #define AVR_DMXOUT_PIN 3

View File

@@ -25,7 +25,7 @@ src_dir = lighthub
;build_dir = /tmp/pioenvs ;build_dir = /tmp/pioenvs
;libdeps_dir = /tmp/piolibdeps ;libdeps_dir = /tmp/piolibdeps
[env:nrf52840_dk] [env:nrf52840]
platform = nordicnrf52 platform = nordicnrf52
board = nrf52840_dk board = nrf52840_dk
;upload_protocol = mbed ;upload_protocol = mbed
@@ -33,6 +33,7 @@ board = nrf52840_dk
framework = arduino framework = arduino
build_flags = !bash check_custom_build_flags_nrf52840.sh build_flags = !bash check_custom_build_flags_nrf52840.sh
lib_ignore = lib_ignore =
ESP_EEPROM
DmxSimple DmxSimple
DMXSerial DMXSerial
DmxDue DmxDue
@@ -45,6 +46,7 @@ lib_ignore =
httpClient httpClient
FastLED FastLED
ESPDMX ESPDMX
ESP-Dmx
DueFlashStorage DueFlashStorage
PrintEx PrintEx
;DHT sensor library ;DHT sensor library
@@ -56,7 +58,7 @@ lib_ignore =
lib_deps = lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
Ethernet2 https://github.com/anklimov/Ethernet2
ESP8266HTTPClient ESP8266HTTPClient
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
@@ -65,7 +67,6 @@ lib_deps =
; https://github.com/anklimov/Artnet.git ; https://github.com/anklimov/Artnet.git
; FastLED ; FastLED
Adafruit Unified Sensor Adafruit Unified Sensor
; DHT sensor library for ESPx
DHT sensor library DHT sensor library
Streaming Streaming
https://github.com/anklimov/NRFFlashStorage https://github.com/anklimov/NRFFlashStorage
@@ -109,17 +110,16 @@ lib_ignore =
DHT sensor library DHT sensor library
Wire Wire
UIPEthernet UIPEthernet
;WifiManager ESP_EEPROM
;HTTPClient
;HttpClient
lib_deps = lib_deps =
https://github.com/ebenolson/WIFIMANAGER-ESP32.git https://github.com/ebenolson/WIFIMANAGER-ESP32.git
https://github.com/zhouhan0126/WebServer-esp32.git https://github.com/zhouhan0126/WebServer-esp32.git
https://github.com/arduino-libraries/ArduinoHttpClient.git ArduinoHttpClient
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
Streaming Streaming
;ESP_EEPROM
https://github.com/anklimov/NRFFlashStorage https://github.com/anklimov/NRFFlashStorage
[env:due] [env:due]
platform = atmelsam platform = atmelsam
@@ -128,10 +128,12 @@ board = due
build_flags = !bash check_custom_build_flags_due.sh build_flags = !bash check_custom_build_flags_due.sh
lib_ignore = lib_ignore =
DHT sensor library for ESPx DHT sensor library for ESPx
ESP_EEPROM
DMXSerial DMXSerial
DmxSimple DmxSimple
httpClient httpClient
ESPDMX ESPDMX
ESP-Dmx
WifiManager WifiManager
Ethernet3 Ethernet3
NRFFlashStorage NRFFlashStorage
@@ -142,7 +144,7 @@ lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxDue https://github.com/anklimov/DmxDue
https://github.com/anklimov/ArduinoHttpClient ArduinoHttpClient
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
@@ -174,6 +176,7 @@ lib_ignore =
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
ESP_EEPROM
lib_deps = lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
@@ -187,7 +190,7 @@ lib_deps =
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git https://github.com/anklimov/Artnet.git
FastLED FastLED
EEPROM ;EEPROM
Adafruit Unified Sensor Adafruit Unified Sensor
DHT sensor library DHT sensor library
https://github.com/arcao/Syslog.git https://github.com/arcao/Syslog.git
@@ -230,6 +233,7 @@ lib_deps =
WifiManager WifiManager
https://github.com/arcao/Syslog.git https://github.com/arcao/Syslog.git
Streaming Streaming
ESP_EEPROM
[env:megaatmega2560-net] [env:megaatmega2560-net]
platform = atmelavr platform = atmelavr
@@ -241,6 +245,7 @@ lib_ignore =
DHT sensor library for ESPx DHT sensor library for ESPx
DmxDue DmxDue
DueFlashStorage DueFlashStorage
ESPDMX
ESP-Dmx ESP-Dmx
WifiManager WifiManager
Ethernet3 Ethernet3
@@ -248,6 +253,7 @@ lib_ignore =
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
ESP_EEPROM
lib_deps = lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
@@ -273,10 +279,9 @@ board = due
build_flags = !bash check_custom_build_flags_due-5500.sh build_flags = !bash check_custom_build_flags_due-5500.sh
lib_ignore = lib_ignore =
DHT sensor library for ESPx DHT sensor library for ESPx
https://github.com/anklimov/Ethernet ESPDMX
ESP-Dmx ESP-Dmx
DMXSerial DMXSerial
ESPDMX
WifiManager WifiManager
DmxSimple DmxSimple
httpClient httpClient
@@ -285,12 +290,13 @@ lib_ignore =
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
ESP_EEPROM
lib_deps = lib_deps =
https://github.com/sebnil/DueFlashStorage https://github.com/sebnil/DueFlashStorage
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/DmxDue https://github.com/anklimov/DmxDue
https://github.com/anklimov/ArduinoHttpClient ArduinoHttpClient
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
@@ -315,6 +321,7 @@ lib_ignore =
DHT sensor library for ESPx DHT sensor library for ESPx
DmxDue DmxDue
DueFlashStorage DueFlashStorage
ESPDMX
ESP-Dmx ESP-Dmx
WifiManager WifiManager
Ethernet3 Ethernet3
@@ -322,6 +329,7 @@ lib_ignore =
NRFFlashStorage NRFFlashStorage
WebServer WebServer
UIPEthernet UIPEthernet
ESP_EEPROM
lib_deps = lib_deps =
https://github.com/anklimov/Arduino-Temperature-Control-Library.git https://github.com/anklimov/Arduino-Temperature-Control-Library.git
https://github.com/anklimov/DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
@@ -335,7 +343,7 @@ lib_deps =
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
https://github.com/anklimov/Artnet.git https://github.com/anklimov/Artnet.git
FastLED FastLED
EEPROM ;EEPROM
Adafruit Unified Sensor Adafruit Unified Sensor
DHT sensor library DHT sensor library
Streaming Streaming
@@ -352,11 +360,11 @@ lib_ignore =
DHT sensor library for ESPx DHT sensor library for ESPx
DmxDue DmxDue
DueFlashStorage DueFlashStorage
ESPDMX
ESP-Dmx ESP-Dmx
WifiManager WifiManager
FastLED FastLED
Ethernet Ethernet
https://github.com/anklimov/Ethernet
DMXSerial DMXSerial
DmxSimple DmxSimple
httpClient httpClient
@@ -367,6 +375,7 @@ lib_ignore =
Ethernet3 Ethernet3
NRFFlashStorage NRFFlashStorage
WebServer WebServer
ESP_EEPROM
lib_deps = lib_deps =
; DallasTemperature ; DallasTemperature
@@ -378,4 +387,4 @@ lib_deps =
DHT sensor library DHT sensor library
Streaming Streaming
UIPEthernet UIPEthernet
EEPROM ;EEPROM