mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Red blink on errors
Some cleanup
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
-DCONTROLLINO
|
-DCONTROLLINO
|
||||||
-DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
-DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
||||||
|
-DWiz5100
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
-DDMX_SMOOTH
|
-DDMX_SMOOTH
|
||||||
-DSTATUSLED
|
-DSTATUSLED
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
|
-DWiz5100
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
-DAVR_DMXOUT_PIN=18
|
-DAVR_DMXOUT_PIN=18
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
|
-DWiz5100
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
File diff suppressed because it is too large
Load Diff
@@ -112,11 +112,11 @@ unsigned long nextSyslogPingTime;
|
|||||||
static char syslogDeviceHostname[16];
|
static char syslogDeviceHostname[16];
|
||||||
|
|
||||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
|
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG,&udpSyslog);
|
||||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog);
|
Streamlog errorSerial(&debugSerialPort,LOG_ERROR,&udpSyslog,ledRED);
|
||||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
|
Streamlog infoSerial (&debugSerialPort,LOG_INFO,&udpSyslog);
|
||||||
#else
|
#else
|
||||||
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
|
Streamlog debugSerial(&debugSerialPort,LOG_DEBUG);
|
||||||
Streamlog errorSerial(&debugSerialPort,LOG_ERROR);
|
Streamlog errorSerial(&debugSerialPort,LOG_ERROR, ledRED);
|
||||||
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
Streamlog infoSerial (&debugSerialPort,LOG_INFO);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -221,8 +221,11 @@ while (items && item)
|
|||||||
}
|
}
|
||||||
pollingItem = NULL;
|
pollingItem = NULL;
|
||||||
debugSerial<<F("Stopped")<<endl;
|
debugSerial<<F("Stopped")<<endl;
|
||||||
//stopSyslog();
|
|
||||||
|
#ifdef SYSLOG_ENABLE
|
||||||
syslogInitialized=false; //Garbage in memory
|
syslogInitialized=false; //Garbage in memory
|
||||||
|
#endif
|
||||||
|
|
||||||
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
root = NULL;
|
root = NULL;
|
||||||
@@ -378,11 +381,6 @@ void setupOTA(void)
|
|||||||
//OTA_initialized=true;
|
//OTA_initialized=true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void stopSyslog()
|
|
||||||
{
|
|
||||||
syslogInitialized = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupSyslog()
|
void setupSyslog()
|
||||||
{
|
{
|
||||||
@@ -391,9 +389,9 @@ void setupSyslog()
|
|||||||
short n = 0;
|
short n = 0;
|
||||||
aJsonObject *udpSyslogArr = NULL;
|
aJsonObject *udpSyslogArr = NULL;
|
||||||
|
|
||||||
if (syslogInitialized) {debugSerial<<F("Syslog: initialized")<<endl;return;};
|
if (syslogInitialized) return;
|
||||||
if (lanStatus<HAVE_IP_ADDRESS) {debugSerial<<F("Syslog: lanStatus=")<<lanStatus<<endl;return;};
|
if (lanStatus<HAVE_IP_ADDRESS) return;
|
||||||
if (!root) {debugSerial<<F("Syslog: no root")<<endl;return;};
|
if (!root) return;
|
||||||
|
|
||||||
udpSyslogClient.begin(SYSLOG_LOCAL_SOCKET);
|
udpSyslogClient.begin(SYSLOG_LOCAL_SOCKET);
|
||||||
|
|
||||||
@@ -412,7 +410,7 @@ void setupSyslog()
|
|||||||
udpSyslog.defaultPriority(LOG_KERN);
|
udpSyslog.defaultPriority(LOG_KERN);
|
||||||
syslogInitialized=true;
|
syslogInitialized=true;
|
||||||
|
|
||||||
infoSerial<<F("UDP Syslog initialized!\n");
|
infoSerial<<F("UDP Syslog initialized.\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1581,18 +1579,18 @@ void setup_main() {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef _modbus
|
#ifdef _modbus
|
||||||
#ifdef CONTROLLINO
|
#ifdef CONTROLLINO
|
||||||
//set PORTJ pin 5,6 direction (RE,DE)
|
//set PORTJ pin 5,6 direction (RE,DE)
|
||||||
DDRJ |= B01100000;
|
DDRJ |= B01100000;
|
||||||
//set RE,DE on LOW
|
//set RE,DE on LOW
|
||||||
PORTJ &= B10011111;
|
PORTJ &= B10011111;
|
||||||
#else
|
#else
|
||||||
pinMode(TXEnablePin, OUTPUT);
|
pinMode(TXEnablePin, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
modbusSerial.begin(MODBUS_SERIAL_BAUD);
|
modbusSerial.begin(MODBUS_SERIAL_BAUD);
|
||||||
node.idle(&modbusIdle);
|
node.idle(&modbusIdle);
|
||||||
node.preTransmission(preTransmission);
|
node.preTransmission(preTransmission);
|
||||||
node.postTransmission(postTransmission);
|
node.postTransmission(postTransmission);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delay(20);
|
delay(20);
|
||||||
@@ -1623,12 +1621,8 @@ void setup_main() {
|
|||||||
delay(LAN_INIT_DELAY);//for LAN-shield initializing
|
delay(LAN_INIT_DELAY);//for LAN-shield initializing
|
||||||
//TODO: checkForRemoteSketchUpdate();
|
//TODO: checkForRemoteSketchUpdate();
|
||||||
|
|
||||||
#ifdef W5500_CS_PIN
|
#if defined(W5500_CS_PIN) && ! defined(WIFI_ENABLE)
|
||||||
//#ifndef Wiz5500
|
Ethernet.init(W5500_CS_PIN);
|
||||||
Ethernet.init(W5500_CS_PIN);
|
|
||||||
//#else
|
|
||||||
// Ethernet.w5500_cspin = W5500_CS_PIN;
|
|
||||||
//#endif
|
|
||||||
infoSerial<<F("Use W5500 pin: ");
|
infoSerial<<F("Use W5500 pin: ");
|
||||||
infoSerial<<QUOTE(W5500_CS_PIN)<<endl;
|
infoSerial<<QUOTE(W5500_CS_PIN)<<endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -1663,12 +1657,19 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
infoSerial<<F("\n(+)WiFi");
|
infoSerial<<F("\n(+)WiFi");
|
||||||
#elif Wiz5500
|
#elif Wiz5500
|
||||||
infoSerial<<F("\n(+)WizNet5500");
|
infoSerial<<F("\n(+)WizNet5500");
|
||||||
|
#elif Wiz5100
|
||||||
|
infoSerial<<F("\n(+)Wiznet5100");
|
||||||
#else
|
#else
|
||||||
infoSerial<<F("\n(+)Wiznet5x00");
|
infoSerial<<F("\n(+)Wiznet5x00");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DMX_DISABLE
|
#ifndef DMX_DISABLE
|
||||||
infoSerial<<F("\n(+)DMX");
|
infoSerial<<F("\n(+)DMX");
|
||||||
|
#ifdef FASTLED
|
||||||
|
infoSerial<<F("\n(+)FASTLED");
|
||||||
|
#else
|
||||||
|
infoSerial<<F("\n(+)ADAFRUIT LED");
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
infoSerial<<F("\n(-)DMX");
|
infoSerial<<F("\n(-)DMX");
|
||||||
#endif
|
#endif
|
||||||
@@ -1733,11 +1734,7 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#else
|
#else
|
||||||
infoSerial<<F("\n(-)SPI LED");
|
infoSerial<<F("\n(-)SPI LED");
|
||||||
#endif
|
#endif
|
||||||
#ifdef FASTLED
|
|
||||||
infoSerial<<F("\n(+)FASTLED");
|
|
||||||
#else
|
|
||||||
infoSerial<<F("\n(+)ADAFRUIT LED");
|
|
||||||
#endif
|
|
||||||
#ifdef OTA
|
#ifdef OTA
|
||||||
infoSerial<<F("\n(+)OTA");
|
infoSerial<<F("\n(+)OTA");
|
||||||
#else
|
#else
|
||||||
@@ -1786,8 +1783,6 @@ void publishStat(){
|
|||||||
char intbuf[16];
|
char intbuf[16];
|
||||||
uint32_t ut = millis()/1000UL;
|
uint32_t ut = millis()/1000UL;
|
||||||
if (!mqttClient.connected() || ethernetIdleCount) return;
|
if (!mqttClient.connected() || ethernetIdleCount) return;
|
||||||
|
|
||||||
// debugSerial<<F("\nfree RAM: ")<<fr;
|
|
||||||
setTopic(topic,sizeof(topic),T_DEV);
|
setTopic(topic,sizeof(topic),T_DEV);
|
||||||
strncat_P(topic, stats_P, sizeof(topic));
|
strncat_P(topic, stats_P, sizeof(topic));
|
||||||
strncat(topic, "/", sizeof(topic));
|
strncat(topic, "/", sizeof(topic));
|
||||||
@@ -1898,13 +1893,9 @@ void loop_main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
// #ifndef MODBUS_DISABLE
|
|
||||||
if (isNotRetainingStatus()) pollingLoop();
|
if (isNotRetainingStatus()) pollingLoop();
|
||||||
// #endif
|
|
||||||
//#ifdef _owire
|
|
||||||
yield();
|
yield();
|
||||||
thermoLoop();
|
thermoLoop();
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
@@ -1945,6 +1936,8 @@ ethernetIdleCount--;
|
|||||||
|
|
||||||
void modbusIdle(void) {
|
void modbusIdle(void) {
|
||||||
LED.poll();
|
LED.poll();
|
||||||
|
yield();
|
||||||
|
cmdPoll();
|
||||||
wdt_res();
|
wdt_res();
|
||||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
if (lanLoop() > HAVE_IP_ADDRESS) {
|
||||||
yield();
|
yield();
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ switch (regType) {
|
|||||||
default:
|
default:
|
||||||
debugSerial<<F("Not supported reg type\n");
|
debugSerial<<F("Not supported reg type\n");
|
||||||
}
|
}
|
||||||
|
if (result != node.ku8MBSuccess) errorSerial<<F("MBUS: Polling error")<<endl;
|
||||||
return (result == node.ku8MBSuccess);
|
return (result == node.ku8MBSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
#include "streamlog.h"
|
#include "streamlog.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#if defined (STATUSLED)
|
||||||
|
extern statusLED LED;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
extern bool syslogInitialized;
|
extern bool syslogInitialized;
|
||||||
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity , Syslog * _syslog )
|
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity , Syslog * _syslog, uint8_t _ledPattern )
|
||||||
{
|
{
|
||||||
serialPort=_serialPort;
|
serialPort=_serialPort;
|
||||||
severity=_severity;
|
severity=_severity;
|
||||||
syslog=_syslog;
|
syslog=_syslog;
|
||||||
|
ledPattern=_ledPattern;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity)
|
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity, uint8_t _ledPattern)
|
||||||
{
|
{
|
||||||
serialPort=_serialPort;
|
serialPort=_serialPort;
|
||||||
severity=_severity;
|
severity=_severity;
|
||||||
@@ -69,6 +75,11 @@ if (syslogInitialized)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (STATUSLED)
|
||||||
|
if ((ch=='\n') && ledPattern) LED.flash(ledPattern);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (serialPort) return serialPort->write(ch);
|
if (serialPort) return serialPort->write(ch);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ class Streamlog : public Print
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, Syslog * _syslog = NULL);
|
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, Syslog * _syslog = NULL, uint8_t _ledPattern = 0);
|
||||||
#else
|
#else
|
||||||
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG);
|
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, uint8_t _ledPattern = 0);
|
||||||
#endif
|
#endif
|
||||||
// {serialPort=_serialPort;severity=_severity; syslog=_syslog; }
|
// {serialPort=_serialPort;severity=_severity; syslog=_syslog; }
|
||||||
void begin(unsigned long speed);
|
void begin(unsigned long speed);
|
||||||
@@ -43,5 +43,6 @@ class Streamlog : public Print
|
|||||||
HardwareSerial *serialPort;
|
HardwareSerial *serialPort;
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
Syslog * syslog;
|
Syslog * syslog;
|
||||||
|
uint8_t ledPattern;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ src_dir = lighthub
|
|||||||
default_envs =
|
default_envs =
|
||||||
; ****** UNCOMMENT single environment name for target platform below *******
|
; ****** UNCOMMENT single environment name for target platform below *******
|
||||||
; Arduino Mega (without onewire) + Ethernet shield Wiznet 5100
|
; Arduino Mega (without onewire) + Ethernet shield Wiznet 5100
|
||||||
mega2560slim-5100
|
; mega2560slim-5100
|
||||||
|
|
||||||
; Arduino Mega + Ethernet shield Wiznet 5100
|
; Arduino Mega + Ethernet shield Wiznet 5100
|
||||||
; mega2560-5100
|
; mega2560-5100
|
||||||
@@ -341,7 +341,7 @@ lib_ignore =
|
|||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
WifiManager
|
WifiManager
|
||||||
Ethernet3
|
Ethernet3
|
||||||
Ethernet
|
Ethernet2
|
||||||
HTTPClient
|
HTTPClient
|
||||||
NRFFlashStorage
|
NRFFlashStorage
|
||||||
WebServer
|
WebServer
|
||||||
@@ -357,7 +357,8 @@ lib_deps =
|
|||||||
https://github.com/anklimov/CmdArduino
|
https://github.com/anklimov/CmdArduino
|
||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
https://github.com/anklimov/DMXSerial
|
https://github.com/anklimov/DMXSerial
|
||||||
https://github.com/anklimov/Ethernet5100
|
https://github.com/anklimov/Ethernet
|
||||||
|
;5100 lib have ~90 bytes less footprint of RAM
|
||||||
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@3.3.2
|
FastLED@3.3.2
|
||||||
|
|||||||
Reference in New Issue
Block a user