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(long int par);
//void copyPar (aJsonObject *itemV);
inline int On (){Ctrl(CMD_ON);};
inline int Off(){Ctrl(CMD_OFF);};
inline int Toggle(){Ctrl(CMD_TOGGLE);};
inline int On (){return Ctrl(CMD_ON);};
inline int Off(){return Ctrl(CMD_OFF);};
inline int Toggle(){return Ctrl(CMD_TOGGLE);};
int Poll();
int SendStatus(short cmd, short n=0, int * Par=NULL, boolean deferred = false);

View File

@@ -87,17 +87,6 @@ NRFFlashStorage EEPROM;
#endif
#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;
#endif
@@ -964,6 +953,7 @@ int mqttConfigRequest(int arg_cnt, char **args)
strncat(buf, "/req/conf", 25);
debugSerial<<buf;
mqttClient.publish(buf, "1");
return 1;
}
@@ -1277,6 +1267,10 @@ void setup_main() {
sd_card_w5100_setup();
#endif
setupMacAddress();
#if defined(ARDUINO_ARCH_ESP8266)
EEPROM.begin(ESP_EEPROM_SIZE);
#endif
loadConfigFromEEPROM();
#ifdef _modbus

View File

@@ -16,7 +16,7 @@
#if defined(ARDUINO_ARCH_ESP8266)
#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 <WiFiManager.h>
#include <DNSServer.h>
@@ -45,14 +45,14 @@
#include <NRFFlashStorage.h>
#endif
#if defined(__SAM3X8E__)
#define wdt_res() watchdogReset()
#define wdt_en()
#define wdt_dis()
#ifdef ARDUINO_ARCH_STM32
#include "HttpClient.h"
#include "UIPEthernet.h"
#include <EEPROM.h>
#endif
#if defined(ARDUINO_ARCH_STM32F1)
#define wdt_res()
#if defined(__SAM3X8E__)
#define wdt_res() watchdogReset()
#define wdt_en()
#define wdt_dis()
#endif

View File

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

View File

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