mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
more persitance all MPU, RESTORE bug fixed
This commit is contained in:
@@ -13,3 +13,4 @@
|
||||
-DCORS=\"http://lazyhome.ru\"
|
||||
-DTIMER_INT
|
||||
|
||||
-DRESTART_LAN_ON_MQTT_ERRORS
|
||||
|
||||
@@ -24,3 +24,5 @@
|
||||
#Default SerialDebug settings
|
||||
#-DSERIAL_BAUD=115200
|
||||
#-DdebugSerialPort=Serial
|
||||
|
||||
-DRESTART_LAN_ON_MQTT_ERRORS
|
||||
@@ -18,6 +18,7 @@
|
||||
#-DWiz5100
|
||||
-DARDUINO_OTA_MDNS_DISABLE
|
||||
#-DMDNS_ENABLE
|
||||
-DRESTART_LAN_ON_MQTT_ERRORS
|
||||
|
||||
# Example of UARTBRIDGE configuration
|
||||
#-DUARTBRIDGE_ENABLE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
2
compiled/due/sendcommand.sh
Executable file
2
compiled/due/sendcommand.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#../tools/mac/arduinoOTA -address 192.168.88.21 -port 65280 -username arduino -password password -sketch firmware.bin -b -upload /sketch
|
||||
curl --basic --user arduino:password --data-ascii "$2" --url http://192.168.88.21:65280/command/$1
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
11220
compiled/nrf52840-5500
11220
compiled/nrf52840-5500
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
bool systemConfig::isValidSysConf()
|
||||
{
|
||||
if (!stream) return false;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,signature));
|
||||
for (int i=0;i<sizeof(systemConfigData::signature);i++)
|
||||
if (stream->read()!=EEPROM_signature[i])
|
||||
@@ -17,6 +18,7 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::getMAC()
|
||||
{
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,mac));
|
||||
|
||||
bool isMacValid = false;
|
||||
@@ -30,16 +32,18 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::setMAC(macAddress& _mac)
|
||||
{
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,mac));
|
||||
stream->write ((const uint8_t *)&_mac,sizeof(_mac));
|
||||
memcpy(mac, _mac, sizeof(mac));
|
||||
|
||||
stream->flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
char * systemConfig::getMQTTpwd(char * buffer, uint16_t bufLen)
|
||||
{
|
||||
if (!stream || !isValidSysConf()) return NULL;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,MQTTpwd));
|
||||
short bytes=stream->readBytesUntil(0,buffer,bufLen-1);
|
||||
if (bytes)
|
||||
@@ -52,16 +56,20 @@ bool systemConfig::isValidSysConf()
|
||||
|
||||
bool systemConfig::setMQTTpwd(char * pwd)
|
||||
{
|
||||
if (!stream || !isValidSysConf() || (strlen(pwd)>=sizeof(systemConfigData::MQTTpwd))) return false;
|
||||
if (!stream || !isValidSysConf() || (strlen(pwd)>=sizeof(systemConfigData::MQTTpwd))) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,MQTTpwd));
|
||||
stream->print(pwd);
|
||||
return stream->write((uint8_t)'\0');
|
||||
stream->print(pwd);
|
||||
int bytes = stream->write((uint8_t)'\0');
|
||||
stream->flush();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
char * systemConfig::getOTApwd(char * buffer, uint16_t bufLen)
|
||||
{
|
||||
if (!stream || !isValidSysConf()) return NULL;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,OTApwd));
|
||||
short bytes=stream->readBytesUntil(0,buffer,bufLen-1);
|
||||
if (bytes)
|
||||
@@ -75,15 +83,19 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::setOTApwd(char * pwd)
|
||||
{
|
||||
if (!stream || !isValidSysConf() || (strlen(pwd)>=sizeof(systemConfigData::OTApwd))) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,OTApwd));
|
||||
stream->print(pwd);
|
||||
return stream->write((uint8_t)'\0');
|
||||
int bytes = stream->write((uint8_t)'\0');
|
||||
stream->flush();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
char * systemConfig::getServer(char * buffer, uint16_t bufLen)
|
||||
{
|
||||
if (!stream || !isValidSysConf()) return NULL;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,configURL));
|
||||
short bytes=stream->readBytesUntil(0,buffer,bufLen-1);
|
||||
if (bytes)
|
||||
@@ -97,9 +109,12 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::setServer(char* url)
|
||||
{
|
||||
if (!stream || !isValidSysConf() || (strlen(url)>=sizeof(systemConfigData::configURL))) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,configURL));
|
||||
stream->print(url);
|
||||
return stream->write((uint8_t)'\0');
|
||||
int bytes = stream->write((uint8_t)'\0');
|
||||
stream->flush();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +122,7 @@ bool systemConfig::isValidSysConf()
|
||||
{
|
||||
uint32_t addr;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,ip));
|
||||
stream->readBytes((uint8_t *) &addr,4);
|
||||
ip=addr;
|
||||
@@ -117,6 +133,7 @@ bool systemConfig::isValidSysConf()
|
||||
{
|
||||
uint32_t addr;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,mask));
|
||||
stream->readBytes((uint8_t *) &addr,4);
|
||||
mask=addr;
|
||||
@@ -126,6 +143,7 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::getDNS(IPAddress& dns)
|
||||
{ uint32_t addr;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,dns));
|
||||
stream->readBytes((uint8_t *) &addr,4);
|
||||
dns = addr;
|
||||
@@ -135,6 +153,7 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::getGW(IPAddress& gw)
|
||||
{ uint32_t addr;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,gw));
|
||||
stream->readBytes((uint8_t *) &addr,4);
|
||||
gw=addr;
|
||||
@@ -145,36 +164,49 @@ bool systemConfig::isValidSysConf()
|
||||
bool systemConfig::setIP(IPAddress& ip)
|
||||
{ uint32_t addr=ip;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->seek(offsetof(systemConfigData,ip));
|
||||
return stream->write((uint8_t *) &addr, 4);
|
||||
stream->open('r');
|
||||
stream->seek(offsetof(systemConfigData,ip));
|
||||
int bytes = stream->write((uint8_t *) &addr, 4);
|
||||
stream->flush();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bool systemConfig::setMask(IPAddress& mask)
|
||||
{ uint32_t addr = mask;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,mask));
|
||||
return stream->write((uint8_t *) &addr, 4);
|
||||
int bytes = stream->write((uint8_t *) &addr, 4);
|
||||
stream->flush();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bool systemConfig::setDNS(IPAddress& dns)
|
||||
{ uint32_t addr = dns;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,dns));
|
||||
return stream->write((uint8_t *) &addr, 4);
|
||||
int bytes = stream->write((uint8_t *) &addr, 4);
|
||||
stream->flush();
|
||||
return bytes;
|
||||
|
||||
}
|
||||
|
||||
bool systemConfig::setGW(IPAddress& gw)
|
||||
{ uint32_t addr = gw;
|
||||
if (!stream || !isValidSysConf()) return false;
|
||||
stream->open('w');
|
||||
stream->seek(offsetof(systemConfigData,gw));
|
||||
return stream->write((uint8_t *) &addr, 4);
|
||||
int bytes = stream->write((uint8_t *) &addr, 4);
|
||||
stream->flush();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
void systemConfig::clear()
|
||||
bool systemConfig::clear()
|
||||
{
|
||||
if (!stream) return ;
|
||||
if (!stream) return false;
|
||||
stream->open('w');
|
||||
stream->seek(0);
|
||||
for (unsigned int i = 0; i < stream->getSize(); i++) {
|
||||
stream->write((uint8_t)'\0');
|
||||
@@ -183,6 +215,7 @@ bool systemConfig::isValidSysConf()
|
||||
for (unsigned int i=0;i<sizeof(systemConfigData::signature);i++)
|
||||
if (stream->write(EEPROM_signature[i]));
|
||||
stream->flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@@ -91,7 +91,7 @@ class systemConfig {
|
||||
uint8_t getSerialDebuglevel();
|
||||
uint8_t getUdpDebuglevel();
|
||||
|
||||
void clear();
|
||||
bool clear();
|
||||
bool getSaveSuccedConfig();
|
||||
bool setSaveSuccedConfig(bool);
|
||||
bool getLoadHTTPConfig();
|
||||
|
||||
@@ -56,18 +56,49 @@ class flashStream : public seekableStream
|
||||
{
|
||||
private:
|
||||
File fs;
|
||||
String filename;
|
||||
char openedMode;
|
||||
|
||||
public:
|
||||
flashStream(String _filename):seekableStream(65535)
|
||||
{
|
||||
fs = SPIFFS.open(_filename, "a+");
|
||||
if (!fs) SPIFFS.open(_filename, "w+");
|
||||
}
|
||||
virtual int available() { return fs.available(); };
|
||||
virtual int read() {return fs.read();};
|
||||
virtual int peek() { return fs.peek();};
|
||||
virtual unsigned int seek(unsigned int _pos = 0){return fs.seek(_pos,SeekSet);};
|
||||
virtual void flush() {return fs.flush();};
|
||||
virtual size_t write(uint8_t ch) {return fs.write(ch);};
|
||||
filename=_filename;
|
||||
openedMode='\0';
|
||||
open('r');
|
||||
}
|
||||
|
||||
int open(char mode='\0')
|
||||
{
|
||||
if (!mode && openedMode) mode=openedMode;
|
||||
if (!mode && !openedMode) mode='r';
|
||||
if (openedMode!=mode)
|
||||
{
|
||||
char modestr[2];
|
||||
modestr[0]=mode;modestr[1]=0;
|
||||
|
||||
unsigned int savedPos=fs.position();
|
||||
if (fs) fs.close();
|
||||
|
||||
if (fs = SPIFFS.open(filename,modestr))
|
||||
{
|
||||
openedMode=mode;
|
||||
fs.seek(savedPos);
|
||||
debugSerial<<("Opened/")<<modestr<<(":")<<filename<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
openedMode='\0';
|
||||
debugSerial<<("Open error/")<<modestr<<(":")<<filename<<endl;
|
||||
}
|
||||
}
|
||||
return fs;
|
||||
}
|
||||
virtual int available() { if (!fs) return 0; return fs.available(); };
|
||||
virtual int read() {open('r');return fs.read();};
|
||||
virtual int peek() {open('r'); return fs.peek();};
|
||||
virtual unsigned int seek(unsigned int _pos = 0){return open();fs.seek(_pos,SeekSet);};
|
||||
virtual void flush() {fs.flush(); open('r'); };
|
||||
virtual size_t write(uint8_t ch) {open('w'); return fs.write(ch);};
|
||||
using Print::write;
|
||||
void putEOF(){write (255);};
|
||||
virtual ~flashStream () {if (fs) fs.close();} ;
|
||||
@@ -87,23 +118,26 @@ public:
|
||||
flashStream(unsigned int _startPos=0, unsigned int _size=4096 ):seekableStream(_size)
|
||||
{
|
||||
pos = _startPos; startPos = _startPos;
|
||||
#if defined(ESP8266)
|
||||
size_t len = EEPROM.length();
|
||||
if (len) EEPROM.commit();
|
||||
EEPROM.begin(len+streamSize); //Re-init
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
void setSize(unsigned int _size) {streamSize=_size;};
|
||||
int open(bool write=false) {return 1;};
|
||||
|
||||
virtual unsigned int seek(unsigned int _pos = 0)
|
||||
{ pos=min(startPos+_pos, startPos+streamSize);
|
||||
//debugSerial<<F("Seek:")<<pos<<endl;
|
||||
debugSerial<<F("Seek:")<<pos<<endl;
|
||||
return pos;
|
||||
};
|
||||
virtual int available() { return (pos<streamSize);};
|
||||
virtual int available() {
|
||||
//debugSerial<<pos<<"%"<<streamSize<<";";
|
||||
return (pos<streamSize);
|
||||
};
|
||||
virtual int read()
|
||||
{
|
||||
int ch = peek();
|
||||
pos++;
|
||||
//debugSerial<<"<"<<(char)ch;
|
||||
return ch;
|
||||
};
|
||||
virtual int peek()
|
||||
@@ -113,22 +147,33 @@ flashStream(unsigned int _startPos=0, unsigned int _size=4096 ):seekableStream(_
|
||||
else return -1;
|
||||
};
|
||||
virtual void flush() {
|
||||
#if defined(ESP8266)
|
||||
EEPROM.commit();
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
if (EEPROM.commitReset())
|
||||
infoSerial<<"Commited to FLASH"<<endl;
|
||||
else errorSerial<<"Commit error. len:"<<EEPROM.length()<<endl;
|
||||
#endif
|
||||
};
|
||||
|
||||
virtual size_t write(uint8_t ch)
|
||||
{
|
||||
#if defined(__AVR__)
|
||||
//debugSerial<<">"<<(char)ch;
|
||||
#if defined(__AVR__)
|
||||
EEPROM.update(pos++,(char)ch);
|
||||
return 1;
|
||||
#endif
|
||||
#elif defined(__SAM3X8E__)
|
||||
return EEPROM.write(pos++,(char)ch);
|
||||
#else
|
||||
EEPROM.write(pos++,(char)ch);
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
return EEPROM.write(pos++,(char)ch);
|
||||
#endif
|
||||
return 0;
|
||||
// #if defined(__SAM3X8E__)
|
||||
// return EEPROM.write(pos++,(char)ch);
|
||||
// #else
|
||||
// EEPROM.update(pos++,(char)ch);
|
||||
// return 1;
|
||||
// #endif
|
||||
// return 0;
|
||||
};
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
@@ -143,7 +188,7 @@ flashStream(unsigned int _startPos=0, unsigned int _size=4096 ):seekableStream(_
|
||||
using Print::write;//(const uint8_t *buffer, size_t size);
|
||||
#endif
|
||||
void putEOF(){write (255);
|
||||
#if defined(ESP8266)
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
EEPROM.commit();
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -861,6 +861,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
||||
debugSerial << F("Restored from:") << t << endl;
|
||||
cmd.loadItemDef(this);
|
||||
cmd.Cmd(CMD_ON); //turning on
|
||||
status2Send |= SEND_COMMAND | SEND_IMMEDIATE;
|
||||
break;
|
||||
default:
|
||||
return -3;
|
||||
@@ -956,6 +957,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
||||
toExecute=true;
|
||||
if (itemType == CH_THERMO) cmd.Cmd(CMD_AUTO); ////
|
||||
else cmd.Cmd(CMD_ON); //turning on
|
||||
status2Send |= SEND_COMMAND | SEND_IMMEDIATE;
|
||||
break;
|
||||
default:
|
||||
return -3;
|
||||
|
||||
@@ -27,9 +27,30 @@ e-mail anklimov@gmail.com
|
||||
#include "TimerInterrupt_Generic.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SYSLOG_ENABLE
|
||||
#include <Syslog.h>
|
||||
|
||||
#ifndef WIFI_ENABLE
|
||||
EthernetUDP udpSyslogClient;
|
||||
#else
|
||||
WiFiUDP udpSyslogClient;
|
||||
#endif
|
||||
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
|
||||
static char syslogDeviceHostname[16];
|
||||
|
||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
|
||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog,ledRED);
|
||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
|
||||
#else
|
||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
|
||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
|
||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
||||
#endif
|
||||
|
||||
#if defined(FS_STORAGE)
|
||||
flashStream sysConfStream("config.bin");
|
||||
flashStream JSONStream("config.json");
|
||||
flashStream sysConfStream("/config.bin");
|
||||
flashStream JSONStream("/config.json");
|
||||
#else
|
||||
flashStream sysConfStream(SYSCONF_OFFSET,EEPROM_offsetJSON);
|
||||
flashStream JSONStream(EEPROM_offsetJSON,MAX_JSON_CONF_SIZE);
|
||||
@@ -37,7 +58,6 @@ flashStream JSONStream(EEPROM_offsetJSON,MAX_JSON_CONF_SIZE);
|
||||
|
||||
systemConfig sysConf(&sysConfStream);
|
||||
|
||||
|
||||
extern long timer0_overflow_count;
|
||||
#ifdef WIFI_ENABLE
|
||||
WiFiClient ethClient;
|
||||
@@ -64,33 +84,10 @@ EthernetClient ethClient;
|
||||
MDNS mdns(mdnsUDP);
|
||||
#endif
|
||||
|
||||
#ifdef SYSLOG_ENABLE
|
||||
#include <Syslog.h>
|
||||
|
||||
#ifndef WIFI_ENABLE
|
||||
EthernetUDP udpSyslogClient;
|
||||
#else
|
||||
WiFiUDP udpSyslogClient;
|
||||
#endif
|
||||
Syslog udpSyslog(udpSyslogClient, SYSLOG_PROTO_BSD);
|
||||
//unsigned long timerSyslogPingTime;
|
||||
static char syslogDeviceHostname[16];
|
||||
|
||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
|
||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog,ledRED);
|
||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
|
||||
#else
|
||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
|
||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
|
||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
||||
#endif
|
||||
|
||||
StatusLED statusLED(ledRED);
|
||||
|
||||
|
||||
lan_status lanStatus = INITIAL_STATE;
|
||||
|
||||
|
||||
const char configserver[] PROGMEM = CONFIG_SERVER;
|
||||
const char verval_P[] PROGMEM = QUOTE(PIO_SRC_REV);
|
||||
|
||||
@@ -132,20 +129,18 @@ bool owReady = false;
|
||||
bool configOk = false; // At least once connected to MQTT
|
||||
bool configLoaded = false;
|
||||
bool initializedListeners = false;
|
||||
int8_t ethernetIdleCount =0;
|
||||
int8_t configLocked = 0;
|
||||
volatile int8_t ethernetIdleCount =0;
|
||||
volatile int8_t configLocked = 0;
|
||||
|
||||
#if defined (_modbus)
|
||||
ModbusMaster node;
|
||||
#endif
|
||||
|
||||
//byte mac[6];
|
||||
|
||||
PubSubClient mqttClient(ethClient);
|
||||
|
||||
bool wifiInitialized;
|
||||
|
||||
int mqttErrorRate;
|
||||
int8_t mqttErrorRate=0;
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
|
||||
@@ -286,11 +281,11 @@ int httpHandler(Client& client, String request, long contentLength, bool authori
|
||||
|
||||
#ifdef CORS
|
||||
client.print(F("Access-Control-Allow-Origin: "));
|
||||
client.println(CORS);
|
||||
client.println(F(CORS));
|
||||
#endif
|
||||
|
||||
if (response!="") {
|
||||
client.println("Content-Type: text/plain");
|
||||
client.println(F("Content-Type: text/plain"));
|
||||
client.println();
|
||||
client.println(response);
|
||||
}
|
||||
@@ -846,7 +841,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
#ifdef RESTART_LAN_ON_MQTT_ERRORS
|
||||
mqttErrorRate++;
|
||||
if(mqttErrorRate>50){
|
||||
errorSerial<<F("Too many MQTT connection errors. Restart LAN"));
|
||||
errorSerial<<F("Too many MQTT connection errors. Restart LAN")<<endl;
|
||||
mqttErrorRate=0;
|
||||
#ifdef RESET_PIN
|
||||
resetHard();
|
||||
@@ -907,7 +902,6 @@ if (WiFi.status() == WL_CONNECTED) {
|
||||
*/
|
||||
#else // Ethernet connection
|
||||
|
||||
//macAddress * mac = sysConf.getMAC();
|
||||
IPAddress ip, dns, gw, mask;
|
||||
int res = 1;
|
||||
infoSerial<<F("Starting lan")<<endl;
|
||||
@@ -1212,12 +1206,7 @@ void printConfigSummary() {
|
||||
infoSerial<<F("\n1-wire ");
|
||||
printBool(owArr);
|
||||
#endif
|
||||
/*
|
||||
#ifdef SYSLOG_ENABLE
|
||||
infoSerial<<F("\nudp syslog ");
|
||||
printBool(udpSyslogArr);
|
||||
#endif
|
||||
*/
|
||||
|
||||
infoSerial << endl;
|
||||
infoSerial<<F("RAM=")<<freeRam()<<endl;
|
||||
}
|
||||
@@ -1231,6 +1220,7 @@ int loadConfigFromEEPROM()
|
||||
{
|
||||
char ch;
|
||||
infoSerial<<F("Loading Config from EEPROM")<<endl;
|
||||
JSONStream.open('r');
|
||||
JSONStream.seek();
|
||||
if (JSONStream.peek() == '{') {
|
||||
aJsonStream as = aJsonStream(&JSONStream);
|
||||
@@ -1271,17 +1261,19 @@ if (arg_cnt>1)
|
||||
aJsonStringStream stringStream(NULL, outBuf, MAX_JSON_CONF_SIZE);
|
||||
aJson.print(root, &stringStream);
|
||||
int len = strlen(outBuf);
|
||||
outBuf[len++]= EOF;
|
||||
outBuf[len++]= 255;
|
||||
JSONStream.seek();
|
||||
size_t res = JSONStream.write((byte*) outBuf,len);
|
||||
free (outBuf);
|
||||
infoSerial<<res<< F("bytes from ")<<len<<F(" are saved to EEPROM")<<endl;
|
||||
#else
|
||||
JSONStream.open('w');
|
||||
JSONStream.seek();
|
||||
aJsonStream jsonEEPROMStream = aJsonStream(&JSONStream);
|
||||
infoSerial<<F("Saving config to EEPROM..");
|
||||
aJson.print(root, &jsonEEPROMStream);
|
||||
JSONStream.putEOF();
|
||||
JSONStream.flush();
|
||||
infoSerial<<F("Saved to EEPROM")<<endl;
|
||||
#endif
|
||||
}
|
||||
@@ -1356,8 +1348,8 @@ void cmdFunctionIp(int arg_cnt, char **args)
|
||||
}
|
||||
|
||||
void cmdFunctionClearEEPROM(int arg_cnt, char **args){
|
||||
sysConf.clear();
|
||||
infoSerial<<F("EEPROM cleared\n");
|
||||
if (sysConf.clear())
|
||||
infoSerial<<F("EEPROM cleared\n");
|
||||
}
|
||||
|
||||
void cmdFunctionPwd(int arg_cnt, char **args)
|
||||
@@ -1651,6 +1643,39 @@ void setup_main() {
|
||||
delay(1000);
|
||||
#endif
|
||||
|
||||
#ifndef ESP_EEPROM_SIZE
|
||||
#define ESP_EEPROM_SIZE 4096-10
|
||||
#endif
|
||||
|
||||
#if defined (FS_STORAGE)
|
||||
#if defined(FS_PREPARE)
|
||||
//Initialize File System
|
||||
if(SPIFFS.begin(true))
|
||||
{
|
||||
debugSerial<<("SPIFFS Initialize....ok")<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
debugSerial<<("SPIFFS Initialization...failed")<<endl;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
EEPROM.begin(ESP_EEPROM_SIZE);
|
||||
int streamSize = EEPROM.length();
|
||||
JSONStream.setSize(streamSize-EEPROM_offsetJSON);
|
||||
debugSerial<<F("FLASH Init: ")<<streamSize<<endl;
|
||||
#endif
|
||||
#endif
|
||||
//Checkin EEPROM integrity (signature)
|
||||
|
||||
if (!sysConf.isValidSysConf())
|
||||
{
|
||||
infoSerial<<F("No valid EEPROM data")<<endl;
|
||||
sysConf.clear();
|
||||
}
|
||||
// scan_i2c_bus();
|
||||
|
||||
serialDebugLevel=sysConf.getSerialDebuglevel();
|
||||
udpDebugLevel=sysConf.getUdpDebuglevel();
|
||||
|
||||
@@ -1666,33 +1691,11 @@ void setup_main() {
|
||||
setupCmdArduino();
|
||||
printFirmwareVersionAndBuildOptions();
|
||||
|
||||
//Checkin EEPROM integrity (signature)
|
||||
|
||||
if (!sysConf.isValidSysConf()) sysConf.clear();
|
||||
// scan_i2c_bus();
|
||||
|
||||
|
||||
#ifdef SD_CARD_INSERTED
|
||||
sd_card_w5100_setup();
|
||||
#endif
|
||||
setupMacAddress();
|
||||
/*
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
EEPROM.begin(ESP_EEPROM_SIZE);
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if defined(FS_PREPARE)
|
||||
|
||||
//Initialize File System
|
||||
if(SPIFFS.begin(true))
|
||||
{
|
||||
debugSerial<<("SPIFFS Initialize....ok")<<endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
debugSerial<<("SPIFFS Initialization...failed")<<endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _modbus
|
||||
#ifdef CONTROLLINO
|
||||
@@ -1735,7 +1738,6 @@ void setup_main() {
|
||||
#endif
|
||||
|
||||
delay(LAN_INIT_DELAY);//for LAN-shield initializing
|
||||
//TODO: checkForRemoteSketchUpdate();
|
||||
|
||||
#if defined(W5500_CS_PIN) && ! defined(WIFI_ENABLE)
|
||||
Ethernet.init(W5500_CS_PIN);
|
||||
@@ -2064,7 +2066,9 @@ void ethernetIdle(void){
|
||||
ethernetIdleCount++;
|
||||
wdt_res();
|
||||
yield();
|
||||
inputLoop(CHECK_INPUT);
|
||||
inputLoop(CHECK_INTERRUPT);
|
||||
yield();
|
||||
cmdPoll();
|
||||
ethernetIdleCount--;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,6 +116,7 @@ lib_deps =
|
||||
https://github.com/arcao/Syslog.git
|
||||
br3ttb/PID@^1.2.1
|
||||
TimerInterrupt_Generic
|
||||
d00616/arduino-NVM @ ^0.9.1
|
||||
|
||||
monitor_speed = 115200
|
||||
|
||||
@@ -138,7 +139,8 @@ lib_ignore =
|
||||
Ethernet2
|
||||
Ethernet3
|
||||
Ethernet5100
|
||||
EEPROM
|
||||
ESP_EEPROM
|
||||
;EEPROM
|
||||
Artnet
|
||||
UIPEthernet
|
||||
ESP_EEPROM
|
||||
@@ -204,7 +206,8 @@ lib_ignore =
|
||||
Ethernet2
|
||||
Ethernet3
|
||||
Ethernet5100
|
||||
EEPROM
|
||||
;EEPROM
|
||||
ESP_EEPROM
|
||||
UIPEthernet
|
||||
ESP_EEPROM
|
||||
httpClient
|
||||
@@ -219,7 +222,7 @@ lib_deps =
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
Streaming
|
||||
;ESP_EEPROM
|
||||
;EEPROM
|
||||
;https://github.com/anklimov/NRFFlashStorage
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library for ESPx
|
||||
@@ -371,8 +374,8 @@ board_build.f_cpu = 16000000L
|
||||
;build_unflags = -flto - not working without LTO!
|
||||
|
||||
;upload_protocol = arduino
|
||||
;upload_command = arduinoOTA -address 192.168.11.213 -port 65280 -username arduino -password password -b -upload /sketch -sketch $BUILD_DIR/${PROGNAME}.bin;sleep 5
|
||||
;upload_protocol = custom
|
||||
upload_command = arduinoOTA -address 192.168.11.213 -port 65280 -username arduino -password password -b -upload /sketch -sketch $BUILD_DIR/${PROGNAME}.bin;sleep 5
|
||||
upload_protocol = custom
|
||||
|
||||
board_upload.speed = ${env:fuses_bootloader.board_bootloader.speed}
|
||||
framework = arduino
|
||||
@@ -599,9 +602,9 @@ framework = arduino
|
||||
board = due
|
||||
monitor_baud = 115200
|
||||
build_flags = !python get_build_flags.py lighthub21
|
||||
;upload_command = arduinoOTA -address 192.168.11.172 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE ;sleep 6
|
||||
upload_command = arduinoOTA -address 192.168.11.172 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE ;sleep 6
|
||||
;upload_command = arduinoOTA -address 192.168.88.45 -port 65280 -username arduino -password password -b -upload /sketch -sketch $SOURCE;sleep 6
|
||||
;upload_protocol = custom
|
||||
upload_protocol = custom
|
||||
lib_ignore =
|
||||
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||
DHT sensor library for ESPx
|
||||
|
||||
Reference in New Issue
Block a user