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