mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
pre-release, save2flash, mdns bugs, dmx, .....
This commit is contained in:
@@ -12,3 +12,15 @@
|
|||||||
-DARDUINO_OTA_MDNS_DISABLE
|
-DARDUINO_OTA_MDNS_DISABLE
|
||||||
-DMDNS_ENABLE
|
-DMDNS_ENABLE
|
||||||
-DTIMER_INT
|
-DTIMER_INT
|
||||||
|
|
||||||
|
#Put modbus exchange in debug hex dump
|
||||||
|
#-DMODBUS_DEBUG
|
||||||
|
|
||||||
|
#Uncomment next 3 lines (or add it to custom build flags) to use Native USB port for debug/CLI instead Serial
|
||||||
|
#-DdebugSerialPort=SerialUSB
|
||||||
|
#-DSerialPortType=Serial_
|
||||||
|
#-DSERIAL_BAUD=0
|
||||||
|
|
||||||
|
#Default SerialDebug settings
|
||||||
|
#-DSERIAL_BAUD=115200
|
||||||
|
#-DdebugSerialPort=Serial
|
||||||
|
|||||||
@@ -10,3 +10,14 @@
|
|||||||
-DAC_DISABLE
|
-DAC_DISABLE
|
||||||
-DPID_DISABLE
|
-DPID_DISABLE
|
||||||
-DdebugSerialPort=SerialUSB
|
-DdebugSerialPort=SerialUSB
|
||||||
|
-DSerialPortType=USBSerial
|
||||||
|
-DSERIAL_BAUD=0
|
||||||
|
|
||||||
|
-DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC
|
||||||
|
-DUSBCON
|
||||||
|
#-DUSBD_VID=0x0483
|
||||||
|
#-DUSBD_PID=0x5740
|
||||||
|
#-DUSB_MANUFACTURER="Unknown"
|
||||||
|
#-DUSB_PRODUCT="\"BLUEPILL_F103C8\""
|
||||||
|
#-DHAL_PCD_MODULE_ENABLED
|
||||||
|
#-D USBD_USE_CDC
|
||||||
|
|||||||
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.
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
11076
compiled/nrf52840-5500
11076
compiled/nrf52840-5500
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
compiled/stm32/firmware.bin
Executable file
BIN
compiled/stm32/firmware.bin
Executable file
Binary file not shown.
BIN
compiled/stm32/firmware.elf
Executable file
BIN
compiled/stm32/firmware.elf
Executable file
Binary file not shown.
1
compiled/stm32/upload.sh
Executable file
1
compiled/stm32/upload.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
dfu-util -D firmware.bin -a 1
|
||||||
@@ -10,10 +10,10 @@ uint8_t getBright255(uint8_t percent255)
|
|||||||
/*
|
/*
|
||||||
int val = stepvar[index];
|
int val = stepvar[index];
|
||||||
if (val>255) val=255;
|
if (val>255) val=255;
|
||||||
Serial.print(F("Bright:"));
|
debugSerialPort.print(F("Bright:"));
|
||||||
Serial.print(percent);
|
debugSerialPort.print(percent);
|
||||||
Serial.print(F("->"));
|
debugSerialPort.print(F("->"));
|
||||||
Serial.println(val);
|
debugSerialPort.println(val);
|
||||||
return val;*/
|
return val;*/
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,5 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
//#if defined(ARDUINO_ARCH_AVR)
|
|
||||||
//#include <EEPROM.h>
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
void saveFlash(short n, char *str) {
|
|
||||||
short len=strlen(str);
|
|
||||||
if (len>MAXFLASHSTR-1) len=MAXFLASHSTR-1;
|
|
||||||
for(int i=0;i<len;i++) EEPROM.write(n+i,str[i]);
|
|
||||||
EEPROM.write(n+len,0);
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
|
||||||
// write the data to EEPROM
|
|
||||||
short res = EEPROM.commitReset();
|
|
||||||
Serial.println((res) ? "EEPROM Commit OK" : "Commit failed");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int loadFlash(short n, char *str, short l) {
|
|
||||||
short i;
|
|
||||||
uint8_t ch = EEPROM.read(n);
|
|
||||||
if (!ch || (ch == 0xff)) return 0;
|
|
||||||
for (i=0;i<l-1 && (str[i] = EEPROM.read(n++));i++);
|
|
||||||
str[i]=0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saveFlash(short n, IPAddress& ip) {
|
|
||||||
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
|
||||||
// write the data to EEPROM
|
|
||||||
short res = EEPROM.commitReset();
|
|
||||||
Serial.println((res) ? "EEPROM Commit OK" : "Commit failed");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int ipLoadFromFlash(short n, IPAddress &ip) {
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
ip[i] = EEPROM.read(n++);
|
|
||||||
return (ip[0] && ((ip[0] != 0xff) || (ip[1] != 0xff) || (ip[2] != 0xff) || (ip[3] != 0xff)));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool systemConfig::isValidSysConf()
|
bool systemConfig::isValidSysConf()
|
||||||
{
|
{
|
||||||
@@ -75,7 +31,7 @@ bool systemConfig::isValidSysConf()
|
|||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return false;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
stream->seek(offsetof(systemConfigData,mac));
|
stream->seek(offsetof(systemConfigData,mac));
|
||||||
///stream->write ((const uint8_t *)&_mac,sizeof(_mac));
|
stream->write ((const uint8_t *)&_mac,sizeof(_mac));
|
||||||
memcpy(mac, _mac, sizeof(mac));
|
memcpy(mac, _mac, sizeof(mac));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -85,16 +41,21 @@ bool systemConfig::isValidSysConf()
|
|||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return NULL;
|
if (!stream || !isValidSysConf()) return NULL;
|
||||||
stream->seek(offsetof(systemConfigData,MQTTpwd));
|
stream->seek(offsetof(systemConfigData,MQTTpwd));
|
||||||
if (stream->readBytesUntil(0,buffer,bufLen)) return buffer;
|
short bytes=stream->readBytesUntil(0,buffer,bufLen-1);
|
||||||
|
if (bytes)
|
||||||
|
{
|
||||||
|
buffer[bytes]=0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::setMQTTpwd(char * pwd)
|
bool systemConfig::setMQTTpwd(char * pwd)
|
||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return false;
|
if (!stream || !isValidSysConf() || (strlen(pwd)>=sizeof(systemConfigData::MQTTpwd))) return false;
|
||||||
stream->seek(offsetof(systemConfigData,MQTTpwd));
|
stream->seek(offsetof(systemConfigData,MQTTpwd));
|
||||||
stream->print(pwd);
|
stream->print(pwd);
|
||||||
return stream->write(0);
|
return stream->write((uint8_t)'\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,16 +63,21 @@ bool systemConfig::isValidSysConf()
|
|||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return NULL;
|
if (!stream || !isValidSysConf()) return NULL;
|
||||||
stream->seek(offsetof(systemConfigData,OTApwd));
|
stream->seek(offsetof(systemConfigData,OTApwd));
|
||||||
if (stream->readBytesUntil(0,buffer,bufLen)) return buffer;
|
short bytes=stream->readBytesUntil(0,buffer,bufLen-1);
|
||||||
|
if (bytes)
|
||||||
|
{
|
||||||
|
buffer[bytes]=0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::setOTApwd(char * pwd)
|
bool systemConfig::setOTApwd(char * pwd)
|
||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return false;
|
if (!stream || !isValidSysConf() || (strlen(pwd)>=sizeof(systemConfigData::OTApwd))) return false;
|
||||||
stream->seek(offsetof(systemConfigData,OTApwd));
|
stream->seek(offsetof(systemConfigData,OTApwd));
|
||||||
stream->print(pwd);
|
stream->print(pwd);
|
||||||
return stream->write(0);
|
return stream->write((uint8_t)'\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,70 +85,90 @@ bool systemConfig::isValidSysConf()
|
|||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return NULL;
|
if (!stream || !isValidSysConf()) return NULL;
|
||||||
stream->seek(offsetof(systemConfigData,configURL));
|
stream->seek(offsetof(systemConfigData,configURL));
|
||||||
if (stream->readBytesUntil(0,buffer,bufLen)) return buffer;
|
short bytes=stream->readBytesUntil(0,buffer,bufLen-1);
|
||||||
|
if (bytes)
|
||||||
|
{
|
||||||
|
buffer[bytes]=0;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::setServer(char* url)
|
bool systemConfig::setServer(char* url)
|
||||||
{
|
{
|
||||||
if (!stream || !isValidSysConf()) return false;
|
if (!stream || !isValidSysConf() || (strlen(url)>=sizeof(systemConfigData::configURL))) return false;
|
||||||
stream->seek(offsetof(systemConfigData,OTApwd));
|
stream->seek(offsetof(systemConfigData,configURL));
|
||||||
stream->print(url);
|
stream->print(url);
|
||||||
return stream->write(0);
|
return stream->write((uint8_t)'\0');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool systemConfig::getIP(IPAddress& ip)
|
bool systemConfig::getIP(IPAddress& ip)
|
||||||
{
|
{
|
||||||
|
uint32_t addr;
|
||||||
if (!stream || !isValidSysConf()) return false;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
stream->seek(offsetof(systemConfigData,ip));
|
stream->seek(offsetof(systemConfigData,ip));
|
||||||
stream->readBytes((char *)&ip,sizeof(ip));
|
stream->readBytes((uint8_t *) &addr,4);
|
||||||
return ip;
|
ip=addr;
|
||||||
|
return (ip[0] && ((ip[0] != 0xff) || (ip[1] != 0xff) || (ip[2] != 0xff) || (ip[3] != 0xff)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::getMask(IPAddress& mask)
|
bool systemConfig::getMask(IPAddress& mask)
|
||||||
{
|
{
|
||||||
return 0;
|
uint32_t addr;
|
||||||
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,mask));
|
||||||
|
stream->readBytes((uint8_t *) &addr,4);
|
||||||
|
mask=addr;
|
||||||
|
return (mask[0] && ((mask[0] != 0xff) || (mask[1] != 0xff) || (mask[2] != 0xff) || (mask[3] != 0xff)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::getDNS(IPAddress& dns)
|
bool systemConfig::getDNS(IPAddress& dns)
|
||||||
{
|
{ uint32_t addr;
|
||||||
return 0;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,dns));
|
||||||
|
stream->readBytes((uint8_t *) &addr,4);
|
||||||
|
dns = addr;
|
||||||
|
return (dns[0] && ((dns[0] != 0xff) || (dns[1] != 0xff) || (dns[2] != 0xff) || (dns[3] != 0xff)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::getGW(IPAddress& gw)
|
bool systemConfig::getGW(IPAddress& gw)
|
||||||
{
|
{ uint32_t addr;
|
||||||
return 0;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,gw));
|
||||||
}
|
stream->readBytes((uint8_t *) &addr,4);
|
||||||
|
gw=addr;
|
||||||
|
return (gw[0] && ((gw[0] != 0xff) || (gw[1] != 0xff) || (gw[2] != 0xff) || (gw[3] != 0xff)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool systemConfig::setIP(IPAddress& ip)
|
bool systemConfig::setIP(IPAddress& ip)
|
||||||
{
|
{ uint32_t addr=ip;
|
||||||
return 0;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,ip));
|
||||||
|
return stream->write((uint8_t *) &addr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::setMask(IPAddress& mask)
|
bool systemConfig::setMask(IPAddress& mask)
|
||||||
{
|
{ uint32_t addr = mask;
|
||||||
return 0;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,mask));
|
||||||
|
return stream->write((uint8_t *) &addr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::setDNS(IPAddress& dns)
|
bool systemConfig::setDNS(IPAddress& dns)
|
||||||
{
|
{ uint32_t addr = dns;
|
||||||
return 0;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,dns));
|
||||||
|
return stream->write((uint8_t *) &addr, 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systemConfig::setGW(IPAddress& gw)
|
bool systemConfig::setGW(IPAddress& gw)
|
||||||
{
|
{ uint32_t addr = gw;
|
||||||
return 0;
|
if (!stream || !isValidSysConf()) return false;
|
||||||
|
stream->seek(offsetof(systemConfigData,gw));
|
||||||
|
return stream->write((uint8_t *) &addr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +177,7 @@ bool systemConfig::isValidSysConf()
|
|||||||
if (!stream) return ;
|
if (!stream) return ;
|
||||||
stream->seek(0);
|
stream->seek(0);
|
||||||
for (unsigned int i = 0; i < stream->getSize(); i++) {
|
for (unsigned int i = 0; i < stream->getSize(); i++) {
|
||||||
stream->write(0);
|
stream->write((uint8_t)'\0');
|
||||||
}
|
}
|
||||||
stream->seek(offsetof(systemConfigData,signature));
|
stream->seek(offsetof(systemConfigData,signature));
|
||||||
for (unsigned int i=0;i<sizeof(systemConfigData::signature);i++)
|
for (unsigned int i=0;i<sizeof(systemConfigData::signature);i++)
|
||||||
@@ -199,9 +185,49 @@ bool systemConfig::isValidSysConf()
|
|||||||
stream->flush();
|
stream->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
bool systemConfig::getSaveSuccedConfig()
|
bool systemConfig::getSaveSuccedConfig()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool systemConfig::setSaveSuccedConfig(bool)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
|
bool systemConfig::setSerialDebuglevel(short level)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool systemConfig::setUdpDebuglevel(short level)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t systemConfig::getSerialDebuglevel()
|
||||||
|
{
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t systemConfig::getUdpDebuglevel()
|
||||||
|
{
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool systemConfig::setLoadHTTPConfig(bool load)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool systemConfig::getLoadHTTPConfig()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,22 +28,26 @@ const char EEPROM_signature[] = EEPROM_SIGNATURE;
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char signature[4];
|
char signature[4];
|
||||||
macAddress mac;
|
macAddress mac; //6 bytes
|
||||||
|
union {
|
||||||
|
uint16_t configFlags;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t serialDebugLevel:4;
|
||||||
|
uint8_t syslogDebugLevel:4;
|
||||||
|
uint8_t notGetConfigFromHTTP:1;
|
||||||
|
uint8_t saveToFlash:1;
|
||||||
|
};
|
||||||
|
};
|
||||||
uint32_t ip;
|
uint32_t ip;
|
||||||
uint32_t dns;
|
uint32_t dns;
|
||||||
uint32_t gw;
|
uint32_t gw;
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
union {
|
|
||||||
uint8_t configFlags;
|
|
||||||
struct
|
|
||||||
{ uint8_t notGetConfigFromHTTP:1;
|
|
||||||
uint8_t saveToFlash:1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
flashstr configURL;
|
flashstr configURL;
|
||||||
flashpwd MQTTpwd;
|
flashpwd MQTTpwd;
|
||||||
flashpwd OTApwd;
|
flashpwd OTApwd;
|
||||||
uint8_t serialDebugLevel;
|
|
||||||
uint16_t sysConfigHash;
|
uint16_t sysConfigHash;
|
||||||
uint16_t JSONHash;
|
uint16_t JSONHash;
|
||||||
|
|
||||||
@@ -82,8 +86,15 @@ class systemConfig {
|
|||||||
bool setDNS(IPAddress& dns);
|
bool setDNS(IPAddress& dns);
|
||||||
bool setGW(IPAddress& gw);
|
bool setGW(IPAddress& gw);
|
||||||
|
|
||||||
|
bool setSerialDebuglevel(short);
|
||||||
|
bool setUdpDebuglevel(short);
|
||||||
|
uint8_t getSerialDebuglevel();
|
||||||
|
uint8_t getUdpDebuglevel();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool getSaveSuccedConfig();
|
bool getSaveSuccedConfig();
|
||||||
|
bool setSaveSuccedConfig(bool);
|
||||||
bool getLoadHTTPConfig();
|
bool getLoadHTTPConfig();
|
||||||
|
bool setLoadHTTPConfig(bool);
|
||||||
//bool Save();
|
//bool Save();
|
||||||
};
|
};
|
||||||
@@ -39,14 +39,14 @@ DMXESPSerial dmxout;
|
|||||||
uint8_t * DMXin = NULL;
|
uint8_t * DMXin = NULL;
|
||||||
|
|
||||||
#ifdef DMX_SMOOTH
|
#ifdef DMX_SMOOTH
|
||||||
uint8_t * DMXinterimBuf = NULL;
|
volatile uint8_t * DMXinterimBuf = NULL;
|
||||||
uint16_t DMXOUT_Channels=0;
|
volatile uint16_t DMXOUT_Channels=0;
|
||||||
uint32_t checkTimestamp=0L;
|
volatile uint32_t checkTimestamp=0L;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int D_State=0;
|
volatile uint32_t D_State=0;
|
||||||
|
|
||||||
unsigned long D_checkT=0;
|
volatile unsigned long D_checkT=0;
|
||||||
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
#include <Artnet.h>
|
#include <Artnet.h>
|
||||||
@@ -123,6 +123,7 @@ void DMXSemiImmediateUpdate(short tch,short trh, int val)
|
|||||||
|
|
||||||
void DMXput(void)
|
void DMXput(void)
|
||||||
{
|
{
|
||||||
|
if (!DMXin) return;
|
||||||
for (short tch=0; tch<=3 ; tch++)
|
for (short tch=0; tch<=3 ; tch++)
|
||||||
{
|
{
|
||||||
short base = tch*4;
|
short base = tch*4;
|
||||||
@@ -130,12 +131,15 @@ for (short tch=0; tch<=3 ; tch++)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern volatile uint8_t timerHandlerBusy;
|
||||||
|
volatile int DMXinDoublecheck=0;
|
||||||
|
|
||||||
void DMXUpdate(void)
|
void DMXUpdate(void)
|
||||||
{
|
{
|
||||||
#if defined(_dmxin)
|
#if defined(_dmxin)
|
||||||
int t;
|
int t;
|
||||||
if(!DMXin) return;
|
if(!DMXin) return;
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
if (dmxin.getRxLength()<16) return;
|
if (dmxin.getRxLength()<16) return;
|
||||||
#endif
|
#endif
|
||||||
@@ -143,21 +147,28 @@ for (short tch=0; tch<=3 ; tch++)
|
|||||||
{
|
{
|
||||||
short base = tch*4;
|
short base = tch*4;
|
||||||
bool updated = 0;
|
bool updated = 0;
|
||||||
|
bool confirmed = 0;
|
||||||
|
|
||||||
for (short trh=0; trh<4 ; trh++)
|
for (short trh=0; trh<4 ; trh++)
|
||||||
if ((t=dmxin.read(base+trh+1)) != DMXin[base+trh])
|
if (((t=dmxin.read(base+trh+1)) != DMXin[base+trh]))
|
||||||
|
{
|
||||||
|
updated=1;
|
||||||
|
if (DMXinDoublecheck>2)
|
||||||
{
|
{
|
||||||
D_State |= (1<<tch);
|
D_State |= (1<<tch);
|
||||||
updated=1;
|
|
||||||
//Serial.print("onContactChanged :"); Serial.print(DMXin[tch*4+trh]); Serial.print(" => "); Serial.print(t);Serial.println();
|
|
||||||
DMXin[base+trh]=t;
|
DMXin[base+trh]=t;
|
||||||
//DMXImmediateUpdate(tch,trh,t);
|
confirmed = 1;
|
||||||
//break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated)
|
if (updated) DMXinDoublecheck++; else DMXinDoublecheck=0;
|
||||||
|
|
||||||
|
|
||||||
|
if (confirmed)
|
||||||
{
|
{
|
||||||
|
|
||||||
DMXImmediateUpdate(tch,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]);
|
DMXImmediateUpdate(tch,DMXin[base],DMXin[base+1],DMXin[base+2],DMXin[base+3]);
|
||||||
|
//for (int i=1; i<17; i++) {debugSerial.print(dmxin.read(i));debugSerial.print("-");};debugSerial.print("|");
|
||||||
D_checkT=millisNZ();
|
D_checkT=millisNZ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,11 +202,14 @@ D_checkT=0;
|
|||||||
|
|
||||||
// Here code for network update
|
// Here code for network update
|
||||||
//int ch = 0;
|
//int ch = 0;
|
||||||
|
|
||||||
DMXput();
|
DMXput();
|
||||||
|
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
for (int i=1; i<17; i++) {Serial.print(dmxin.read(i));Serial.print(";");}
|
for (int i=1; i<17; i++) {debugSerial.print(dmxin.read(i));debugSerial.print(";");}
|
||||||
|
debugSerial.println();
|
||||||
#endif
|
#endif
|
||||||
Serial.println();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +235,7 @@ void DMXinSetup(int channels)
|
|||||||
DMXin = new uint8_t [channels];
|
DMXin = new uint8_t [channels];
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
DMXSerial.init(DMXReceiver,0,channels);
|
DMXSerial.init(DMXReceiver,0,channels);
|
||||||
if (DMXSerial.getBuffer()) {Serial.print(F("Init in ch:"));Serial.println(channels);} else Serial.println(F("DMXin Buffer alloc err"));
|
if (DMXSerial.getBuffer()) {debugSerial.print(F("Init in ch:"));debugSerial.println(channels);} else debugSerial.println(F("DMXin Buffer alloc err"));
|
||||||
//DMXSerial.maxChannel(channels);
|
//DMXSerial.maxChannel(channels);
|
||||||
DMXSerial.attachOnUpdate(&DMXUpdate);
|
DMXSerial.attachOnUpdate(&DMXUpdate);
|
||||||
#endif
|
#endif
|
||||||
@@ -271,13 +285,16 @@ debugSerial<<F("DMXInterim. Free:")<<freeRam()<<endl;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
volatile int8_t propagateBusy = 0;
|
||||||
void DMXOUT_propagate()
|
void DMXOUT_propagate()
|
||||||
{
|
{
|
||||||
#ifdef DMX_SMOOTH
|
#ifdef DMX_SMOOTH
|
||||||
|
if (propagateBusy) return;
|
||||||
|
propagateBusy++;
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
//if (now<checkTimestamp) return;
|
//if (now<checkTimestamp) return;
|
||||||
if (!isTimeOver(checkTimestamp,now,DMX_SMOOTH_DELAY)) return;
|
if (isTimeOver(checkTimestamp,now,DMX_SMOOTH_DELAY))
|
||||||
|
{
|
||||||
for(int i=1;i<=DMXOUT_Channels;i++)
|
for(int i=1;i<=DMXOUT_Channels;i++)
|
||||||
{
|
{
|
||||||
uint8_t currLevel=dmxout.getTx(i);
|
uint8_t currLevel=dmxout.getTx(i);
|
||||||
@@ -301,6 +318,8 @@ void DMXOUT_propagate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkTimestamp=now;
|
checkTimestamp=now;
|
||||||
|
}
|
||||||
|
propagateBusy--;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,369 +0,0 @@
|
|||||||
help
|
|
||||||
|
|
||||||
Lazyhome.ru LightHub controller 473256d_2021-05-16 C++ version:201103L
|
|
||||||
|
|
||||||
(+)WATCHDOG
|
|
||||||
Config server:lazyhome.ru
|
|
||||||
Firmware MAC Address CUSTOM_FIRMWARE_MAC
|
|
||||||
(+)FreeRam printing
|
|
||||||
(+)DS2482-100
|
|
||||||
(+)Wiznet5x00
|
|
||||||
(+)DMX
|
|
||||||
(+)ADAFRUIT LED
|
|
||||||
(+)MODBUS
|
|
||||||
(+)OWIRE
|
|
||||||
(+)DHT
|
|
||||||
(+)COUNTER
|
|
||||||
(-)HARDRESET, using soft
|
|
||||||
(-)RESTART_LAN_ON_MQTT_ERRORS
|
|
||||||
(+)CCS811 & HDC1080
|
|
||||||
(+)AC HAIER
|
|
||||||
(+)MOTOR CTR
|
|
||||||
(+)SPI LED
|
|
||||||
(+)OTA
|
|
||||||
(+)ARTNET
|
|
||||||
(+)MCP23017
|
|
||||||
(+)PID
|
|
||||||
(+)SYSLOG
|
|
||||||
Reading 128 bits unique identifier
|
|
||||||
ID: 51203120383830503130313232313035
|
|
||||||
Current LAN config(ip,dns,gw,subnet):192.168.11.172, 192.168.11.1, 255.255.255.0,
|
|
||||||
Use these commands: 'help' - this text
|
|
||||||
'mac de:ad:be:ef:fe:00' set and store MAC-address in EEPROM
|
|
||||||
'ip [ip[,dns[,gw[,subnet]]]]' - set static IP
|
|
||||||
'save' - save config in NVRAM
|
|
||||||
'get' [config addr]' - get config from pre-configured URL and store addr
|
|
||||||
'load' - load config from NVRAM
|
|
||||||
'pwd' - define MQTT password
|
|
||||||
'kill' - test watchdog
|
|
||||||
'clear' - clear EEPROM
|
|
||||||
'reboot' - reboot controller
|
|
||||||
>>
|
|
||||||
|
|
||||||
|
|
||||||
thermostat inactive Set:33.00 Cur:0.00 cmd:2 Expired
|
|
||||||
|
|
||||||
RAM=41128 thermostat inactive Set:33.00 Cur:0.00 cmd:2 Expired
|
|
||||||
|
|
||||||
RAM=41128 load
|
|
||||||
Loading Config from EEPROM
|
|
||||||
No stored config
|
|
||||||
|
|
||||||
>>
|
|
||||||
thermostat inactive Set:33.00 Cur:0.00 cmd:2 Expired
|
|
||||||
|
|
||||||
RAM=41128 get
|
|
||||||
Default config server used: lazyhome.ru
|
|
||||||
Config URI: http://lazyhome.ru/cnf/de-71-d1-a2-92-96.config.json
|
|
||||||
HTTP Status code: 200
|
|
||||||
GET Response: {
|
|
||||||
"mqtt":["edem3","192.168.88.2"],
|
|
||||||
"syslog":["192.168.88.2"],
|
|
||||||
"dmx":[3,80],
|
|
||||||
"topics":{"root":"edem"},
|
|
||||||
"items":
|
|
||||||
{
|
|
||||||
"lightall":[7,[
|
|
||||||
"lampbedr3",
|
|
||||||
"lampcab31",
|
|
||||||
"lampcab32",
|
|
||||||
"lampsauna3",
|
|
||||||
"lampbath33",
|
|
||||||
"lampktc3",
|
|
||||||
"lampwc3",
|
|
||||||
"lamp4",
|
|
||||||
"lampext4",
|
|
||||||
"lamphall3",
|
|
||||||
"lampstw3",
|
|
||||||
"fasadeast",
|
|
||||||
"bra31",
|
|
||||||
"lampgst3",
|
|
||||||
"lampkln3",
|
|
||||||
"lampbalk3",
|
|
||||||
"fasadsouth",
|
|
||||||
"bra32"]],
|
|
||||||
"gr_hall3":[7,["lamphall3","lampstw3","lampwc3"]],
|
|
||||||
"gr_gost3":[7,["lampgst3","lampktc3"]],
|
|
||||||
"gr_kab3":[7,["lampcab31","lampcab32"]],
|
|
||||||
"relays":[7,["pout0","thermostat","pout2","pout3","pout4","pout5","pout6"]],
|
|
||||||
"uouts":[7,["unprot0","unprot1","unprot2","unprot3","unprot4","unprot5","unprot6","unprot7"]],
|
|
||||||
|
|
||||||
"mb1":[44,[1,0,3,100]],
|
|
||||||
"mb2":[44,[1,1,3,100]],
|
|
||||||
"mb3":[44,[1,2,3,100]],
|
|
||||||
"mb4":[44,[1,3,3,100]],
|
|
||||||
"mba":[44,[96,0,0]],
|
|
||||||
|
|
||||||
"lampbedr3":[0,3],
|
|
||||||
"lampcab31":[0,9],
|
|
||||||
"lampcab32":[0,4],
|
|
||||||
|
|
||||||
"lampsauna3":[0,11],
|
|
||||||
"lampbath3":[0,5],
|
|
||||||
"lampwc3":[0,2],
|
|
||||||
|
|
||||||
"lampktc3":[0,7],
|
|
||||||
"lamp4":[0,8],
|
|
||||||
"lamphall3":[0,1],
|
|
||||||
|
|
||||||
"lampext4":[0,10],
|
|
||||||
"lampstw3":[0,6],
|
|
||||||
"fasadeast":[0,12],
|
|
||||||
|
|
||||||
"lampgst3":[0,13],
|
|
||||||
"bra31":[0,14],
|
|
||||||
"bra32":[0,15],
|
|
||||||
|
|
||||||
"lampbalk3":[0,16],
|
|
||||||
"fasadsouth":[0,17],
|
|
||||||
"lampkln3":[0,18],
|
|
||||||
"lampbar3":[0,21],
|
|
||||||
|
|
||||||
"ledbedr3":[1,22],
|
|
||||||
"ledcab31":[1,26],
|
|
||||||
"ledcab32":[1,30],
|
|
||||||
"ledkab":[7,["ledcab31","ledcab32"]],
|
|
||||||
"ledsauna31":[1,34],
|
|
||||||
"ledsauna32":[1,38],
|
|
||||||
"ledsauna":[7,["ledsauna31","ledsauna32"]],
|
|
||||||
"led4":[1,42],
|
|
||||||
|
|
||||||
"ledktc31":[1,48],
|
|
||||||
"ledktc31w":[0,52],
|
|
||||||
"ledktc32":[1,53],
|
|
||||||
"ledktc32w":[0,57],
|
|
||||||
"ledgst31":[1,58],
|
|
||||||
"ledgst31w":[0,62],
|
|
||||||
"ledgst32":[1,63],
|
|
||||||
"ledgst32w":[0,67],
|
|
||||||
"ledktc3w":[7,["ledktc31w","ledktc32w","ledgst31w","ledgst32w"]],
|
|
||||||
"ledktc3":[7,["ledktc31","ledktc32","ledgst31","ledgst32"]],
|
|
||||||
|
|
||||||
"fanbath3":[0,68],
|
|
||||||
"fanwc3":[0,69],
|
|
||||||
|
|
||||||
"pout0":[6,22],
|
|
||||||
"thermostat":[5,23,33],
|
|
||||||
"pout2":[6,24],
|
|
||||||
"water3":[6,25],
|
|
||||||
"pout4":[3,9],
|
|
||||||
"pout5":[3,8],
|
|
||||||
"pout6":[3,11],
|
|
||||||
"pout7":[6,12],
|
|
||||||
|
|
||||||
|
|
||||||
"pwm0" :[3,4],
|
|
||||||
"pwm1" :[3,5],
|
|
||||||
"pwm2" :[3,6],
|
|
||||||
"pwm3" :[3,7],
|
|
||||||
"pwm10":[3,10],
|
|
||||||
|
|
||||||
|
|
||||||
"unprot0":[6,33],
|
|
||||||
"unprot1":[6,32],
|
|
||||||
"unprot2":[6,31],
|
|
||||||
"unprot3":[6,30],
|
|
||||||
"unprot4":[6,29],
|
|
||||||
"unprot5":[6,28],
|
|
||||||
"unprot6":[6,27],
|
|
||||||
"unprot7":[6,26]
|
|
||||||
},
|
|
||||||
|
|
||||||
"in":
|
|
||||||
[ {"#":42,"emit":"power3","item":"fanwc3"},
|
|
||||||
{"#":44,"emit":"in1"},
|
|
||||||
{"#":46,"emit":"in2"},
|
|
||||||
{"#":49,"emit":"in3"},
|
|
||||||
{"#":43,"emit":"in4"},
|
|
||||||
{"#":45,"emit":"in5"},
|
|
||||||
{"#":47,"emit":"in6"},
|
|
||||||
{"#":48,"emit":"in7"},
|
|
||||||
{"#":34,"emit":"in8"},
|
|
||||||
{"#":36,"emit":"in9"},
|
|
||||||
|
|
||||||
{"#":38,"T":0,
|
|
||||||
"click":{"item":"gr_hall3","icmd":"80"},
|
|
||||||
"dclick":{"item":"lampbedr3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lightall","icmd":"REST"},
|
|
||||||
"rpcmd":{"item":"gr_hall3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
{"#":40,"T":0,
|
|
||||||
"click":{"item":"gr_hall3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"lampbedr3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lightall","icmd":"HALT"},
|
|
||||||
"rpcmd":{"item":"gr_hall3","icmd":"%-2"}
|
|
||||||
},
|
|
||||||
{"#":35,"T":0,
|
|
||||||
"click":{"item":"gr_gost3","icmd":"ON"},
|
|
||||||
"dclick":{"item":"gr_kab3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"ON"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
{"#":37,"T":0,
|
|
||||||
"click":{"item":"gr_gost3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"gr_kab3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
|
||||||
},
|
|
||||||
|
|
||||||
{"#":39,"emit":"in14"},
|
|
||||||
{"#":41,"emit":"in15"},
|
|
||||||
|
|
||||||
{"#":54,"T":0,"act":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"map":[128,640],
|
|
||||||
"click":{"item":"gr_gost3","icmd":"ON"},
|
|
||||||
"dclick":{"item":"gr_kab3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"ON"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"map":[641,1024],
|
|
||||||
"click":{"item":"gr_gost3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"gr_kab3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
|
||||||
}
|
|
||||||
]},
|
|
||||||
{"#":55,"T":66,"emit":"a01","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
{"#":56,"T":66,"emit":"a02","map":[0,1024,0,1024,10]},
|
|
||||||
{"#":57,"T":66,"emit":"a03","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
{"#":58,"T":66,"emit":"a04","map":[0,1024,0,1024,10]},
|
|
||||||
{"#":59,"T":66,"emit":"a05","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
{"#":60,"T":0,"act":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"map":[128,640],
|
|
||||||
"click":{"item":"gr_hall3","icmd":"50"},
|
|
||||||
"dclick":{"item":"lampbedr3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lightall","icmd":"REST"},
|
|
||||||
"rpcmd":{"item":"gr_hall3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"map":[641,1024],
|
|
||||||
"click":{"item":"gr_hall3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"lampbedr3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lightall","icmd":"HALT"},
|
|
||||||
"rpcmd":{"item":"gr_hall3","icmd":"%-2"}
|
|
||||||
}
|
|
||||||
]},
|
|
||||||
{"#":61,"T":0,"act":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"map":[128,640],
|
|
||||||
"click":{"item":"gr_gost3","icmd":"ON"},
|
|
||||||
"dclick":{"item":"gr_kab3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"ON"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"map":[641,1024],
|
|
||||||
"click":{"item":"gr_gost3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"gr_kab3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
|
||||||
}
|
|
||||||
]},
|
|
||||||
|
|
||||||
{"#":62,"T":66,"emit":"a08","map":[0,1024,0,1024,10]},
|
|
||||||
{"#":63,"T":66,"emit":"a09","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
{"#":64,"T":66,"emit":"a10","map":[0,1024,0,1024,10]},
|
|
||||||
{"#":65,"T":66,"emit":"a11","map":[0,1024,0,1024,10]},
|
|
||||||
{"#":66,"T":0,"emit":"leak31","item":"water3","scmd":"OFF","rcmd":"ON"},
|
|
||||||
{"#":67,"T":2,"emit":"leak32","item":"water3","scmd":"OFF","rcmd":"ON"},
|
|
||||||
{"#":68,"T":0,"emit":"leak33","item":"water3","scmd":"OFF","rcmd":"ON"},
|
|
||||||
{"#":69,"T":0,"emit":"a15"}
|
|
||||||
],
|
|
||||||
|
|
||||||
"in2":
|
|
||||||
{ "42":{"emit":"power3","item":"fanwc3"},
|
|
||||||
"44":{"emit":"in1"},
|
|
||||||
"46":{"emit":"in2"},
|
|
||||||
"49":{"emit":"in3"},
|
|
||||||
"43":{"emit":"in4"},
|
|
||||||
"45":{"emit":"in5"},
|
|
||||||
"47":{"emit":"in6"},
|
|
||||||
"48":{"emit":"in7"},
|
|
||||||
"34":{"emit":"in8"},
|
|
||||||
"36":{"emit":"in9"},
|
|
||||||
|
|
||||||
"38":{"T":0,
|
|
||||||
"click":{"item":"gr_hall3","icmd":"ON"},
|
|
||||||
"dclick":{"item":"lampbedr3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lightall","icmd":"REST"},
|
|
||||||
"rpcmd":{"item":"gr_hall3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
"40":{"T":0,
|
|
||||||
"click":{"item":"gr_hall3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"lampbedr3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lightall","icmd":"HALT"},
|
|
||||||
"rpcmd":{"item":"gr_hall3","icmd":"%-2"}
|
|
||||||
},
|
|
||||||
"35":{"T":0,
|
|
||||||
"click":{"item":"gr_gost3","icmd":"ON"},
|
|
||||||
"dclick":{"item":"lampwc3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"ON"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
"37":{"T":0,
|
|
||||||
"click":{"item":"gr_gost3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
|
||||||
},
|
|
||||||
|
|
||||||
"39":{"emit":"in14"},
|
|
||||||
"41":{"emit":"in15"},
|
|
||||||
|
|
||||||
"54":{"addr":54,"T":0,"act":
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"map":[128,640],
|
|
||||||
"click":{"item":"gr_gost3","icmd":"ON"},
|
|
||||||
"dclick":{"item":"lampwc3","icmd":"ON"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"ON"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"map":[641,1024],
|
|
||||||
"click":{"item":"gr_gost3","icmd":"OFF"},
|
|
||||||
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
|
||||||
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
|
||||||
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
|
||||||
}
|
|
||||||
]},
|
|
||||||
"55":{"T":66,"emit":"a01","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
"56":{"T":66,"emit":"a02","map":[0,1024,0,1024,10]},
|
|
||||||
"57":{"T":66,"emit":"a03","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
"58":{"T":66,"emit":"a04","map":[0,1024,0,1024,10]},
|
|
||||||
"59":{"T":66,"emit":"a05","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
"60":{"T":66,"emit":"a06","map":[0,1024,0,1024,10]},
|
|
||||||
"61":{"T":66,"emit":"a07","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
"62":{"T":66,"emit":"a08","map":[0,1024,0,1024,10]},
|
|
||||||
"63":{"T":66,"emit":"a09","map":[0,1024,0,1024,10]},
|
|
||||||
|
|
||||||
"64":{"T":66,"emit":"a10","map":[0,1024,0,1024,10]},
|
|
||||||
"65":{"T":66,"emit":"a11","map":[0,1024,0,1024,10]},
|
|
||||||
"66":{"T":0,"emit":"leak31","item":"water3","scmd":"OFF","rcmd":"ON"},
|
|
||||||
"67":{"T":2,"emit":"leak32","item":"water3","scmd":"OFF","rcmd":"ON"},
|
|
||||||
"68":{"T":0,"emit":"leak33","item":"water3","scmd":"OFF","rcmd":"ON"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Free:29320
|
|
||||||
Unlocking config ...
|
|
||||||
|
|
||||||
Default config server used: lazyhome.ru
|
|
||||||
Config URI: http://lazyhome.ru/cnf/de-71-d1-a2-92-96.config.json
|
|
||||||
HTTP Status code>>>
|
|
||||||
Lazyhome.ru LightHub controller 473256d_2021-05-16 C++ version:201103L
|
|
||||||
|
|
||||||
(+)WATCHDOG
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
#include "options.h"
|
|
||||||
#ifdef __ESP__
|
|
||||||
#include "esp.h"
|
|
||||||
|
|
||||||
ESP8266WiFiMulti wifiMulti;
|
|
||||||
WiFiClient ethClient;
|
|
||||||
|
|
||||||
char mqtt_password[16];
|
|
||||||
|
|
||||||
//default custom static IP
|
|
||||||
//char static_ip[16] = "10.0.1.56";
|
|
||||||
//char static_gw[16] = "10.0.1.1";
|
|
||||||
//char static_sn[16] = "255.255.255.0";
|
|
||||||
|
|
||||||
//flag for saving data
|
|
||||||
bool shouldSaveConfig = false;
|
|
||||||
|
|
||||||
//callback notifying us of the need to save config
|
|
||||||
void saveConfigCallback () {
|
|
||||||
Serial.println(F("Should save config"));
|
|
||||||
shouldSaveConfig = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void espSetup () {
|
|
||||||
Serial.println(F("Setting up Wifi"));
|
|
||||||
shouldSaveConfig = true;
|
|
||||||
//WiFiManager
|
|
||||||
|
|
||||||
WiFiManagerParameter custom_mqtt_password("", "mqtt password", mqtt_password, 16);
|
|
||||||
//Local intialization. Once its business is done, there is no need to keep it around
|
|
||||||
WiFiManager wifiManager;
|
|
||||||
|
|
||||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
|
||||||
|
|
||||||
wifiManager.addParameter(&custom_mqtt_password);
|
|
||||||
wifiManager.setMinimumSignalQuality();
|
|
||||||
|
|
||||||
if (!wifiManager.autoConnect()) {
|
|
||||||
Serial.println(F("failed to connect and hit timeout"));
|
|
||||||
delay(3000);
|
|
||||||
//reset and try again, or maybe put it to deep sleep
|
|
||||||
ESP.reset();
|
|
||||||
delay(5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if you get here you have connected to the WiFi
|
|
||||||
Serial.println(F("connected...yeey :)"));
|
|
||||||
|
|
||||||
//read updated parameters
|
|
||||||
strcpy(mqtt_password, custom_mqtt_password.getValue());
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#include <ESP8266WiFi.h>
|
|
||||||
//needed for library
|
|
||||||
#include <DNSServer.h>
|
|
||||||
#include <ESP8266WebServer.h>
|
|
||||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
|
||||||
#include <ESP8266WiFiMulti.h>
|
|
||||||
|
|
||||||
extern ESP8266WiFiMulti wifiMulti;
|
|
||||||
extern WiFiClient ethClient;
|
|
||||||
//WiFiManager wifiManager;
|
|
||||||
|
|
||||||
//define your default values here, if there are different values in config.json, they are overwritten.
|
|
||||||
//length should be max size + 1
|
|
||||||
extern char mqtt_password[16];
|
|
||||||
|
|
||||||
//default custom static IP
|
|
||||||
//char static_ip[16] = "10.0.1.56";
|
|
||||||
//char static_gw[16] = "10.0.1.1";
|
|
||||||
//char static_sn[16] = "255.255.255.0";
|
|
||||||
|
|
||||||
//flag for saving data
|
|
||||||
extern bool shouldSaveConfig;
|
|
||||||
|
|
||||||
void espSetup ();
|
|
||||||
@@ -68,6 +68,7 @@ flashStream(String _filename):seekableStream(65535)
|
|||||||
virtual unsigned int seek(unsigned int _pos = 0){return fs.seek(_pos,SeekSet);};
|
virtual unsigned int seek(unsigned int _pos = 0){return fs.seek(_pos,SeekSet);};
|
||||||
virtual void flush() {return fs.flush();};
|
virtual void flush() {return fs.flush();};
|
||||||
virtual size_t write(uint8_t ch) {return fs.write(ch);};
|
virtual size_t write(uint8_t ch) {return fs.write(ch);};
|
||||||
|
using Print::write;
|
||||||
void putEOF(){write (255);};
|
void putEOF(){write (255);};
|
||||||
virtual ~flashStream () {if (fs) fs.close();} ;
|
virtual ~flashStream () {if (fs) fs.close();} ;
|
||||||
};
|
};
|
||||||
@@ -95,7 +96,7 @@ flashStream(unsigned int _startPos=0, unsigned int _size=4096 ):seekableStream(_
|
|||||||
|
|
||||||
virtual unsigned int seek(unsigned int _pos = 0)
|
virtual unsigned int seek(unsigned int _pos = 0)
|
||||||
{ pos=min(startPos+_pos, startPos+streamSize);
|
{ pos=min(startPos+_pos, startPos+streamSize);
|
||||||
debugSerial<<F("Seek:")<<pos<<endl;
|
//debugSerial<<F("Seek:")<<pos<<endl;
|
||||||
return pos;
|
return pos;
|
||||||
};
|
};
|
||||||
virtual int available() { return (pos<streamSize);};
|
virtual int available() { return (pos<streamSize);};
|
||||||
@@ -117,19 +118,9 @@ flashStream(unsigned int _startPos=0, unsigned int _size=4096 ):seekableStream(_
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
virtual size_t write(const uint8_t *buffer, size_t size) override
|
|
||||||
{
|
|
||||||
debugSerial<<("Write from:")<<pos<<" "<<size<<" bytes"<<endl;
|
|
||||||
EEPROM.write(pos,(byte*)buffer,size);
|
|
||||||
pos+=size;
|
|
||||||
return size;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
virtual size_t write(uint8_t ch)
|
virtual size_t write(uint8_t ch)
|
||||||
{
|
{
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
//Serial.print (ch);
|
|
||||||
EEPROM.update(pos++,(char)ch);
|
EEPROM.update(pos++,(char)ch);
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
@@ -139,6 +130,18 @@ flashStream(unsigned int _startPos=0, unsigned int _size=4096 ):seekableStream(_
|
|||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
|
virtual size_t write(const uint8_t *buffer, size_t size) override
|
||||||
|
{
|
||||||
|
//debugSerial<<("Write from:")<<pos<<" "<<size<<" bytes"<<endl;
|
||||||
|
EEPROM.write(pos,(byte*)buffer,size);
|
||||||
|
pos+=size;
|
||||||
|
return size;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
using Print::write;//(const uint8_t *buffer, size_t size);
|
||||||
|
#endif
|
||||||
void putEOF(){write (255);
|
void putEOF(){write (255);
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
|
|||||||
@@ -300,9 +300,9 @@ void Input::counterPoll() {
|
|||||||
short real_pin = mega_interrupt_array[interrupt_number];
|
short real_pin = mega_interrupt_array[interrupt_number];
|
||||||
attachInterruptPinIrq(real_pin,interrupt_number);
|
attachInterruptPinIrq(real_pin,interrupt_number);
|
||||||
} else {
|
} else {
|
||||||
Serial.print(F("IRQ:"));
|
debugSerial.print(F("IRQ:"));
|
||||||
Serial.print(pin);
|
debugSerial.print(pin);
|
||||||
Serial.print(F(" Counter type. INCORRECT Interrupt number!!!"));
|
debugSerial.print(F(" Counter type. INCORRECT Interrupt number!!!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -365,7 +365,7 @@ void Input::attachInterruptPinIrq(int realPin, int irq) {
|
|||||||
attachInterrupt(real_irq, onCounterChanged5, RISING);
|
attachInterrupt(real_irq, onCounterChanged5, RISING);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Serial.print(F("Incorrect irq:"));Serial.println(irq);
|
debugSerial.print(F("Incorrect irq:"));debugSerial.println(irq);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -653,6 +653,7 @@ return false;
|
|||||||
//Main routine to control Item
|
//Main routine to control Item
|
||||||
int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
||||||
{
|
{
|
||||||
|
uint32_t time=millis();
|
||||||
int suffixCode = cmd.getSuffix();
|
int suffixCode = cmd.getSuffix();
|
||||||
bool operation = isNotRetainingStatus();
|
bool operation = isNotRetainingStatus();
|
||||||
|
|
||||||
@@ -730,7 +731,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
|||||||
toExecute=true;
|
toExecute=true;
|
||||||
scale100=true; //openHab topic format
|
scale100=true; //openHab topic format
|
||||||
chActive=(isActive()>0);
|
chActive=(isActive()>0);
|
||||||
|
debugSerial<<chActive<<" "<<cmd.getInt()<<endl;
|
||||||
if (chActive>0 && !cmd.getInt()) {cmd.Cmd(CMD_OFF);status2Send |= SEND_COMMAND | SEND_IMMEDIATE;}
|
if (chActive>0 && !cmd.getInt()) {cmd.Cmd(CMD_OFF);status2Send |= SEND_COMMAND | SEND_IMMEDIATE;}
|
||||||
if (chActive==0 && cmd.getInt()) {cmd.Cmd(CMD_ON);status2Send |= SEND_COMMAND | SEND_IMMEDIATE;}
|
if (chActive==0 && cmd.getInt()) {cmd.Cmd(CMD_ON);status2Send |= SEND_COMMAND | SEND_IMMEDIATE;}
|
||||||
|
|
||||||
@@ -1132,7 +1133,7 @@ switch (itemType) {
|
|||||||
if (command2Set) setCmd(command2Set | SEND_COMMAND);
|
if (command2Set) setCmd(command2Set | SEND_COMMAND);
|
||||||
if (operation) SendStatus(status2Send);
|
if (operation) SendStatus(status2Send);
|
||||||
|
|
||||||
debugSerial<<F("Ctrl Res:")<<res<<endl;
|
debugSerial<<F("Ctrl Res:")<<res<<F(" time:")<<millis()-time<<endl;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,9 @@ itemCmd itemCmd::assignFrom(itemCmd from, short chanType)
|
|||||||
setColorTemp(t);
|
setColorTemp(t);
|
||||||
}
|
}
|
||||||
cmd.suffixCode=from.cmd.suffixCode;
|
cmd.suffixCode=from.cmd.suffixCode;
|
||||||
|
cmd.cmdCode=from.cmd.cmdCode;
|
||||||
|
//cmd.cmdFlag
|
||||||
|
//cmd.cmdParam
|
||||||
|
|
||||||
switch (cmd.itemArgType){ //Destination
|
switch (cmd.itemArgType){ //Destination
|
||||||
case ST_HSV255:
|
case ST_HSV255:
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
void setup(){
|
void setup()
|
||||||
//if (millis()>1000)
|
{
|
||||||
setup_main();
|
setup_main();
|
||||||
//else Serial.println("Hello");
|
|
||||||
//delay(1000);
|
|
||||||
}
|
}
|
||||||
void loop(){
|
void loop()
|
||||||
//if (millis()>10000)
|
{
|
||||||
loop_main();
|
loop_main();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,25 +64,6 @@ EthernetClient ethClient;
|
|||||||
MDNS mdns(mdnsUDP);
|
MDNS mdns(mdnsUDP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
DueFlashStorage EEPROM;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
|
||||||
NRFFlashStorage EEPROM;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_STM32
|
|
||||||
NRFFlashStorage EEPROM;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NRF5
|
|
||||||
NRFFlashStorage EEPROM;
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
#include <Syslog.h>
|
#include <Syslog.h>
|
||||||
|
|
||||||
@@ -138,12 +119,12 @@ aJsonObject *dmxArr = NULL;
|
|||||||
bool syslogInitialized = false;
|
bool syslogInitialized = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t timerPollingCheck = 0;
|
volatile uint32_t timerPollingCheck = 0;
|
||||||
uint32_t timerInputCheck = 0;
|
volatile uint32_t timerInputCheck = 0;
|
||||||
uint32_t timerLanCheckTime = 0;
|
volatile uint32_t timerLanCheckTime = 0;
|
||||||
uint32_t timerThermostatCheck = 0;
|
volatile uint32_t timerThermostatCheck = 0;
|
||||||
uint32_t timerSensorCheck =0;
|
volatile uint32_t timerSensorCheck =0;
|
||||||
uint32_t WiFiAwaitingTime =0;
|
volatile uint32_t WiFiAwaitingTime =0;
|
||||||
|
|
||||||
aJsonObject *pollingItem = NULL;
|
aJsonObject *pollingItem = NULL;
|
||||||
|
|
||||||
@@ -269,7 +250,7 @@ int httpHandler(Client& client, String request, long contentLength, bool authori
|
|||||||
if (!item.isValid() || !item.Ctrl((char*) body.c_str())) return 400;
|
if (!item.isValid() || !item.Ctrl((char*) body.c_str())) return 400;
|
||||||
|
|
||||||
itemCmd ic;
|
itemCmd ic;
|
||||||
ic.loadItem(&item,true);
|
ic.loadItem(&item,SEND_COMMAND|SEND_PARAMETERS);
|
||||||
char buf[32];
|
char buf[32];
|
||||||
response=ic.toString(buf, sizeof(buf));
|
response=ic.toString(buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
@@ -280,7 +261,7 @@ int httpHandler(Client& client, String request, long contentLength, bool authori
|
|||||||
if (!item.isValid()) return 400;
|
if (!item.isValid()) return 400;
|
||||||
|
|
||||||
itemCmd ic;
|
itemCmd ic;
|
||||||
ic.loadItem(&item,true);
|
ic.loadItem(&item,SEND_COMMAND|SEND_PARAMETERS);
|
||||||
char buf[32];
|
char buf[32];
|
||||||
response=ic.toString(buf, sizeof(buf));
|
response=ic.toString(buf, sizeof(buf));
|
||||||
|
|
||||||
@@ -424,8 +405,15 @@ if (element && element->type == aJson_String) return element->valuestring;
|
|||||||
|
|
||||||
#ifdef OTA
|
#ifdef OTA
|
||||||
void setupOTA(void)
|
void setupOTA(void)
|
||||||
|
{ char passwordBuf[16];
|
||||||
|
if (!sysConf.getOTApwd(passwordBuf, sizeof(passwordBuf)))
|
||||||
{
|
{
|
||||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage, sysConfStream, JSONStream);
|
strcpy(passwordBuf,"password");
|
||||||
|
errorSerial<<F("DEFAULT password for OTA API. Use otapwd command to set")<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
debugSerial<<passwordBuf<<endl;
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", passwordBuf, InternalStorage, sysConfStream, JSONStream);
|
||||||
ArduinoOTA.setCustomHandler(httpHandler);
|
ArduinoOTA.setCustomHandler(httpHandler);
|
||||||
infoSerial<<F("OTA initialized\n");
|
infoSerial<<F("OTA initialized\n");
|
||||||
|
|
||||||
@@ -838,12 +826,12 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
//strncpy_P(buf, inprefix, sizeof(buf));
|
//strncpy_P(buf, inprefix, sizeof(buf));
|
||||||
setTopic(buf,sizeof(buf),T_BCST);
|
setTopic(buf,sizeof(buf),T_BCST);
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "#", sizeof(buf));
|
||||||
Serial.println(buf);
|
debugSerial.println(buf);
|
||||||
mqttClient.subscribe(buf);
|
mqttClient.subscribe(buf);
|
||||||
|
|
||||||
setTopic(buf,sizeof(buf),T_DEV);
|
setTopic(buf,sizeof(buf),T_DEV);
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "#", sizeof(buf));
|
||||||
Serial.println(buf);
|
debugSerialPort.println(buf);
|
||||||
mqttClient.subscribe(buf);
|
mqttClient.subscribe(buf);
|
||||||
|
|
||||||
onMQTTConnect();
|
onMQTTConnect();
|
||||||
@@ -966,6 +954,8 @@ if (WiFi.status() == WL_CONNECTED) {
|
|||||||
infoSerial<<F("Got IP address:");
|
infoSerial<<F("Got IP address:");
|
||||||
printIPAddress(Ethernet.localIP());
|
printIPAddress(Ethernet.localIP());
|
||||||
lanStatus = HAVE_IP_ADDRESS;
|
lanStatus = HAVE_IP_ADDRESS;
|
||||||
|
}
|
||||||
|
}//DHCP
|
||||||
|
|
||||||
#ifdef MDNS_ENABLE
|
#ifdef MDNS_ENABLE
|
||||||
#ifndef OTA_PORT
|
#ifndef OTA_PORT
|
||||||
@@ -973,20 +963,15 @@ if (WiFi.status() == WL_CONNECTED) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mdns.begin(Ethernet.localIP(), "lighthub");
|
mdns.begin(Ethernet.localIP(), "lighthub");
|
||||||
mdns.addServiceRecord(("LightHub controller._http"),
|
|
||||||
OTA_PORT,
|
|
||||||
MDNSServiceTCP);
|
|
||||||
|
|
||||||
mdns.addServiceRecord("Lighthub TXT"
|
|
||||||
"._http",
|
|
||||||
OTA_PORT,
|
|
||||||
MDNSServiceTCP,
|
|
||||||
"\x7path=/2");
|
|
||||||
|
|
||||||
|
char txtRecord[32] = "\x7mac=";
|
||||||
|
SetBytes(sysConf.mac,6,txtRecord+5);
|
||||||
|
char mdnsName[32] = "LightHub";
|
||||||
|
SetBytes(sysConf.mac+4,2,mdnsName+8);
|
||||||
|
strncat(mdnsName,"._http",sizeof(mdnsName));
|
||||||
|
mdns.addServiceRecord(mdnsName, OTA_PORT, MDNSServiceTCP, txtRecord);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,10 +1055,12 @@ void cmdFunctionHelp(int arg_cnt, char **args)
|
|||||||
infoSerial<<F("\nUse these commands: 'help' - this text\n"
|
infoSerial<<F("\nUse these commands: 'help' - this text\n"
|
||||||
"'mac de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
|
"'mac de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
|
||||||
"'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n"
|
"'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n"
|
||||||
"'save' - save config in NVRAM\n"
|
"'save' - save current config in NVRAM; ON|OFF - enable/disable autosave\n"
|
||||||
"'get' [config addr]' - get config from pre-configured URL and store addr\n"
|
"'get' [config addr]' - get config from pre-configured URL and store addr, ON|OFF - enable/disable download on startup\n"
|
||||||
"'load' - load config from NVRAM\n"
|
"'load' - load config from NVRAM\n"
|
||||||
"'pwd' - define MQTT password\n"
|
"'pwd' - define and store MQTT password\n"
|
||||||
|
"'otapwd' - define and store HTTP API password\n"
|
||||||
|
"'log [serial_loglevel] [udp_loglevel]' - define log level (0..7)\n"
|
||||||
"'kill' - test watchdog\n"
|
"'kill' - test watchdog\n"
|
||||||
"'clear' - clear EEPROM\n"
|
"'clear' - clear EEPROM\n"
|
||||||
"'reboot' - reboot controller");
|
"'reboot' - reboot controller");
|
||||||
@@ -1081,9 +1068,12 @@ void cmdFunctionHelp(int arg_cnt, char **args)
|
|||||||
void printCurentLanConfig() {
|
void printCurentLanConfig() {
|
||||||
infoSerial << F("Current LAN config(ip,dns,gw,subnet):");
|
infoSerial << F("Current LAN config(ip,dns,gw,subnet):");
|
||||||
printIPAddress(Ethernet.localIP());
|
printIPAddress(Ethernet.localIP());
|
||||||
// printIPAddress(Ethernet.dnsServerIP());
|
#if not defined(ESP8266) and not defined(ESP32)
|
||||||
|
printIPAddress(Ethernet.dnsServerIP());
|
||||||
|
#endif
|
||||||
printIPAddress(Ethernet.gatewayIP());
|
printIPAddress(Ethernet.gatewayIP());
|
||||||
printIPAddress(Ethernet.subnetMask());
|
printIPAddress(Ethernet.subnetMask());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionKill(int arg_cnt, char **args) {
|
void cmdFunctionKill(int arg_cnt, char **args) {
|
||||||
@@ -1262,12 +1252,16 @@ int loadConfigFromEEPROM()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
|
||||||
|
|
||||||
//#define saveBufLen 16000
|
|
||||||
void cmdFunctionSave(int arg_cnt, char **args)
|
void cmdFunctionSave(int arg_cnt, char **args)
|
||||||
{
|
{
|
||||||
|
if (arg_cnt>1)
|
||||||
|
{
|
||||||
|
if (!strcasecmp_P(args[1],ON_P)) sysConf.setSaveSuccedConfig(true);
|
||||||
|
if (!strcasecmp_P(args[1],OFF_P)) sysConf.setSaveSuccedConfig(false);
|
||||||
|
infoSerial<<F("Config autosave:")<<sysConf.getSaveSuccedConfig()<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
char* outBuf = (char*) malloc(MAX_JSON_CONF_SIZE); /* XXX: Dynamic size. */
|
char* outBuf = (char*) malloc(MAX_JSON_CONF_SIZE); /* XXX: Dynamic size. */
|
||||||
if (outBuf == NULL)
|
if (outBuf == NULL)
|
||||||
{
|
{
|
||||||
@@ -1278,32 +1272,36 @@ void cmdFunctionSave(int arg_cnt, char **args)
|
|||||||
aJson.print(root, &stringStream);
|
aJson.print(root, &stringStream);
|
||||||
int len = strlen(outBuf);
|
int len = strlen(outBuf);
|
||||||
outBuf[len++]= EOF;
|
outBuf[len++]= EOF;
|
||||||
|
|
||||||
//EEPROM.write(EEPROM_offsetJSON,(byte*) outBuf,len);
|
|
||||||
JSONStream.seek();
|
JSONStream.seek();
|
||||||
size_t res = JSONStream.write((byte*) outBuf,len);
|
size_t res = JSONStream.write((byte*) outBuf,len);
|
||||||
free (outBuf);
|
free (outBuf);
|
||||||
infoSerial<<res<< F("bytes from ")<<len<<F(" are saved to EEPROM")<<endl;
|
infoSerial<<res<< F("bytes from ")<<len<<F(" are saved to EEPROM")<<endl;
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
void cmdFunctionSave(int arg_cnt, char **args)
|
|
||||||
{
|
|
||||||
//aJsonEEPROMStream jsonEEPROMStream = aJsonEEPROMStream(EEPROM_offsetJSON);
|
|
||||||
//flashStream fs = flashStream(EEPROM_offsetJSON);
|
|
||||||
JSONStream.seek();
|
JSONStream.seek();
|
||||||
aJsonStream jsonEEPROMStream = aJsonStream(&JSONStream);
|
aJsonStream jsonEEPROMStream = aJsonStream(&JSONStream);
|
||||||
|
|
||||||
infoSerial<<F("Saving config to EEPROM..");
|
infoSerial<<F("Saving config to EEPROM..");
|
||||||
|
|
||||||
aJson.print(root, &jsonEEPROMStream);
|
aJson.print(root, &jsonEEPROMStream);
|
||||||
JSONStream.putEOF();
|
JSONStream.putEOF();
|
||||||
|
|
||||||
|
|
||||||
infoSerial<<F("Saved to EEPROM")<<endl;
|
infoSerial<<F("Saved to EEPROM")<<endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
void cmdFunctionLoglevel(int arg_cnt, char **args)
|
||||||
|
{
|
||||||
|
if (arg_cnt>1)
|
||||||
|
{
|
||||||
|
serialDebugLevel=atoi(args[1]);
|
||||||
|
sysConf.setSerialDebuglevel(serialDebugLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg_cnt>2)
|
||||||
|
{
|
||||||
|
udpDebugLevel=atoi(args[2]);
|
||||||
|
sysConf.setUdpDebuglevel(udpDebugLevel);
|
||||||
|
}
|
||||||
|
infoSerial<<F("Serial debug level:")<<serialDebugLevel<<F("\nSyslog debug level:")<<udpDebugLevel<<endl;
|
||||||
|
}
|
||||||
|
|
||||||
void cmdFunctionIp(int arg_cnt, char **args)
|
void cmdFunctionIp(int arg_cnt, char **args)
|
||||||
{
|
{
|
||||||
@@ -1367,7 +1365,7 @@ void cmdFunctionPwd(int arg_cnt, char **args)
|
|||||||
if (arg_cnt)
|
if (arg_cnt)
|
||||||
sysConf.setMQTTpwd(args[1]);
|
sysConf.setMQTTpwd(args[1]);
|
||||||
else sysConf.setMQTTpwd();
|
else sysConf.setMQTTpwd();
|
||||||
infoSerial<<F("Password updated\n");
|
infoSerial<<F("MQTT Password updated\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionOTAPwd(int arg_cnt, char **args)
|
void cmdFunctionOTAPwd(int arg_cnt, char **args)
|
||||||
@@ -1375,7 +1373,7 @@ void cmdFunctionOTAPwd(int arg_cnt, char **args)
|
|||||||
if (arg_cnt)
|
if (arg_cnt)
|
||||||
sysConf.setOTApwd(args[1]);
|
sysConf.setOTApwd(args[1]);
|
||||||
else sysConf.setOTApwd();
|
else sysConf.setOTApwd();
|
||||||
infoSerial<<F("Password updated\n");
|
infoSerial<<F("OTA Password updated\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
||||||
@@ -1393,6 +1391,14 @@ void cmdFunctionSetMac(int arg_cnt, char **args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionGet(int arg_cnt, char **args) {
|
void cmdFunctionGet(int arg_cnt, char **args) {
|
||||||
|
if (arg_cnt>1)
|
||||||
|
{
|
||||||
|
if (!strcasecmp_P(args[1],ON_P)) sysConf.setLoadHTTPConfig(true);
|
||||||
|
if (!strcasecmp_P(args[1],OFF_P)) sysConf.setLoadHTTPConfig(false);
|
||||||
|
infoSerial<<F("Loading HTTP config on startup:")<<sysConf.getLoadHTTPConfig()<<endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lanStatus= loadConfigFromHttp(arg_cnt, args);
|
lanStatus= loadConfigFromHttp(arg_cnt, args);
|
||||||
ethClient.stop(); //Refresh MQTT connect to get retained info
|
ethClient.stop(); //Refresh MQTT connect to get retained info
|
||||||
}
|
}
|
||||||
@@ -1613,7 +1619,9 @@ void TimerHandler(void)
|
|||||||
interrupts();
|
interrupts();
|
||||||
timerCount=micros();
|
timerCount=micros();
|
||||||
if (configLoaded && !timerHandlerBusy) inputLoop(CHECK_INTERRUPT);
|
if (configLoaded && !timerHandlerBusy) inputLoop(CHECK_INTERRUPT);
|
||||||
|
#ifdef DMX_SMOOTH
|
||||||
DMXOUT_propagate();
|
DMXOUT_propagate();
|
||||||
|
#endif
|
||||||
timerCount=micros()-timerCount;
|
timerCount=micros()-timerCount;
|
||||||
timerHandlerBusy--;
|
timerHandlerBusy--;
|
||||||
}
|
}
|
||||||
@@ -1633,6 +1641,19 @@ int16_t attachTimer(double microseconds, timerCallback callback, const char* Tim
|
|||||||
|
|
||||||
void setup_main() {
|
void setup_main() {
|
||||||
|
|
||||||
|
#if (SERIAL_BAUD)
|
||||||
|
debugSerialPort.begin(SERIAL_BAUD);
|
||||||
|
#else
|
||||||
|
|
||||||
|
#if not defined (__SAM3X8E__)
|
||||||
|
debugSerialPort.begin();
|
||||||
|
#endif
|
||||||
|
delay(1000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
serialDebugLevel=sysConf.getSerialDebuglevel();
|
||||||
|
udpDebugLevel=sysConf.getUdpDebuglevel();
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
memset(&UniqueID,0,sizeof(UniqueID));
|
memset(&UniqueID,0,sizeof(UniqueID));
|
||||||
#endif
|
#endif
|
||||||
@@ -1943,7 +1964,8 @@ if (!sysConf.getMAC()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupCmdArduino() {
|
void setupCmdArduino() {
|
||||||
cmdInit(uint32_t(SERIAL_BAUD));
|
//cmdInit(uint32_t(SERIAL_BAUD));
|
||||||
|
cmdInit();
|
||||||
debugSerial<<(F(">>>"));
|
debugSerial<<(F(">>>"));
|
||||||
cmdAdd("help", cmdFunctionHelp);
|
cmdAdd("help", cmdFunctionHelp);
|
||||||
cmdAdd("save", cmdFunctionSave);
|
cmdAdd("save", cmdFunctionSave);
|
||||||
@@ -1959,6 +1981,7 @@ void setupCmdArduino() {
|
|||||||
cmdAdd("otapwd", cmdFunctionOTAPwd);
|
cmdAdd("otapwd", cmdFunctionOTAPwd);
|
||||||
cmdAdd("clear",cmdFunctionClearEEPROM);
|
cmdAdd("clear",cmdFunctionClearEEPROM);
|
||||||
cmdAdd("reboot",cmdFunctionReboot);
|
cmdAdd("reboot",cmdFunctionReboot);
|
||||||
|
cmdAdd("log",cmdFunctionLoglevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop_main() {
|
void loop_main() {
|
||||||
@@ -1983,7 +2006,11 @@ void loop_main() {
|
|||||||
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
yield();
|
yield();
|
||||||
if (artnet) artnet->read(); ///hung
|
if (artnet) artnet->read(); ///hung if network not initialized
|
||||||
|
#endif
|
||||||
|
#ifdef MDNS_ENABLE
|
||||||
|
yield();
|
||||||
|
mdns.run();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2011,9 +2038,7 @@ void loop_main() {
|
|||||||
dmxout.update();
|
dmxout.update();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MDNS_ENABLE
|
|
||||||
mdns.run();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void owIdle(void) {
|
void owIdle(void) {
|
||||||
@@ -2044,27 +2069,32 @@ ethernetIdleCount--;
|
|||||||
};
|
};
|
||||||
|
|
||||||
void modbusIdle(void) {
|
void modbusIdle(void) {
|
||||||
|
wdt_res();
|
||||||
statusLED.poll();
|
statusLED.poll();
|
||||||
yield();
|
yield();
|
||||||
cmdPoll();
|
cmdPoll();
|
||||||
wdt_res();
|
yield();
|
||||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
inputLoop(CHECK_INPUT);
|
||||||
|
|
||||||
|
if (lanLoop() > HAVE_IP_ADDRESS)
|
||||||
|
{ // Begin network runners
|
||||||
yield();
|
yield();
|
||||||
mqttClient.loop();
|
mqttClient.loop();
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->read();
|
if (artnet) artnet->read();
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(OTA)
|
||||||
yield();
|
yield();
|
||||||
inputLoop(CHECK_INPUT);
|
ArduinoOTA.poll();
|
||||||
}
|
#endif
|
||||||
#ifdef MDNS_ENABLE
|
#ifdef MDNS_ENABLE
|
||||||
mdns.run();
|
mdns.run();
|
||||||
#endif
|
#endif
|
||||||
|
} //End network runners
|
||||||
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
DMXCheck();
|
DMXCheck();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (_espdmx)
|
#if defined (_espdmx)
|
||||||
dmxout.update();
|
dmxout.update();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -261,6 +261,8 @@ void cmdFunctionSetMac(int arg_cnt, char **args);
|
|||||||
|
|
||||||
void cmdFunctionGet(int arg_cnt, char **args);
|
void cmdFunctionGet(int arg_cnt, char **args);
|
||||||
|
|
||||||
|
void cmdFunctionLoglevel(int arg_cnt, char **args);
|
||||||
|
|
||||||
void printBool(bool arg);
|
void printBool(bool arg);
|
||||||
/*
|
/*
|
||||||
void saveFlash(short n, char *str);
|
void saveFlash(short n, char *str);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ int in_ccs811::Setup()
|
|||||||
digitalWrite(WAK_PIN,LOW);
|
digitalWrite(WAK_PIN,LOW);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Serial.println("CCS811 Init");
|
debugSerial.println("CCS811 Init");
|
||||||
|
|
||||||
Wire.begin(); //Inialize I2C Harware
|
Wire.begin(); //Inialize I2C Harware
|
||||||
Wire.setClock(4000);
|
Wire.setClock(4000);
|
||||||
@@ -41,7 +41,7 @@ Wire.setClock(4000);
|
|||||||
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
||||||
{
|
{
|
||||||
Serial.print("CCS811 Init error ");
|
Serial.print("CCS811 Init error ");
|
||||||
//Serial.println(ccs811.statusString(returnCode));
|
//debugSerial.println(ccs811.statusString(returnCode));
|
||||||
printDriverError(returnCode);
|
printDriverError(returnCode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -61,16 +61,16 @@ return 1;
|
|||||||
int in_hdc1080::Setup()
|
int in_hdc1080::Setup()
|
||||||
{
|
{
|
||||||
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
||||||
Serial.println("HDC1080 Init ");
|
debugSerial.println("HDC1080 Init ");
|
||||||
Wire.begin(); //Inialize I2C Harware
|
Wire.begin(); //Inialize I2C Harware
|
||||||
// Default settings:
|
// Default settings:
|
||||||
// - Heater off
|
// - Heater off
|
||||||
// - 14 bit Temperature and Humidity Measurement Resolutions
|
// - 14 bit Temperature and Humidity Measurement Resolutions
|
||||||
hdc1080.begin(0x40);
|
hdc1080.begin(0x40);
|
||||||
Serial.print("Manufacturer ID=0x");
|
debugSerial.print("Manufacturer ID=0x");
|
||||||
Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
|
debugSerial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
|
||||||
Serial.print("Device ID=0x");
|
debugSerial.print("Device ID=0x");
|
||||||
Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
|
debugSerial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
|
||||||
printSerialNumber();
|
printSerialNumber();
|
||||||
HDC1080ready = true;
|
HDC1080ready = true;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -91,15 +91,15 @@ int in_hdc1080::Poll(short cause)
|
|||||||
int reg;
|
int reg;
|
||||||
if (cause!=POLLING_SLOW) return 0;
|
if (cause!=POLLING_SLOW) return 0;
|
||||||
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
||||||
Serial.print("HDC Status=");
|
debugSerial.print("HDC Status=");
|
||||||
Serial.println(reg=hdc1080.readRegister().rawData,HEX);
|
debugSerial.println(reg=hdc1080.readRegister().rawData,HEX);
|
||||||
if (reg!=0xff)
|
if (reg!=0xff)
|
||||||
{
|
{
|
||||||
Serial.print(" T=");
|
debugSerial.print(" T=");
|
||||||
Serial.print(t=hdc1080.readTemperature());
|
debugSerial.print(t=hdc1080.readTemperature());
|
||||||
Serial.print("C, RH=");
|
debugSerial.print("C, RH=");
|
||||||
Serial.print(h=hdc1080.readHumidity());
|
debugSerial.print(h=hdc1080.readHumidity());
|
||||||
Serial.println("%");
|
debugSerial.println("%");
|
||||||
|
|
||||||
|
|
||||||
#ifdef M5STACK
|
#ifdef M5STACK
|
||||||
@@ -125,7 +125,7 @@ if (reg!=0xff)
|
|||||||
}
|
}
|
||||||
else //ESP I2C glitch
|
else //ESP I2C glitch
|
||||||
{
|
{
|
||||||
Serial.println("I2C Reset");
|
debugSerial.println("I2C Reset");
|
||||||
i2cReset();
|
i2cReset();
|
||||||
}
|
}
|
||||||
return INTERVAL_SLOW_POLLING;
|
return INTERVAL_SLOW_POLLING;
|
||||||
@@ -147,15 +147,15 @@ int in_ccs811::Poll(short cause)
|
|||||||
CCS811Core::status returnCode = ccs811.readAlgorithmResults();
|
CCS811Core::status returnCode = ccs811.readAlgorithmResults();
|
||||||
printDriverError(returnCode);
|
printDriverError(returnCode);
|
||||||
float co2,tvoc;
|
float co2,tvoc;
|
||||||
Serial.print(" CO2[");
|
debugSerial.print(" CO2[");
|
||||||
//Returns calculated CO2 reading
|
//Returns calculated CO2 reading
|
||||||
Serial.print(co2 = ccs811.getCO2());
|
debugSerial.print(co2 = ccs811.getCO2());
|
||||||
Serial.print("] tVOC[");
|
debugSerial.print("] tVOC[");
|
||||||
//Returns calculated TVOC reading
|
//Returns calculated TVOC reading
|
||||||
|
|
||||||
Serial.print(tvoc = ccs811.getTVOC());
|
debugSerial.print(tvoc = ccs811.getTVOC());
|
||||||
Serial.print("] baseline[");
|
debugSerial.print("] baseline[");
|
||||||
Serial.print(ccs811Baseline = ccs811.getBaseline());
|
debugSerial.print(ccs811Baseline = ccs811.getBaseline());
|
||||||
|
|
||||||
#ifdef M5STACK
|
#ifdef M5STACK
|
||||||
M5.Lcd.print(" CO2[");
|
M5.Lcd.print(" CO2[");
|
||||||
@@ -181,7 +181,7 @@ int in_ccs811::Poll(short cause)
|
|||||||
publish(co2,"/CO2");
|
publish(co2,"/CO2");
|
||||||
publish(tvoc,"/TVOC");
|
publish(tvoc,"/TVOC");
|
||||||
publish(ccs811Baseline,"/base");}
|
publish(ccs811Baseline,"/base");}
|
||||||
Serial.println("]");
|
debugSerial.println("]");
|
||||||
printSensorError();
|
printSensorError();
|
||||||
|
|
||||||
#ifdef WAK_PIN
|
#ifdef WAK_PIN
|
||||||
@@ -192,11 +192,11 @@ int in_ccs811::Poll(short cause)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void in_hdc1080::printSerialNumber() {
|
void in_hdc1080::printSerialNumber() {
|
||||||
Serial.print("Device Serial Number=");
|
debugSerial.print("Device Serial Number=");
|
||||||
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
|
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
|
||||||
char format[16];
|
char format[16];
|
||||||
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
|
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
|
||||||
Serial.println(format);
|
debugSerial.println(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printDriverError decodes the CCS811Core::status type and prints the
|
//printDriverError decodes the CCS811Core::status type and prints the
|
||||||
@@ -209,22 +209,22 @@ void in_ccs811::printDriverError( CCS811Core::status errorCode )
|
|||||||
switch ( errorCode )
|
switch ( errorCode )
|
||||||
{
|
{
|
||||||
case CCS811Core::SENSOR_SUCCESS:
|
case CCS811Core::SENSOR_SUCCESS:
|
||||||
Serial.print("SUCCESS");
|
debugSerial.print("SUCCESS");
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_ID_ERROR:
|
case CCS811Core::SENSOR_ID_ERROR:
|
||||||
Serial.print("ID_ERROR");
|
debugSerial.print("ID_ERROR");
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_I2C_ERROR:
|
case CCS811Core::SENSOR_I2C_ERROR:
|
||||||
Serial.print("I2C_ERROR");
|
debugSerial.print("I2C_ERROR");
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_INTERNAL_ERROR:
|
case CCS811Core::SENSOR_INTERNAL_ERROR:
|
||||||
Serial.print("INTERNAL_ERROR");
|
debugSerial.print("INTERNAL_ERROR");
|
||||||
break;
|
break;
|
||||||
case CCS811Core::SENSOR_GENERIC_ERROR:
|
case CCS811Core::SENSOR_GENERIC_ERROR:
|
||||||
Serial.print("GENERIC_ERROR");
|
debugSerial.print("GENERIC_ERROR");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Serial.print("Unspecified error.");
|
debugSerial.print("Unspecified error.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,18 +236,18 @@ void in_ccs811::printSensorError()
|
|||||||
|
|
||||||
if ( error == 0xFF ) //comm error
|
if ( error == 0xFF ) //comm error
|
||||||
{
|
{
|
||||||
Serial.println("Failed to get ERROR_ID register.");
|
debugSerial.println("Failed to get ERROR_ID register.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Serial.print("");
|
//debugSerial.print("");
|
||||||
if (error & 1 << 5) Serial.print("Error: HeaterSupply");
|
if (error & 1 << 5) debugSerial.print("Error: HeaterSupply");
|
||||||
if (error & 1 << 4) Serial.print("Error: HeaterFault");
|
if (error & 1 << 4) debugSerial.print("Error: HeaterFault");
|
||||||
if (error & 1 << 3) Serial.print("Error: MaxResistance");
|
if (error & 1 << 3) debugSerial.print("Error: MaxResistance");
|
||||||
if (error & 1 << 2) Serial.print("Error: MeasModeInvalid");
|
if (error & 1 << 2) debugSerial.print("Error: MeasModeInvalid");
|
||||||
if (error & 1 << 1) Serial.print("Error: ReadRegInvalid");
|
if (error & 1 << 1) debugSerial.print("Error: ReadRegInvalid");
|
||||||
if (error & 1 << 0) Serial.print("Error: MsgInvalid");
|
if (error & 1 << 0) debugSerial.print("Error: MsgInvalid");
|
||||||
Serial.println();
|
debugSerial.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ void out_AC::InsertData(byte data[], size_t size){
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Serial.print ("Power=");
|
debugSerial.print ("Power=");
|
||||||
Serial.println(power);
|
debugSerial.println(power);
|
||||||
|
|
||||||
if (power & 0x08)
|
if (power & 0x08)
|
||||||
publishTopic(item->itemArr->name, "ON", "/quiet");
|
publishTopic(item->itemArr->name, "ON", "/quiet");
|
||||||
@@ -189,7 +189,7 @@ void SendData(byte req[], size_t size){
|
|||||||
AC_Serial.write(req, size - 1);
|
AC_Serial.write(req, size - 1);
|
||||||
AC_Serial.write(getCRC(req, size-1));
|
AC_Serial.write(getCRC(req, size-1));
|
||||||
AC_Serial.flush();
|
AC_Serial.flush();
|
||||||
|
/*
|
||||||
Serial.print("<<");
|
Serial.print("<<");
|
||||||
for (int i=0; i < size-1; i++)
|
for (int i=0; i < size-1; i++)
|
||||||
{
|
{
|
||||||
@@ -203,6 +203,7 @@ void SendData(byte req[], size_t size){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned char toHex( char ch ){
|
inline unsigned char toHex( char ch ){
|
||||||
@@ -214,7 +215,7 @@ inline unsigned char toHex( char ch ){
|
|||||||
int out_AC::Setup()
|
int out_AC::Setup()
|
||||||
{
|
{
|
||||||
abstractOut::Setup();
|
abstractOut::Setup();
|
||||||
Serial.println("AC Init");
|
debugSerial.println("AC Init");
|
||||||
AC_Serial.begin(9600);
|
AC_Serial.begin(9600);
|
||||||
driverStatus = CST_INITIALIZED;
|
driverStatus = CST_INITIALIZED;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -222,7 +223,7 @@ return 1;
|
|||||||
|
|
||||||
int out_AC::Stop()
|
int out_AC::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("AC De-Init");
|
debugSerial.println("AC De-Init");
|
||||||
|
|
||||||
driverStatus = CST_UNKNOWN;
|
driverStatus = CST_UNKNOWN;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -246,7 +247,7 @@ if (cause!=POLLING_SLOW) return 0;
|
|||||||
//if (now - prevPolling > INTERVAL_AC_POLLING) {
|
//if (now - prevPolling > INTERVAL_AC_POLLING) {
|
||||||
if (isTimeOver(prevPolling,millis(),INTERVAL_AC_POLLING)) {
|
if (isTimeOver(prevPolling,millis(),INTERVAL_AC_POLLING)) {
|
||||||
prevPolling = millisNZ();
|
prevPolling = millisNZ();
|
||||||
Serial.println ("Polling");
|
debugSerial.println ("Polling");
|
||||||
SendData(qstn, sizeof(qstn)/sizeof(byte)); //Опрос кондиционера
|
SendData(qstn, sizeof(qstn)/sizeof(byte)); //Опрос кондиционера
|
||||||
}
|
}
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ else
|
|||||||
|
|
||||||
int out_Modbus::Stop()
|
int out_Modbus::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("Modbus De-Init");
|
debugSerial.println("Modbus De-Init");
|
||||||
|
|
||||||
delete store;
|
delete store;
|
||||||
item->setPersistent(NULL);
|
item->setPersistent(NULL);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ int out_Motor::Setup()
|
|||||||
{
|
{
|
||||||
abstractOut::Setup();
|
abstractOut::Setup();
|
||||||
getConfig();
|
getConfig();
|
||||||
Serial.println("Motor Init");
|
debugSerial.println("Motor Init");
|
||||||
pinMode(pinUp,OUTPUT);
|
pinMode(pinUp,OUTPUT);
|
||||||
pinMode(pinDown,OUTPUT);
|
pinMode(pinDown,OUTPUT);
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ return 1;
|
|||||||
|
|
||||||
int out_Motor::Stop()
|
int out_Motor::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("Motor De-Init");
|
debugSerial.println("Motor De-Init");
|
||||||
digitalWrite(pinUp,INACTIVE);
|
digitalWrite(pinUp,INACTIVE);
|
||||||
digitalWrite(pinDown,INACTIVE);
|
digitalWrite(pinDown,INACTIVE);
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ else
|
|||||||
|
|
||||||
}
|
}
|
||||||
else //Target zone
|
else //Target zone
|
||||||
{ Serial.println("Target");
|
{ debugSerial.println("Target");
|
||||||
digitalWrite(pinUp,INACTIVE);
|
digitalWrite(pinUp,INACTIVE);
|
||||||
digitalWrite(pinDown,INACTIVE);
|
digitalWrite(pinDown,INACTIVE);
|
||||||
item->setExt(0);
|
item->setExt(0);
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ else
|
|||||||
|
|
||||||
int out_pid::Stop()
|
int out_pid::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("PID De-Init");
|
debugSerial.println("PID De-Init");
|
||||||
if (store) delete (store->pid);
|
if (store) delete (store->pid);
|
||||||
delete store;
|
delete store;
|
||||||
item->setPersistent(NULL);
|
item->setPersistent(NULL);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ int out_SPILed::Setup()
|
|||||||
{
|
{
|
||||||
abstractOut::Setup();
|
abstractOut::Setup();
|
||||||
getConfig();
|
getConfig();
|
||||||
Serial.println("SPI-LED Init");
|
debugSerial.println("SPI-LED Init");
|
||||||
|
|
||||||
if (!leds)
|
if (!leds)
|
||||||
{
|
{
|
||||||
@@ -69,7 +69,7 @@ return 1;
|
|||||||
|
|
||||||
int out_SPILed::Stop()
|
int out_SPILed::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("SPI-LED De-Init");
|
debugSerial.println("SPI-LED De-Init");
|
||||||
//FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
|
//FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
|
||||||
#ifdef ADAFRUIT_LED
|
#ifdef ADAFRUIT_LED
|
||||||
leds->clear();
|
leds->clear();
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ else
|
|||||||
|
|
||||||
int out_UARTbridge::Stop()
|
int out_UARTbridge::Stop()
|
||||||
{
|
{
|
||||||
Serial.println("UARTbridge De-Init");
|
debugSerial.println("UARTbridge De-Init");
|
||||||
|
|
||||||
udpClientA.stop();
|
udpClientA.stop();
|
||||||
udpClientB.stop();
|
udpClientB.stop();
|
||||||
|
|||||||
@@ -2,13 +2,21 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "statusled.h"
|
#include "statusled.h"
|
||||||
|
|
||||||
|
#ifdef SYSLOG_ENABLE
|
||||||
|
char logBuffer[LOGBUFFER_SIZE];
|
||||||
|
int logBufferPos=0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t serialDebugLevel = 7;
|
||||||
|
uint8_t udpDebugLevel =7;
|
||||||
|
|
||||||
#if defined (STATUSLED)
|
#if defined (STATUSLED)
|
||||||
extern StatusLED statusLED;
|
extern StatusLED statusLED;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
extern bool syslogInitialized;
|
extern bool syslogInitialized;
|
||||||
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity , Syslog * _syslog, uint8_t _ledPattern )
|
Streamlog::Streamlog (SerialPortType * _serialPort, uint8_t _severity , Syslog * _syslog, uint8_t _ledPattern )
|
||||||
{
|
{
|
||||||
serialPort=_serialPort;
|
serialPort=_serialPort;
|
||||||
severity=_severity;
|
severity=_severity;
|
||||||
@@ -16,7 +24,7 @@ Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity , Syslog * _sy
|
|||||||
ledPattern=_ledPattern;
|
ledPattern=_ledPattern;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Streamlog::Streamlog (HardwareSerial * _serialPort, int _severity, uint8_t _ledPattern)
|
Streamlog::Streamlog (SerialPortType * _serialPort, uint8_t _severity, uint8_t _ledPattern)
|
||||||
{
|
{
|
||||||
serialPort=_serialPort;
|
serialPort=_serialPort;
|
||||||
severity=_severity;
|
severity=_severity;
|
||||||
@@ -61,7 +69,7 @@ void Streamlog::flush(void)
|
|||||||
size_t Streamlog::write(uint8_t ch)
|
size_t Streamlog::write(uint8_t ch)
|
||||||
{
|
{
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
if (syslogInitialized)
|
if (syslogInitialized && (udpDebugLevel>=severity))
|
||||||
{
|
{
|
||||||
if (ch=='\n')
|
if (ch=='\n')
|
||||||
{
|
{
|
||||||
@@ -80,7 +88,7 @@ if (syslogInitialized)
|
|||||||
if ((ch=='\n') && ledPattern) statusLED.flash(ledPattern);
|
if ((ch=='\n') && ledPattern) statusLED.flash(ledPattern);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (serialPort) return serialPort->write(ch);
|
if (serialPort && (serialDebugLevel>=severity)) return serialPort->write(ch);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,34 +1,41 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Print.h>
|
#include <Print.h>
|
||||||
|
#include <Arduino.h>
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#if defined (STM32)
|
||||||
|
#include <USBSerial.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef LOGBUFFER_SIZE
|
#ifndef LOGBUFFER_SIZE
|
||||||
#define LOGBUFFER_SIZE 80
|
#define LOGBUFFER_SIZE 80
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
#include <Syslog.h>
|
#include <Syslog.h>
|
||||||
static char logBuffer[LOGBUFFER_SIZE];
|
#endif
|
||||||
static int logBufferPos=0;
|
|
||||||
|
extern uint8_t serialDebugLevel;
|
||||||
|
extern uint8_t udpDebugLevel;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SerialPortType
|
||||||
|
#define SerialPortType HardwareSerial
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOG_DEBUG 7
|
#define LOG_DEBUG 7
|
||||||
#define LOG_INFO 6
|
#define LOG_INFO 6
|
||||||
#define LOG_ERROR 3
|
#define LOG_ERROR 3
|
||||||
|
|
||||||
static uint8_t serialDebugLevel = 7;
|
|
||||||
static uint8_t udpDebugLevel =7;
|
|
||||||
|
|
||||||
class Streamlog : public Print
|
class Streamlog : public Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, Syslog * _syslog = NULL, uint8_t _ledPattern = 0);
|
Streamlog (SerialPortType * _serialPort, uint8_t _severity = LOG_DEBUG, Syslog * _syslog = NULL, uint8_t _ledPattern = 0);
|
||||||
#else
|
#else
|
||||||
Streamlog (HardwareSerial * _serialPort, int _severity = LOG_DEBUG, uint8_t _ledPattern = 0);
|
Streamlog (SerialPortType * _serialPort, uint8_t _severity = LOG_DEBUG, uint8_t _ledPattern = 0);
|
||||||
#endif
|
#endif
|
||||||
// {serialPort=_serialPort;severity=_severity; syslog=_syslog; }
|
|
||||||
void begin(unsigned long speed);
|
void begin(unsigned long speed);
|
||||||
void end() ;
|
void end() ;
|
||||||
|
|
||||||
@@ -40,8 +47,8 @@ class Streamlog : public Print
|
|||||||
using Print::write; // pull in write(str) and write(buf, size) from Print
|
using Print::write; // pull in write(str) and write(buf, size) from Print
|
||||||
operator bool() {return true;};
|
operator bool() {return true;};
|
||||||
private:
|
private:
|
||||||
uint16_t severity;
|
uint8_t severity;
|
||||||
HardwareSerial *serialPort;
|
SerialPortType *serialPort;
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
Syslog * syslog;
|
Syslog * syslog;
|
||||||
uint8_t ledPattern;
|
uint8_t ledPattern;
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ e-mail anklimov@gmail.com
|
|||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
|
|
||||||
|
#ifndef debugSerialPort
|
||||||
|
#define debugSerialPort Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int8_t configLocked;
|
extern int8_t configLocked;
|
||||||
extern int8_t ethernetIdleCount;
|
extern int8_t ethernetIdleCount;
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
@@ -63,7 +67,7 @@ void PrintBytes(uint8_t *addr, uint8_t count, bool newline) {
|
|||||||
const char HEXSTR[] = "0123456789ABCDEF";
|
const char HEXSTR[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
void SetBytes(uint8_t *addr, uint8_t count, char *out) {
|
void SetBytes(uint8_t *addr, uint8_t count, char *out) {
|
||||||
// Serial.println("SB:");
|
// debugSerialPort.println("SB:");
|
||||||
for (uint8_t i = 0; i < count; i++) {
|
for (uint8_t i = 0; i < count; i++) {
|
||||||
*(out++) = HEXSTR[(addr[i] >> 4)];
|
*(out++) = HEXSTR[(addr[i] >> 4)];
|
||||||
*(out++) = HEXSTR[(addr[i] & 0x0f)];
|
*(out++) = HEXSTR[(addr[i] & 0x0f)];
|
||||||
@@ -101,7 +105,7 @@ int getInt(char **chan) {
|
|||||||
//Move pointer to next element (after ,)
|
//Move pointer to next element (after ,)
|
||||||
*chan = strchr(*chan, ',');
|
*chan = strchr(*chan, ',');
|
||||||
if (*chan) *chan += 1;
|
if (*chan) *chan += 1;
|
||||||
//Serial.print(F("Par:")); Serial.println(ch);
|
//debugSerialPort.print(F("Par:")); debugSerialPort.println(ch);
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -131,7 +135,7 @@ itemCmd getNumber(char **chan) {
|
|||||||
//Move pointer to next element (after ,)
|
//Move pointer to next element (after ,)
|
||||||
*chan = strchr(*chan, ',');
|
*chan = strchr(*chan, ',');
|
||||||
if (*chan) *chan += 1;
|
if (*chan) *chan += 1;
|
||||||
//Serial.print(F("Par:")); Serial.println(ch);
|
//debugSerialPort.print(F("Par:")); debugSerialPort.println(ch);
|
||||||
|
|
||||||
if (fract)
|
if (fract)
|
||||||
val.Tens(ch*10+((ch>0)?fract:-fract));
|
val.Tens(ch*10+((ch>0)?fract:-fract));
|
||||||
@@ -248,7 +252,7 @@ int log(const char *str, ...)//TODO: __FlashStringHelper str support
|
|||||||
{
|
{
|
||||||
//Clear buffer
|
//Clear buffer
|
||||||
temp[j] = '\0';
|
temp[j] = '\0';
|
||||||
Serial.print(temp);
|
debugSerialPort.print(temp);
|
||||||
j=0;
|
j=0;
|
||||||
temp[0] = '\0';
|
temp[0] = '\0';
|
||||||
|
|
||||||
@@ -282,7 +286,7 @@ int log(const char *str, ...)//TODO: __FlashStringHelper str support
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Serial.println(); //Print trailing newline
|
debugSerialPort.println(); //Print trailing newline
|
||||||
return count + 1; //Return number of arguments detected
|
return count + 1; //Return number of arguments detected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,9 +419,9 @@ for(n = 0; n < 4; n++) {
|
|||||||
void printIPAddress(IPAddress ipAddress) {
|
void printIPAddress(IPAddress ipAddress) {
|
||||||
for (byte i = 0; i < 4; i++)
|
for (byte i = 0; i < 4; i++)
|
||||||
#ifdef WITH_PRINTEX_LIB
|
#ifdef WITH_PRINTEX_LIB
|
||||||
(i < 3) ? debugSerial << (ipAddress[i]) << F(".") : debugSerial << (ipAddress[i])<<F(", ");
|
(i < 3) ? debugSerial << (ipAddress[i]) << F(".") : infoSerial << (ipAddress[i])<<F(", ");
|
||||||
#else
|
#else
|
||||||
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : debugSerial << _DEC(ipAddress[i]) << F(" ");
|
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : infoSerial << _DEC(ipAddress[i]) << F(" ");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -599,9 +599,9 @@ framework = arduino
|
|||||||
board = due
|
board = due
|
||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
build_flags = !python get_build_flags.py lighthub21
|
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_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 =
|
lib_ignore =
|
||||||
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
@@ -768,6 +768,7 @@ board_build.mcu = stm32f103rbt6
|
|||||||
board_build.f_cpu = 72000000L
|
board_build.f_cpu = 72000000L
|
||||||
framework = arduino
|
framework = arduino
|
||||||
monitor_baud = 115200
|
monitor_baud = 115200
|
||||||
|
monitor_dtr = 1
|
||||||
upload_protocol = dfu
|
upload_protocol = dfu
|
||||||
;debug_tool = cmsis-dap
|
;debug_tool = cmsis-dap
|
||||||
build_flags = !python get_build_flags.py stm32
|
build_flags = !python get_build_flags.py stm32
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ GIT: https://github.com/anklimov/lighthub
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#ifndef debugSerialPort
|
||||||
|
#define debugSerialPort Serial
|
||||||
|
#endif
|
||||||
|
|
||||||
int owRead2408(uint8_t* addr) {
|
int owRead2408(uint8_t* addr) {
|
||||||
uint8_t buf[13];
|
uint8_t buf[13];
|
||||||
// PrintBytes(buf, 13, true);
|
// PrintBytes(buf, 13, true);
|
||||||
@@ -38,7 +42,7 @@ if (!net) return -1;
|
|||||||
net->reset();
|
net->reset();
|
||||||
|
|
||||||
if (!OneWire::check_crc16(buf, 11, &buf[11])) {
|
if (!OneWire::check_crc16(buf, 11, &buf[11])) {
|
||||||
Serial.print(F("CRC failure in DS2408 at "));
|
debugSerialPort.print(F("CRC failure in DS2408 at "));
|
||||||
PrintBytes(addr, 8, true);
|
PrintBytes(addr, 8, true);
|
||||||
PrintBytes(buf+3,10);
|
PrintBytes(buf+3,10);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -51,8 +55,8 @@ if (!net) return -1;
|
|||||||
int read1W(int i)
|
int read1W(int i)
|
||||||
{
|
{
|
||||||
|
|
||||||
Serial.print("1W requested: ");
|
debugSerialPort.print("1W requested: ");
|
||||||
Serial.println (i);
|
debugSerialPort.println (i);
|
||||||
|
|
||||||
int t=-1;
|
int t=-1;
|
||||||
switch (term[i][0]){
|
switch (term[i][0]){
|
||||||
@@ -80,10 +84,10 @@ int ow2408out(DeviceAddress addr,uint8_t cur)
|
|||||||
net->read_bytes(buf+3, 2);
|
net->read_bytes(buf+3, 2);
|
||||||
//net.reset();
|
//net.reset();
|
||||||
PrintBytes(buf, 5);
|
PrintBytes(buf, 5);
|
||||||
Serial.print(F(" Out: "));Serial.print(buf[1],BIN);
|
debugSerialPort.print(F(" Out: "));debugSerialPort.print(buf[1],BIN);
|
||||||
Serial.print(F(" In: "));Serial.println(buf[4],BIN);
|
debugSerialPort.print(F(" In: "));debugSerialPort.println(buf[4],BIN);
|
||||||
if (buf[3] != 0xAA) {
|
if (buf[3] != 0xAA) {
|
||||||
Serial.print(F("Write failure in DS2408 at "));
|
debugSerialPort.print(F("Write failure in DS2408 at "));
|
||||||
PrintBytes(addr, 8, true);
|
PrintBytes(addr, 8, true);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
@@ -97,7 +101,7 @@ if (!net) return -1;
|
|||||||
|
|
||||||
if ((devnum=owFind(addr))<0) return -1;
|
if ((devnum=owFind(addr))<0) return -1;
|
||||||
buf=regs[devnum];
|
buf=regs[devnum];
|
||||||
Serial.print(F("Current: "));Serial.println(buf,BIN);
|
debugSerialPort.print(F("Current: "));debugSerialPort.println(buf,BIN);
|
||||||
mask=0;
|
mask=0;
|
||||||
int r,f;
|
int r,f;
|
||||||
switch (subchan) {
|
switch (subchan) {
|
||||||
@@ -107,7 +111,7 @@ if (!net) return -1;
|
|||||||
if (wstat[devnum] & (SW_PULSE0|SW_PULSE_P0))
|
if (wstat[devnum] & (SW_PULSE0|SW_PULSE_P0))
|
||||||
{
|
{
|
||||||
wstat[devnum]|=SW_CHANGED_P0;
|
wstat[devnum]|=SW_CHANGED_P0;
|
||||||
Serial.println(F("Rollback 0"));
|
debugSerialPort.println(F("Rollback 0"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wstat[devnum]|=SW_PULSE0;
|
wstat[devnum]|=SW_PULSE0;
|
||||||
@@ -122,7 +126,7 @@ if (!net) return -1;
|
|||||||
if (wstat[devnum] & (SW_PULSE1|SW_PULSE_P1))
|
if (wstat[devnum] & (SW_PULSE1|SW_PULSE_P1))
|
||||||
{
|
{
|
||||||
wstat[devnum]|=SW_CHANGED_P1;
|
wstat[devnum]|=SW_CHANGED_P1;
|
||||||
Serial.println(F("Rollback 1"));
|
debugSerialPort.println(F("Rollback 1"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wstat[devnum]|=SW_PULSE1;
|
wstat[devnum]|=SW_PULSE1;
|
||||||
@@ -156,8 +160,8 @@ int cntrl2890(uint8_t* addr, int val) {
|
|||||||
uint8_t buf[13];
|
uint8_t buf[13];
|
||||||
if (!net) return -1;
|
if (!net) return -1;
|
||||||
// case 0x2C: //Dimmer
|
// case 0x2C: //Dimmer
|
||||||
Serial.print(F("Update dimmer "));PrintBytes(addr, 8, true);Serial.print(F(" = "));
|
debugSerialPort.print(F("Update dimmer "));PrintBytes(addr, 8, true);debugSerialPort.print(F(" = "));
|
||||||
Serial.println(val);
|
debugSerialPort.println(val);
|
||||||
|
|
||||||
net->reset();
|
net->reset();
|
||||||
net->select(addr);
|
net->select(addr);
|
||||||
@@ -270,7 +274,7 @@ int cntrl2413(uint8_t* addr, int subchan, int val) {
|
|||||||
uint8_t count =10;
|
uint8_t count =10;
|
||||||
if (!net) return -1;
|
if (!net) return -1;
|
||||||
// case 0x85: //Switch
|
// case 0x85: //Switch
|
||||||
Serial.print(F("Update switch "));PrintBytes(addr, 8, false); Serial.print(F("/"));Serial.print(subchan);Serial.print(F(" = "));Serial.println(val);
|
debugSerialPort.print(F("Update switch "));PrintBytes(addr, 8, false); debugSerialPort.print(F("/"));debugSerialPort.print(subchan);debugSerialPort.print(F(" = "));debugSerialPort.println(val);
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
net->reset();
|
net->reset();
|
||||||
@@ -281,13 +285,13 @@ int cntrl2413(uint8_t* addr, int subchan, int val) {
|
|||||||
net->write(cmd);
|
net->write(cmd);
|
||||||
|
|
||||||
results = net->read();
|
results = net->read();
|
||||||
Serial.print(F("Got: ")); Serial.println(results,BIN);
|
debugSerialPort.print(F("Got: ")); debugSerialPort.println(results,BIN);
|
||||||
//Serial.println((~results & 0x0F),BIN); Serial.println ((results >> 4),BIN);
|
//debugSerialPort.println((~results & 0x0F),BIN); debugSerialPort.println ((results >> 4),BIN);
|
||||||
|
|
||||||
ok = (~results & 0x0F) == (results >> 4); // Compare nibbles
|
ok = (~results & 0x0F) == (results >> 4); // Compare nibbles
|
||||||
results &= 0x0F; // Clear inverted values
|
results &= 0x0F; // Clear inverted values
|
||||||
|
|
||||||
if (ok) {Serial.println(F("Read ok"));break;} else {Serial.println(F("read Error"));delay(1);}
|
if (ok) {debugSerialPort.println(F("Read ok"));break;} else {debugSerialPort.println(F("read Error"));delay(1);}
|
||||||
} //while
|
} //while
|
||||||
|
|
||||||
if (ok && (val>=0))
|
if (ok && (val>=0))
|
||||||
@@ -309,7 +313,7 @@ int cntrl2413(uint8_t* addr, int subchan, int val) {
|
|||||||
if (!val) set|=DS2413_OUT_PinB; else set &= ~DS2413_OUT_PinB;
|
if (!val) set|=DS2413_OUT_PinB; else set &= ~DS2413_OUT_PinB;
|
||||||
};
|
};
|
||||||
set |= 0xFC;
|
set |= 0xFC;
|
||||||
Serial.print(F("New: "));Serial.println(set,BIN);
|
debugSerialPort.print(F("New: "));debugSerialPort.println(set,BIN);
|
||||||
cmd = DS2413_ACCESS_WRITE;
|
cmd = DS2413_ACCESS_WRITE;
|
||||||
net->write(cmd);
|
net->write(cmd);
|
||||||
|
|
||||||
@@ -321,17 +325,17 @@ int cntrl2413(uint8_t* addr, int subchan, int val) {
|
|||||||
if (ack == DS2413_ACK_SUCCESS)
|
if (ack == DS2413_ACK_SUCCESS)
|
||||||
{
|
{
|
||||||
results=net->read();
|
results=net->read();
|
||||||
Serial.print(F("Updated ok: ")); Serial.println(results,BIN);
|
debugSerialPort.print(F("Updated ok: ")); debugSerialPort.println(results,BIN);
|
||||||
ok = (~results & 0x0F) == (results >> 4); // Compare nibbles
|
ok = (~results & 0x0F) == (results >> 4); // Compare nibbles
|
||||||
{
|
{
|
||||||
if (ok)
|
if (ok)
|
||||||
{Serial.println(F("Readback ok"));
|
{debugSerialPort.println(F("Readback ok"));
|
||||||
break;}
|
break;}
|
||||||
else {Serial.println(F("readback Error"));delay(1);}
|
else {debugSerialPort.println(F("readback Error"));delay(1);}
|
||||||
}
|
}
|
||||||
results &= 0x0F; // Clear inverted values
|
results &= 0x0F; // Clear inverted values
|
||||||
}
|
}
|
||||||
else Serial.println (F("Write failed"));;
|
else debugSerialPort.println (F("Write failed"));;
|
||||||
|
|
||||||
} //while
|
} //while
|
||||||
} //if
|
} //if
|
||||||
@@ -347,12 +351,12 @@ int sensors_ext(void)
|
|||||||
int t;
|
int t;
|
||||||
switch (term[si][0]){
|
switch (term[si][0]){
|
||||||
case 0x29: // DS2408
|
case 0x29: // DS2408
|
||||||
//Serial.println(wstat[si],BIN);
|
//debugSerialPort.println(wstat[si],BIN);
|
||||||
|
|
||||||
if (wstat[si] & SW_PULSE0) {
|
if (wstat[si] & SW_PULSE0) {
|
||||||
wstat[si]&=~SW_PULSE0;
|
wstat[si]&=~SW_PULSE0;
|
||||||
wstat[si]|=SW_PULSE_P0;
|
wstat[si]|=SW_PULSE_P0;
|
||||||
Serial.println(F("Pulse0 in progress"));
|
debugSerialPort.println(F("Pulse0 in progress"));
|
||||||
|
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
@@ -361,7 +365,7 @@ int sensors_ext(void)
|
|||||||
wstat[si]&=~SW_PULSE0_R;
|
wstat[si]&=~SW_PULSE0_R;
|
||||||
wstat[si]|=SW_PULSE_P0;
|
wstat[si]|=SW_PULSE_P0;
|
||||||
regs[si] =(ow2408out(term[si],(regs[si] | SW_MASK) & ~SW_OUT0) & SW_INMASK) ^ SW_STAT0;
|
regs[si] =(ow2408out(term[si],(regs[si] | SW_MASK) & ~SW_OUT0) & SW_INMASK) ^ SW_STAT0;
|
||||||
Serial.println(F("Pulse0 in activated"));
|
debugSerialPort.println(F("Pulse0 in activated"));
|
||||||
|
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
@@ -369,7 +373,7 @@ int sensors_ext(void)
|
|||||||
if (wstat[si] & SW_PULSE1) {
|
if (wstat[si] & SW_PULSE1) {
|
||||||
wstat[si]&=~SW_PULSE1;
|
wstat[si]&=~SW_PULSE1;
|
||||||
wstat[si]|=SW_PULSE_P1;
|
wstat[si]|=SW_PULSE_P1;
|
||||||
Serial.println(F("Pulse1 in progress"));
|
debugSerialPort.println(F("Pulse1 in progress"));
|
||||||
|
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
@@ -378,14 +382,14 @@ int sensors_ext(void)
|
|||||||
wstat[si]&=~SW_PULSE1_R;
|
wstat[si]&=~SW_PULSE1_R;
|
||||||
wstat[si]|=SW_PULSE_P1;
|
wstat[si]|=SW_PULSE_P1;
|
||||||
regs[si] =(ow2408out(term[si],(regs[si] | SW_MASK) & ~SW_OUT1) & SW_INMASK) ^ SW_STAT1;
|
regs[si] =(ow2408out(term[si],(regs[si] | SW_MASK) & ~SW_OUT1) & SW_INMASK) ^ SW_STAT1;
|
||||||
Serial.println(F("Pulse0 in activated"));
|
debugSerialPort.println(F("Pulse0 in activated"));
|
||||||
|
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wstat[si] & SW_PULSE_P0) {
|
if (wstat[si] & SW_PULSE_P0) {
|
||||||
wstat[si]&=~SW_PULSE_P0;
|
wstat[si]&=~SW_PULSE_P0;
|
||||||
Serial.println(F("Pulse0 clearing"));
|
debugSerialPort.println(F("Pulse0 clearing"));
|
||||||
ow2408out(term[si],regs[si] | SW_MASK | SW_OUT0);
|
ow2408out(term[si],regs[si] | SW_MASK | SW_OUT0);
|
||||||
|
|
||||||
if (wstat[si] & SW_CHANGED_P0) {
|
if (wstat[si] & SW_CHANGED_P0) {
|
||||||
@@ -397,7 +401,7 @@ int sensors_ext(void)
|
|||||||
|
|
||||||
if (wstat[si] & SW_PULSE_P1) {
|
if (wstat[si] & SW_PULSE_P1) {
|
||||||
wstat[si]&=~SW_PULSE_P1;
|
wstat[si]&=~SW_PULSE_P1;
|
||||||
Serial.println(F("Pulse1 clearing"));
|
debugSerialPort.println(F("Pulse1 clearing"));
|
||||||
ow2408out(term[si],regs[si] | SW_MASK | SW_OUT1);
|
ow2408out(term[si],regs[si] | SW_MASK | SW_OUT1);
|
||||||
|
|
||||||
if (wstat[si] & SW_CHANGED_P1) {
|
if (wstat[si] & SW_CHANGED_P1) {
|
||||||
@@ -415,18 +419,18 @@ if (wstat[si] & SW_PULSE_P1) {
|
|||||||
|
|
||||||
if (t!=regs[si]) {
|
if (t!=regs[si]) {
|
||||||
|
|
||||||
Serial.print(F("DS2408 data = "));
|
debugSerialPort.print(F("DS2408 data = "));
|
||||||
Serial.println(t, BIN);
|
debugSerialPort.println(t, BIN);
|
||||||
|
|
||||||
if (!(wstat[si] & SW_DOUBLECHECK))
|
if (!(wstat[si] & SW_DOUBLECHECK))
|
||||||
{
|
{
|
||||||
wstat[si]|=SW_DOUBLECHECK; //suspected
|
wstat[si]|=SW_DOUBLECHECK; //suspected
|
||||||
Serial.println(F("DOUBLECHECK"));
|
debugSerialPort.println(F("DOUBLECHECK"));
|
||||||
return recheck_interval;
|
return recheck_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Serial.println(F("Really Changed"));
|
debugSerialPort.println(F("Really Changed"));
|
||||||
if (owChanged) owChanged(si,term[si],t);
|
if (owChanged) owChanged(si,term[si],t);
|
||||||
regs[si]=t;
|
regs[si]=t;
|
||||||
|
|
||||||
@@ -441,7 +445,7 @@ if (wstat[si] & SW_PULSE_P1) {
|
|||||||
case 0x81:
|
case 0x81:
|
||||||
t=wstat[si];
|
t=wstat[si];
|
||||||
if (t!=regs[si])
|
if (t!=regs[si])
|
||||||
{ Serial.println(F("Changed"));
|
{ debugSerialPort.println(F("Changed"));
|
||||||
if (owChanged) owChanged(si,term[si],t);
|
if (owChanged) owChanged(si,term[si],t);
|
||||||
regs[si]=t;
|
regs[si]=t;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user