mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Fixes: negative pin# hung, compilation error, double ON ->white color, analog mapping on the edges of interval, macaddr mask, potential unrelability on LAN re-interability
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
extern lan_status lanStatus;
|
extern lan_status lanStatus;
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
extern int8_t ethernetIdleCount;
|
||||||
|
|
||||||
int abstractCh::publishTopic(const char* topic, long value, const char* subtopic)
|
int abstractCh::publishTopic(const char* topic, long value, const char* subtopic)
|
||||||
{
|
{
|
||||||
@@ -31,7 +32,7 @@ int abstractCh::publishTopic(const char* topic, const char * value, const char*
|
|||||||
strncpy(addrstr,topic,sizeof(addrstr));
|
strncpy(addrstr,topic,sizeof(addrstr));
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,topic);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,topic);
|
||||||
strncat(addrstr,subtopic,sizeof(addrstr));
|
strncat(addrstr,subtopic,sizeof(addrstr));
|
||||||
if (mqttClient.connected() && lanStatus == OPERATION)
|
if (mqttClient.connected() && lanStatus == OPERATION && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
mqttClient.publish(addrstr, value, true);
|
mqttClient.publish(addrstr, value, true);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -852,8 +852,15 @@ void Input::analogPoll(short cause) {
|
|||||||
|
|
||||||
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
||||||
|
|
||||||
if (mappedInputVal>max) mappedInputVal = max;
|
if (mappedInputVal>max)
|
||||||
if (mappedInputVal<min) mappedInputVal = min;
|
{
|
||||||
|
mappedInputVal = max;
|
||||||
|
inputVal = 1023;
|
||||||
|
}
|
||||||
|
if (mappedInputVal<min) {
|
||||||
|
mappedInputVal = min;
|
||||||
|
inputVal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (aJson.getArraySize(inputMap)==2)
|
if (aJson.getArraySize(inputMap)==2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -555,6 +555,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
CHstore st;
|
CHstore st;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
int t;
|
int t;
|
||||||
|
/*
|
||||||
case CMD_ON:
|
case CMD_ON:
|
||||||
if (getChanType()==CH_RGBW && getCmd() == CMD_ON && send && (chActive>0)) {
|
if (getChanType()==CH_RGBW && getCmd() == CMD_ON && send && (chActive>0)) {
|
||||||
debugSerial<<F("Force White\n");
|
debugSerial<<F("Force White\n");
|
||||||
@@ -564,7 +565,7 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
Par[1] = 0; //Zero saturation
|
Par[1] = 0; //Zero saturation
|
||||||
Par[2] = 100; //Full power
|
Par[2] = 100; //Full power
|
||||||
n=3;
|
n=3;
|
||||||
cmd=CMD_NUM;
|
cmd=CMD_NUM; */
|
||||||
// Store
|
// Store
|
||||||
/*
|
/*
|
||||||
st.h = Par[0];
|
st.h = Par[0];
|
||||||
@@ -574,8 +575,8 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode
|
|||||||
setCmd(cmd);
|
setCmd(cmd);
|
||||||
//Send to OH
|
//Send to OH
|
||||||
if (send) SendStatus(SEND_COMMAND | SEND_PARAMETERS ); */
|
if (send) SendStatus(SEND_COMMAND | SEND_PARAMETERS ); */
|
||||||
} // if forcewhite
|
// } // if forcewhite
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
|
|
||||||
case CMD_TOGGLE:
|
case CMD_TOGGLE:
|
||||||
|
|||||||
@@ -1637,7 +1637,7 @@ void publishStat(){
|
|||||||
char topic[64];
|
char topic[64];
|
||||||
char intbuf[16];
|
char intbuf[16];
|
||||||
uint32_t ut = millis()/1000UL;
|
uint32_t ut = millis()/1000UL;
|
||||||
if (!mqttClient.connected()) return;
|
if (!mqttClient.connected() || ethernetIdleCount) return;
|
||||||
|
|
||||||
// debugSerial<<F("\nfree RAM: ")<<fr;
|
// debugSerial<<F("\nfree RAM: ")<<fr;
|
||||||
setTopic(topic,sizeof(topic),T_DEV);
|
setTopic(topic,sizeof(topic),T_DEV);
|
||||||
@@ -1670,6 +1670,9 @@ if (!isMacValid) {
|
|||||||
const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);//colon(:) separated from build options
|
const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);//colon(:) separated from build options
|
||||||
parseBytes(macStr, ':', mac, 6, 16);
|
parseBytes(macStr, ':', mac, 6, 16);
|
||||||
|
|
||||||
|
mac[0]&=0xFE;
|
||||||
|
mac[0]|=2;
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
//Using original MPU MAC
|
//Using original MPU MAC
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
@@ -1688,6 +1691,7 @@ if (!isMacValid) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printMACAddress();
|
printMACAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1937,17 +1941,17 @@ void thermoLoop(void) {
|
|||||||
<< F(" cmd:") << thermoStateCommand;
|
<< F(" cmd:") << thermoStateCommand;
|
||||||
if (thermoPin<0) pinMode(-thermoPin, OUTPUT); else pinMode(thermoPin, OUTPUT);
|
if (thermoPin<0) pinMode(-thermoPin, OUTPUT); else pinMode(thermoPin, OUTPUT);
|
||||||
if (thermoDisabledOrDisconnected(thermoExtensionArray, thermoStateCommand)) {
|
if (thermoDisabledOrDisconnected(thermoExtensionArray, thermoStateCommand)) {
|
||||||
if (thermoPin<0) digitalWrite(-thermoPin, LOW); digitalWrite(thermoPin, LOW);
|
if (thermoPin<0) digitalWrite(-thermoPin, LOW); else digitalWrite(thermoPin, LOW);
|
||||||
// Caution - for water heaters (negative pin#) if some comes wrong (or no connection with termometers output is LOW - valve OPEN)
|
// Caution - for water heaters (negative pin#) if some comes wrong (or no connection with termometers output is LOW - valve OPEN)
|
||||||
// OFF - also VALVE is OPEN (no teat control)
|
// OFF - also VALVE is OPEN (no teat control)
|
||||||
debugSerial<<F(" OFF");
|
debugSerial<<F(" OFF");
|
||||||
} else {
|
} else {
|
||||||
if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) {
|
if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) {
|
||||||
if (thermoPin<0) digitalWrite(-thermoPin, LOW); digitalWrite(thermoPin, HIGH);
|
if (thermoPin<0) digitalWrite(-thermoPin, LOW); else digitalWrite(thermoPin, HIGH);
|
||||||
debugSerial<<F(" ON");
|
debugSerial<<F(" ON");
|
||||||
} //too cold
|
} //too cold
|
||||||
else if (curTemp >= thermoSetting) {
|
else if (curTemp >= thermoSetting) {
|
||||||
if (thermoPin<0) digitalWrite(-thermoPin, HIGH); digitalWrite(thermoPin, LOW);
|
if (thermoPin<0) digitalWrite(-thermoPin, HIGH); else digitalWrite(thermoPin, LOW);
|
||||||
debugSerial<<F(" OFF");
|
debugSerial<<F(" OFF");
|
||||||
} //Reached settings
|
} //Reached settings
|
||||||
else debugSerial<<F(" -target zone-"); // Nothing to do
|
else debugSerial<<F(" -target zone-"); // Nothing to do
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ e-mail anklimov@gmail.com
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
#include <wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32)
|
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user