mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
NOIP compilation option & some inits
This commit is contained in:
44
build-flags/build_flags_stm32-noip
Normal file
44
build-flags/build_flags_stm32-noip
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
-DNOIP
|
||||||
|
-DDMX_DISABLE
|
||||||
|
-DMODBUS_DISABLE
|
||||||
|
-DMBUS_DISABLE
|
||||||
|
-DOWIRE_DISABLE
|
||||||
|
-DDHT_DISABLE
|
||||||
|
-DCOUNTER_DISABLE
|
||||||
|
-DNO_HOMIE
|
||||||
|
-DCSSHDC_DISABLE
|
||||||
|
-DSPILED_DISABLE
|
||||||
|
-DAC_DISABLE
|
||||||
|
-DPID_DISABLE
|
||||||
|
-DMULTIVENT_DISABLE
|
||||||
|
-DMOTOR_DISABLE
|
||||||
|
|
||||||
|
|
||||||
|
-DENABLE_HWSERIAL1
|
||||||
|
-DdebugSerialPort=Serial1
|
||||||
|
|
||||||
|
#-DFLASH_BASE_ADDRESS
|
||||||
|
#-DFLASH_DATA_SECTOR
|
||||||
|
#-DFLASH_PAGE_NUMBER
|
||||||
|
|
||||||
|
-D PIO_FRAMEWORK_ARDUINO_ENABLE_MASS_STORAGE
|
||||||
|
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC_AND_MSC
|
||||||
|
|
||||||
|
#-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
|
||||||
|
|
||||||
|
-D HAL_CAN_MODULE_ENABLED
|
||||||
|
#HAL_ETH_MODULE_DISABLED
|
||||||
|
#HAL_SD_MODULE_DISABLED
|
||||||
|
#HAL_DAC_MODULE_DISABLED
|
||||||
|
#-DMERCURY_ENABLE
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
|
|
||||||
#include "abstractch.h"
|
#include "abstractch.h"
|
||||||
|
#if not defined (NOIP)
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
#endif
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <aJSON.h>
|
#include <aJSON.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
extern lan_status lanStatus;
|
extern lan_status lanStatus;
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
extern int8_t ethernetIdleCount;
|
extern int8_t ethernetIdleCount;
|
||||||
|
#endif
|
||||||
|
|
||||||
int abstractCh::publishTopic(const char* topic, long value, const char* subtopic)
|
int abstractCh::publishTopic(const char* topic, long value, const char* subtopic)
|
||||||
{
|
{
|
||||||
@@ -25,6 +30,7 @@ int abstractCh::publishTopic(const char* topic, float value, const char* subtopi
|
|||||||
|
|
||||||
int abstractCh::publishTopic(const char* topic, const char * value, const char* subtopic)
|
int abstractCh::publishTopic(const char* topic, const char * value, const char* subtopic)
|
||||||
{
|
{
|
||||||
|
#if not defined (NOIP)
|
||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
if (!isNotRetainingStatus()) return 0;
|
if (!isNotRetainingStatus()) return 0;
|
||||||
if (topic)
|
if (topic)
|
||||||
@@ -38,5 +44,6 @@ int abstractCh::publishTopic(const char* topic, const char * value, const char*
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
|
|
||||||
#include "abstractin.h"
|
#include "abstractin.h"
|
||||||
#include "abstractch.h"
|
#include "abstractch.h"
|
||||||
|
#if not defined (NOIP)
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
extern PubSubClient mqttClient;
|
||||||
|
#endif
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <aJSON.h>
|
#include <aJSON.h>
|
||||||
#include "inputs.h"
|
#include "inputs.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
extern lan_status lanStatus;
|
extern lan_status lanStatus;
|
||||||
extern PubSubClient mqttClient;
|
|
||||||
|
|
||||||
int abstractIn::publish(long value, const char* subtopic)
|
int abstractIn::publish(long value, const char* subtopic)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ unsigned int startPos;
|
|||||||
char openmode ;
|
char openmode ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
flashStream():seekableStream(MAX_STREAM_SIZE){openmode = '\0';};
|
flashStream():seekableStream(MAX_STREAM_SIZE),pos(0),startPos(0),openmode('\0'){};
|
||||||
void setSize(unsigned int _size);
|
void setSize(unsigned int _size);
|
||||||
int open(short fileNum, char mode='\0') ;
|
int open(short fileNum, char mode='\0') ;
|
||||||
virtual int open(String _filename, char mode='\0') override;
|
virtual int open(String _filename, char mode='\0') override;
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ e-mail anklimov@gmail.com
|
|||||||
#include "inputs.h"
|
#include "inputs.h"
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#if not defined (NOIP)
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
#endif
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "itemCmd.h"
|
#include "itemCmd.h"
|
||||||
|
|
||||||
@@ -37,8 +39,9 @@ e-mail anklimov@gmail.com
|
|||||||
#include "Adafruit_MCP23X17.h"
|
#include "Adafruit_MCP23X17.h"
|
||||||
Adafruit_MCP23X17 mcp;
|
Adafruit_MCP23X17 mcp;
|
||||||
#endif
|
#endif
|
||||||
|
#if not defined (NOIP)
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
#endif
|
||||||
extern aJsonObject *root;
|
extern aJsonObject *root;
|
||||||
extern int8_t ethernetIdleCount;
|
extern int8_t ethernetIdleCount;
|
||||||
extern int8_t configLocked;
|
extern int8_t configLocked;
|
||||||
@@ -966,6 +969,7 @@ void Input::onContactChanged(int newValue) {
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if not defined (NOIP)
|
||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
@@ -980,6 +984,7 @@ if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestri
|
|||||||
else if (strlen(rcmd->valuestring))mqttClient.publish(addrstr, rcmd->valuestring, true);
|
else if (strlen(rcmd->valuestring))mqttClient.publish(addrstr, rcmd->valuestring, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif //NOIP
|
||||||
}
|
}
|
||||||
} // emit
|
} // emit
|
||||||
if (item && item->type == aJson_String) {
|
if (item && item->type == aJson_String) {
|
||||||
@@ -1011,7 +1016,7 @@ void Input::onAnalogChanged(itemCmd newValue) {
|
|||||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
if (emit && emit->type == aJson_String) {
|
if (emit && emit->type == aJson_String) {
|
||||||
|
|
||||||
//#ifdef WITH_DOMOTICZ
|
//#ifdef WITH_DOMOTICZ
|
||||||
@@ -1029,7 +1034,7 @@ void Input::onAnalogChanged(itemCmd newValue) {
|
|||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
mqttClient.publish(addrstr, strVal, true);
|
mqttClient.publish(addrstr, strVal, true);
|
||||||
}
|
}
|
||||||
|
#endif //NOIP
|
||||||
if (item && item->type == aJson_String) {
|
if (item && item->type == aJson_String) {
|
||||||
Item it(item->valuestring);
|
Item it(item->valuestring);
|
||||||
if (it.isValid()) it.Ctrl(newValue);
|
if (it.isValid()) it.Ctrl(newValue);
|
||||||
@@ -1073,6 +1078,7 @@ readCache::readCache()
|
|||||||
{
|
{
|
||||||
addr=0;
|
addr=0;
|
||||||
type=0;
|
type=0;
|
||||||
|
cached_data = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t readCache::analogReadCached (uint8_t _pin)
|
uint16_t readCache::analogReadCached (uint8_t _pin)
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ e-mail anklimov@gmail.com
|
|||||||
#ifndef MODBUS_DISABLE
|
#ifndef MODBUS_DISABLE
|
||||||
#include <ModbusMaster.h>
|
#include <ModbusMaster.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if not defined (NOIP)
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
#endif
|
||||||
#include "modules/out_spiled.h"
|
#include "modules/out_spiled.h"
|
||||||
#include "modules/out_ac.h"
|
#include "modules/out_ac.h"
|
||||||
#include "modules/out_motor.h"
|
#include "modules/out_motor.h"
|
||||||
@@ -70,7 +71,9 @@ short modbusBusy = 0;
|
|||||||
//bool isPendedModbusWrites = false;
|
//bool isPendedModbusWrites = false;
|
||||||
|
|
||||||
extern aJsonObject *pollingItem;
|
extern aJsonObject *pollingItem;
|
||||||
|
#if not defined (NOIP)
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
#endif
|
||||||
extern int8_t ethernetIdleCount;
|
extern int8_t ethernetIdleCount;
|
||||||
extern int8_t configLocked;
|
extern int8_t configLocked;
|
||||||
extern lan_status lanStatus;
|
extern lan_status lanStatus;
|
||||||
@@ -1470,10 +1473,16 @@ if ((!driver || driver->isAllowed(cmd)) && (!getFlag(FLAG_FREEZED)))
|
|||||||
{
|
{
|
||||||
thermostatStore tStore;
|
thermostatStore tStore;
|
||||||
tStore.asint=getExt();
|
tStore.asint=getExt();
|
||||||
if (!tStore.timestamp16) mqttClient.publish("/alarmoff/snsr", itemArr->name);
|
if (!tStore.timestamp16)
|
||||||
|
{
|
||||||
|
infoSerial<<F("Cleaning alarm ")<<itemArr->name<<endl;
|
||||||
|
#if not defined (NOIP)
|
||||||
|
mqttClient.publish("/alarmoff/snsr", itemArr->name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
tStore.tempX100=cmd.getFloat()*100.; //Save measurement
|
tStore.tempX100=cmd.getFloat()*100.; //Save measurement
|
||||||
tStore.timestamp16=millisNZ(8) & 0xFFFF; //And timestamp
|
tStore.timestamp16=millisNZ(8) & 0xFFFF; //And timestamp
|
||||||
//debugSerial<<F(" T:")<<tStore.tempX100<<F(" TS:")<<tStore.timestamp16<<endl;
|
debugSerial<<F("THERM:")<<itemArr->name<<F(" T:")<<tStore.tempX100<<F(" TS:")<<tStore.timestamp16<<endl;
|
||||||
setExt(tStore.asint);
|
setExt(tStore.asint);
|
||||||
res=1;
|
res=1;
|
||||||
}
|
}
|
||||||
@@ -1762,7 +1771,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
// publish to MQTT - OpenHab Legacy style to
|
// publish to MQTT - OpenHab Legacy style to
|
||||||
// myhome/s_out/item - mix: value and command
|
// myhome/s_out/item - mix: value and command
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
if (!subItem )
|
if (!subItem )
|
||||||
@@ -1787,6 +1796,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
}
|
}
|
||||||
} //!subItem
|
} //!subItem
|
||||||
}
|
}
|
||||||
|
#endif //NOIP
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setFlag(sendFlags);
|
setFlag(sendFlags);
|
||||||
@@ -1835,16 +1845,18 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
|
|
||||||
|
|
||||||
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<valstr<<endl;
|
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<valstr<<endl;
|
||||||
|
#if not defined (NOIP)
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
mqttClient.publish(addrstr, valstr,true);
|
mqttClient.publish(addrstr, valstr,true);
|
||||||
clearFlag(FLAG_PARAMETERS);
|
clearFlag(FLAG_PARAMETERS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setFlag(sendFlags);
|
setFlag(sendFlags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1890,6 +1902,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
strncat_P(addrstr, suffix_P[S_CMD], sizeof(addrstr)-1);
|
strncat_P(addrstr, suffix_P[S_CMD], sizeof(addrstr)-1);
|
||||||
|
|
||||||
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<cmdstr<<endl;
|
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<cmdstr<<endl;
|
||||||
|
#if not defined (NOIP)
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
mqttClient.publish(addrstr, cmdstr,true);
|
mqttClient.publish(addrstr, cmdstr,true);
|
||||||
@@ -1900,6 +1913,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
setFlag(sendFlags);
|
setFlag(sendFlags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// Send ctrl
|
// Send ctrl
|
||||||
if (sendFlags & FLAG_FLAGS)
|
if (sendFlags & FLAG_FLAGS)
|
||||||
@@ -1928,6 +1942,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
strncat_P(addrstr, suffix_P[S_CTRL], sizeof(addrstr)-1);
|
strncat_P(addrstr, suffix_P[S_CTRL], sizeof(addrstr)-1);
|
||||||
|
|
||||||
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<cmdstr<<endl;
|
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<cmdstr<<endl;
|
||||||
|
#if not defined (NOIP)
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
mqttClient.publish(addrstr, cmdstr,true);
|
mqttClient.publish(addrstr, cmdstr,true);
|
||||||
@@ -1938,6 +1953,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
setFlag(sendFlags);
|
setFlag(sendFlags);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ itemCmd itemCmd::assignFrom(itemCmd from, short chanType)
|
|||||||
{
|
{
|
||||||
long coldPercent = map (colorT,0,100,100,30);
|
long coldPercent = map (colorT,0,100,100,30);
|
||||||
long hotPercent = map (colorT,0,100,30,100);
|
long hotPercent = map (colorT,0,100,30,100);
|
||||||
int rgbvLevel;
|
int rgbvLevel = 0;
|
||||||
|
|
||||||
if (rgbSaturation < 128) { // Using white
|
if (rgbSaturation < 128) { // Using white
|
||||||
param.w=map((127 - rgbSaturation) * rgbValue *hotPercent, 0, 127*255*100, 0, 255);
|
param.w=map((127 - rgbSaturation) * rgbValue *hotPercent, 0, 127*255*100, 0, 255);
|
||||||
|
|||||||
@@ -76,8 +76,10 @@ WiFiClient ethClient;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#if not defined (NOIP)
|
||||||
#include <Dhcp.h>
|
#include <Dhcp.h>
|
||||||
EthernetClient ethClient;
|
EthernetClient ethClient;
|
||||||
|
#endif //NOIP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OTA)
|
#if defined(OTA)
|
||||||
@@ -156,7 +158,9 @@ volatile int8_t configLocked = 0;
|
|||||||
ModbusMaster node;
|
ModbusMaster node;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
PubSubClient mqttClient(ethClient);
|
PubSubClient mqttClient(ethClient);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool wifiInitialized;
|
bool wifiInitialized;
|
||||||
|
|
||||||
@@ -401,6 +405,7 @@ int intopic;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
void mqttCallback(char *topic, byte *payload, unsigned int length)
|
void mqttCallback(char *topic, byte *payload, unsigned int length)
|
||||||
{
|
{
|
||||||
if (!payload || !length) {debugSerial<<F("\n")<<F("Empty: [")<<topic<<F("]")<<endl;return;}
|
if (!payload || !length) {debugSerial<<F("\n")<<F("Empty: [")<<topic<<F("]")<<endl;return;}
|
||||||
@@ -489,6 +494,8 @@ void printMACAddress() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //NOIP
|
||||||
|
|
||||||
char* getStringFromConfig(aJsonObject * a, int i)
|
char* getStringFromConfig(aJsonObject * a, int i)
|
||||||
{
|
{
|
||||||
aJsonObject * element = NULL;
|
aJsonObject * element = NULL;
|
||||||
@@ -568,7 +575,7 @@ void setupSyslog()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
lan_status lanLoop() {
|
lan_status lanLoop() {
|
||||||
|
|
||||||
#ifdef NOETHER
|
#ifdef NOETHER
|
||||||
@@ -1257,6 +1264,18 @@ if (WiFi.status() == WL_CONNECTED) {
|
|||||||
#endif //Ethernet
|
#endif //Ethernet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printCurentLanConfig() {
|
||||||
|
infoSerial << F("Current LAN config(ip,dns,gw,subnet):");
|
||||||
|
printIPAddress(Ethernet.localIP());
|
||||||
|
#if not defined(ESP8266) and not defined(ESP32)
|
||||||
|
printIPAddress(Ethernet.dnsServerIP());
|
||||||
|
#endif
|
||||||
|
printIPAddress(Ethernet.gatewayIP());
|
||||||
|
printIPAddress(Ethernet.subnetMask());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //NOIP
|
||||||
|
|
||||||
void resetHard() {
|
void resetHard() {
|
||||||
#ifdef RESET_PIN
|
#ifdef RESET_PIN
|
||||||
@@ -1275,7 +1294,9 @@ void resetHard() {
|
|||||||
int cmdFunctionHelp(int arg_cnt, char **args)
|
int cmdFunctionHelp(int arg_cnt, char **args)
|
||||||
{
|
{
|
||||||
printFirmwareVersionAndBuildOptions();
|
printFirmwareVersionAndBuildOptions();
|
||||||
|
#if not defined (NOIP)
|
||||||
printCurentLanConfig();
|
printCurentLanConfig();
|
||||||
|
#endif
|
||||||
// printFreeRam();
|
// printFreeRam();
|
||||||
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"
|
||||||
@@ -1296,16 +1317,7 @@ int cmdFunctionHelp(int arg_cnt, char **args)
|
|||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printCurentLanConfig() {
|
|
||||||
infoSerial << F("Current LAN config(ip,dns,gw,subnet):");
|
|
||||||
printIPAddress(Ethernet.localIP());
|
|
||||||
#if not defined(ESP8266) and not defined(ESP32)
|
|
||||||
printIPAddress(Ethernet.dnsServerIP());
|
|
||||||
#endif
|
|
||||||
printIPAddress(Ethernet.gatewayIP());
|
|
||||||
printIPAddress(Ethernet.subnetMask());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int cmdFunctionKill(int arg_cnt, char **args) {
|
int cmdFunctionKill(int arg_cnt, char **args) {
|
||||||
for (byte i = 1; i < 20; i++) {
|
for (byte i = 1; i < 20; i++) {
|
||||||
@@ -1453,11 +1465,15 @@ setupSyslog();
|
|||||||
|
|
||||||
printConfigSummary();
|
printConfigSummary();
|
||||||
configLoaded=true;
|
configLoaded=true;
|
||||||
|
#if not defined (NOIP)
|
||||||
if (ethClient.connected())
|
if (ethClient.connected())
|
||||||
{
|
{
|
||||||
ethClient.stop(); //Refresh MQTT connection
|
ethClient.stop(); //Refresh MQTT connection
|
||||||
lanStatus=IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
|
lanStatus=IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
lanStatus=IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER; ///change
|
||||||
|
#endif
|
||||||
if (lanStatus == OPERATION_NO_MQTT) lanStatus=IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
|
if (lanStatus == OPERATION_NO_MQTT) lanStatus=IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
|
||||||
|
|
||||||
configLocked--;
|
configLocked--;
|
||||||
@@ -1597,6 +1613,7 @@ infoSerial<<F("Serial debug level:")<<serialDebugLevel<<F("\nSyslog debug level:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
int cmdFunctionIp(int arg_cnt, char **args)
|
int cmdFunctionIp(int arg_cnt, char **args)
|
||||||
{
|
{
|
||||||
IPAddress ip0(0, 0, 0, 0);
|
IPAddress ip0(0, 0, 0, 0);
|
||||||
@@ -1651,31 +1668,6 @@ int cmdFunctionIp(int arg_cnt, char **args)
|
|||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmdFunctionClearEEPROM(int arg_cnt, char **args){
|
|
||||||
#ifdef FS_STORAGE
|
|
||||||
if (SPIFFS.format()) infoSerial<<F("FS Formatted\n");
|
|
||||||
#endif
|
|
||||||
if (sysConf.clear()) infoSerial<<F("EEPROM cleared\n");
|
|
||||||
#if defined(FS_STORAGE)
|
|
||||||
|
|
||||||
sysConfStream.open("/config.json",'r');
|
|
||||||
#else
|
|
||||||
sysConfStream.open(FN_CONFIG_JSON,'r');
|
|
||||||
#endif
|
|
||||||
sysConfStream.putEOF();
|
|
||||||
sysConfStream.close();
|
|
||||||
return 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cmdFunctionPwd(int arg_cnt, char **args)
|
|
||||||
{ //char empty[]="";
|
|
||||||
if (arg_cnt)
|
|
||||||
sysConf.setMQTTpwd(args[1]);
|
|
||||||
else sysConf.setMQTTpwd();
|
|
||||||
infoSerial<<F("MQTT Password updated\n");
|
|
||||||
return 200;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cmdFunctionOTAPwd(int arg_cnt, char **args)
|
int cmdFunctionOTAPwd(int arg_cnt, char **args)
|
||||||
{ //char empty[]="";
|
{ //char empty[]="";
|
||||||
if (arg_cnt)
|
if (arg_cnt)
|
||||||
@@ -1742,6 +1734,34 @@ errorSerial<<F("No IP adress")<<endl;
|
|||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //NOIP
|
||||||
|
|
||||||
|
int cmdFunctionClearEEPROM(int arg_cnt, char **args){
|
||||||
|
#ifdef FS_STORAGE
|
||||||
|
if (SPIFFS.format()) infoSerial<<F("FS Formatted\n");
|
||||||
|
#endif
|
||||||
|
if (sysConf.clear()) infoSerial<<F("EEPROM cleared\n");
|
||||||
|
#if defined(FS_STORAGE)
|
||||||
|
|
||||||
|
sysConfStream.open("/config.json",'r');
|
||||||
|
#else
|
||||||
|
sysConfStream.open(FN_CONFIG_JSON,'r');
|
||||||
|
#endif
|
||||||
|
sysConfStream.putEOF();
|
||||||
|
sysConfStream.close();
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cmdFunctionPwd(int arg_cnt, char **args)
|
||||||
|
{ //char empty[]="";
|
||||||
|
if (arg_cnt)
|
||||||
|
sysConf.setMQTTpwd(args[1]);
|
||||||
|
else sysConf.setMQTTpwd();
|
||||||
|
infoSerial<<F("MQTT Password updated\n");
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void printBool(bool arg) { (arg) ? infoSerial<<F("+") : infoSerial<<F("-"); }
|
void printBool(bool arg) { (arg) ? infoSerial<<F("+") : infoSerial<<F("-"); }
|
||||||
|
|
||||||
const char * headerKeys[]={"ETag"};
|
const char * headerKeys[]={"ETag"};
|
||||||
@@ -1756,6 +1776,8 @@ void headerHandlerProc(String header)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined(NOIP)
|
||||||
|
|
||||||
int loadConfigFromHttp()
|
int loadConfigFromHttp()
|
||||||
{
|
{
|
||||||
//macAddress * mac = sysConf.getMAC();
|
//macAddress * mac = sysConf.getMAC();
|
||||||
@@ -2013,6 +2035,8 @@ if (!sysConf.getServer(configServer,sizeof(configServer)))
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //NOIP
|
||||||
|
|
||||||
void preTransmission() {
|
void preTransmission() {
|
||||||
#ifdef CONTROLLINO
|
#ifdef CONTROLLINO
|
||||||
// set DE and RE on HIGH
|
// set DE and RE on HIGH
|
||||||
@@ -2313,7 +2337,10 @@ while ((digitalRead(CONFIG_CLEAN_PIN)==LOW) && !needClean)
|
|||||||
#endif
|
#endif
|
||||||
// Serial.print("Sig4=");
|
// Serial.print("Sig4=");
|
||||||
// Serial.println(FLASH_START[0],HEX);
|
// Serial.println(FLASH_START[0],HEX);
|
||||||
|
|
||||||
|
#if not defined(NOIP)
|
||||||
setupMacAddress(); //тут почему-то не считывается из флэш
|
setupMacAddress(); //тут почему-то не считывается из флэш
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _modbus
|
#ifdef _modbus
|
||||||
#ifdef CONTROLLINO
|
#ifdef CONTROLLINO
|
||||||
@@ -2334,7 +2361,7 @@ while ((digitalRead(CONFIG_CLEAN_PIN)==LOW) && !needClean)
|
|||||||
//owReady = 0;
|
//owReady = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
mqttClient.setCallback(mqttCallback);
|
mqttClient.setCallback(mqttCallback);
|
||||||
|
|
||||||
//#ifdef _artnet
|
//#ifdef _artnet
|
||||||
@@ -2365,7 +2392,8 @@ WiFi.onEvent(WiFiEvent);
|
|||||||
infoSerial<<F("Use W5500 pin: ");
|
infoSerial<<F("Use W5500 pin: ");
|
||||||
infoSerial<<QUOTE(W5500_CS_PIN)<<endl;
|
infoSerial<<QUOTE(W5500_CS_PIN)<<endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif //NOIP
|
||||||
loadConfigFromEEPROM();
|
loadConfigFromEEPROM();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2582,6 +2610,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 not defined (NOIP)
|
||||||
if (!mqttClient.connected() || ethernetIdleCount) return;
|
if (!mqttClient.connected() || ethernetIdleCount) return;
|
||||||
setTopic(topic,sizeof(topic),T_DEV);
|
setTopic(topic,sizeof(topic),T_DEV);
|
||||||
strncat_P(topic, stats_P, sizeof(topic)-1);
|
strncat_P(topic, stats_P, sizeof(topic)-1);
|
||||||
@@ -2601,7 +2630,7 @@ void publishStat(){
|
|||||||
strncat_P(topic, state_P, sizeof(topic)-1);
|
strncat_P(topic, state_P, sizeof(topic)-1);
|
||||||
strncpy_P(intbuf, ready_P, sizeof(intbuf)-1);
|
strncpy_P(intbuf, ready_P, sizeof(intbuf)-1);
|
||||||
mqttClient.publish(topic,intbuf,true);
|
mqttClient.publish(topic,intbuf,true);
|
||||||
|
#endif //NOIP
|
||||||
#ifdef CRYPT
|
#ifdef CRYPT
|
||||||
RNG.rand((uint8_t *) &cryptoSalt,sizeof(cryptoSalt));
|
RNG.rand((uint8_t *) &cryptoSalt,sizeof(cryptoSalt));
|
||||||
setTopic(topic,sizeof(topic),T_DEV);
|
setTopic(topic,sizeof(topic),T_DEV);
|
||||||
@@ -2613,6 +2642,7 @@ void publishStat(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
void setupMacAddress() {
|
void setupMacAddress() {
|
||||||
//Check MAC, stored in NVRAM
|
//Check MAC, stored in NVRAM
|
||||||
|
|
||||||
@@ -2645,6 +2675,7 @@ if (!sysConf.getMAC()) {
|
|||||||
}
|
}
|
||||||
printMACAddress();
|
printMACAddress();
|
||||||
}
|
}
|
||||||
|
#endif //NOIP
|
||||||
|
|
||||||
void setupCmdArduino() {
|
void setupCmdArduino() {
|
||||||
//cmdInit(uint32_t(SERIAL_BAUD));
|
//cmdInit(uint32_t(SERIAL_BAUD));
|
||||||
@@ -2653,15 +2684,19 @@ void setupCmdArduino() {
|
|||||||
cmdAdd("help", cmdFunctionHelp);
|
cmdAdd("help", cmdFunctionHelp);
|
||||||
cmdAdd("save", cmdFunctionSave);
|
cmdAdd("save", cmdFunctionSave);
|
||||||
cmdAdd("load", cmdFunctionLoad);
|
cmdAdd("load", cmdFunctionLoad);
|
||||||
|
#if not defined (NOIP)
|
||||||
cmdAdd("get", cmdFunctionGet);
|
cmdAdd("get", cmdFunctionGet);
|
||||||
#ifndef FLASH_64KB
|
#ifndef FLASH_64KB
|
||||||
cmdAdd("mac", cmdFunctionSetMac);
|
cmdAdd("mac", cmdFunctionSetMac);
|
||||||
#endif
|
#endif
|
||||||
|
cmdAdd("ip", cmdFunctionIp);
|
||||||
|
cmdAdd("otapwd", cmdFunctionOTAPwd);
|
||||||
|
#endif //NOIP
|
||||||
cmdAdd("kill", cmdFunctionKill);
|
cmdAdd("kill", cmdFunctionKill);
|
||||||
//cmdAdd("req", cmdFunctionReq);
|
//cmdAdd("req", cmdFunctionReq);
|
||||||
cmdAdd("ip", cmdFunctionIp);
|
|
||||||
cmdAdd("pwd", cmdFunctionPwd);
|
cmdAdd("pwd", cmdFunctionPwd);
|
||||||
cmdAdd("otapwd", cmdFunctionOTAPwd);
|
|
||||||
cmdAdd("clear",cmdFunctionClearEEPROM);
|
cmdAdd("clear",cmdFunctionClearEEPROM);
|
||||||
cmdAdd("reboot",cmdFunctionReboot);
|
cmdAdd("reboot",cmdFunctionReboot);
|
||||||
cmdAdd("log",cmdFunctionLoglevel);
|
cmdAdd("log",cmdFunctionLoglevel);
|
||||||
@@ -2683,6 +2718,8 @@ void loop_main() {
|
|||||||
wdt_res();
|
wdt_res();
|
||||||
yield();
|
yield();
|
||||||
cmdPoll();
|
cmdPoll();
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
if (lanLoop() > HAVE_IP_ADDRESS) {
|
||||||
mqttClient.loop();
|
mqttClient.loop();
|
||||||
|
|
||||||
@@ -2703,7 +2740,9 @@ void loop_main() {
|
|||||||
MDNS.update();
|
MDNS.update();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif //NOIP
|
||||||
|
|
||||||
|
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
yield();
|
yield();
|
||||||
@@ -2776,6 +2815,8 @@ inputLoop(CHECK_INPUT);
|
|||||||
if (initializedListeners) ipmodbusLoop();
|
if (initializedListeners) ipmodbusLoop();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
void ethernetIdle(void){
|
void ethernetIdle(void){
|
||||||
ethernetIdleCount++;
|
ethernetIdleCount++;
|
||||||
wdt_res();
|
wdt_res();
|
||||||
@@ -2785,7 +2826,7 @@ ethernetIdleCount++;
|
|||||||
cmdPoll();
|
cmdPoll();
|
||||||
ethernetIdleCount--;
|
ethernetIdleCount--;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
void modbusIdle(void) {
|
void modbusIdle(void) {
|
||||||
|
|
||||||
@@ -2796,10 +2837,11 @@ void modbusIdle(void) {
|
|||||||
yield();
|
yield();
|
||||||
inputLoop(CHECK_INPUT);
|
inputLoop(CHECK_INPUT);
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
if (lanLoop() > HAVE_IP_ADDRESS)
|
if (lanLoop() > HAVE_IP_ADDRESS)
|
||||||
{ // Begin network runners
|
{ // Begin network runners
|
||||||
yield();
|
yield();
|
||||||
mqttClient.loop();
|
mqttClient.loop();
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet && initializedListeners) artnet->read();
|
if (artnet && initializedListeners) artnet->read();
|
||||||
#endif
|
#endif
|
||||||
@@ -2816,6 +2858,8 @@ void modbusIdle(void) {
|
|||||||
#endif
|
#endif
|
||||||
} //End network runners
|
} //End network runners
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
DMXCheck();
|
DMXCheck();
|
||||||
#endif
|
#endif
|
||||||
@@ -3027,14 +3071,18 @@ void thermoLoop(void) {
|
|||||||
if (isTimeOver(tStore.timestamp16,millisNZ(8) & 0xFFFF,PERIOD_THERMOSTAT_FAILED >> 8,0xFFFF))
|
if (isTimeOver(tStore.timestamp16,millisNZ(8) & 0xFFFF,PERIOD_THERMOSTAT_FAILED >> 8,0xFFFF))
|
||||||
{
|
{
|
||||||
errorSerial<<thermoItem->name<<F(" Alarm Expired\n");
|
errorSerial<<thermoItem->name<<F(" Alarm Expired\n");
|
||||||
|
#if not defined (NOIP)
|
||||||
mqttClient.publish("/alarm/snsr", thermoItem->name);
|
mqttClient.publish("/alarm/snsr", thermoItem->name);
|
||||||
|
#endif
|
||||||
tStore.timestamp16=0; //Stop termostat
|
tStore.timestamp16=0; //Stop termostat
|
||||||
thermostat.setExt(tStore.asint);
|
thermostat.setExt(tStore.asint);
|
||||||
thermoRelay(thermoPin,HEATER_ERROR);
|
thermoRelay(thermoPin,HEATER_ERROR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Not expired yet
|
{ // Not expired yet
|
||||||
|
#if not defined(NOIP)
|
||||||
if (curTemp > overHeatTemp) mqttClient.publish("/alarm/ovrht", thermoItem->name);
|
if (curTemp > overHeatTemp) mqttClient.publish("/alarm/ovrht", thermoItem->name);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!active) thermoRelay(thermoPin,HEATER_OFF);//OFF
|
if (!active) thermoRelay(thermoPin,HEATER_OFF);//OFF
|
||||||
else if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) thermoRelay(thermoPin,HEATER_HEAT);//ON
|
else if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) thermoRelay(thermoPin,HEATER_HEAT);//ON
|
||||||
|
|||||||
@@ -8,13 +8,17 @@
|
|||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
#include <watchdog.h>
|
#include <watchdog.h>
|
||||||
#include <ArduinoHttpClient.h>
|
#if not defined (NOIP)
|
||||||
|
#include <ArduinoHttpClient.h>
|
||||||
|
#endif
|
||||||
//#include "TimerInterrupt_Generic.h"
|
//#include "TimerInterrupt_Generic.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
#include "HTTPClient.h"
|
#if not defined (NOIP)
|
||||||
//#include <ArduinoHttpClient.h>
|
#include "HTTPClient.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -35,7 +39,7 @@
|
|||||||
//#define Ethernet WiFi
|
//#define Ethernet WiFi
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined ARDUINO_ARCH_ESP32
|
#if defined (ARDUINO_ARCH_ESP32)
|
||||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||||
//#include "SPIFFS.h"
|
//#include "SPIFFS.h"
|
||||||
//#include <EEPROM.h>
|
//#include <EEPROM.h>
|
||||||
@@ -58,7 +62,7 @@
|
|||||||
#include <ArduinoHttpClient.h>
|
#include <ArduinoHttpClient.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_STM32
|
#if defined (ARDUINO_ARCH_STM32) and not defined (NOIP)
|
||||||
#include "HttpClient.h"
|
#include "HttpClient.h"
|
||||||
//#include "UIPEthernet.h"
|
//#include "UIPEthernet.h"
|
||||||
//#include <NRFFlashStorage.h>
|
//#include <NRFFlashStorage.h>
|
||||||
@@ -156,7 +160,8 @@ extern Streamlog errorSerial;
|
|||||||
#include <ESP8266mDNS.h>
|
#include <ESP8266mDNS.h>
|
||||||
#endif
|
#endif
|
||||||
#define Ethernet WiFi
|
#define Ethernet WiFi
|
||||||
#else //Wired connection
|
#else
|
||||||
|
#if not defined (NOIP) //Wired connection
|
||||||
#ifdef Wiz5500
|
#ifdef Wiz5500
|
||||||
#include <Ethernet2.h>
|
#include <Ethernet2.h>
|
||||||
#else
|
#else
|
||||||
@@ -166,6 +171,7 @@ extern Streamlog errorSerial;
|
|||||||
#include <Ethernet.h>
|
#include <Ethernet.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -190,7 +196,9 @@ extern Streamlog errorSerial;
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "textconst.h"
|
#include "textconst.h"
|
||||||
#include <PubSubClient.h>
|
#if not defined (NOIP)
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
#endif
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "aJSON.h"
|
#include "aJSON.h"
|
||||||
@@ -233,11 +241,16 @@ typedef union {
|
|||||||
|
|
||||||
bool isNotRetainingStatus();
|
bool isNotRetainingStatus();
|
||||||
|
|
||||||
|
#if not defined (NOIP)
|
||||||
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
||||||
|
|
||||||
void printMACAddress();
|
void printMACAddress();
|
||||||
|
|
||||||
lan_status lanLoop();
|
lan_status lanLoop();
|
||||||
|
int loadConfigFromHttp();
|
||||||
|
void onInitialStateInitLAN();
|
||||||
|
void onMQTTConnect();
|
||||||
|
void ip_ready_config_loaded_connecting_to_broker();
|
||||||
|
void setupMacAddress();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef OWIRE_DISABLE
|
#ifndef OWIRE_DISABLE
|
||||||
void Changed(int i, DeviceAddress addr, float currentTemp);
|
void Changed(int i, DeviceAddress addr, float currentTemp);
|
||||||
@@ -274,7 +287,7 @@ void saveFlash(short n, IPAddress& ip);
|
|||||||
int ipLoadFromFlash(short n, IPAddress &ip);
|
int ipLoadFromFlash(short n, IPAddress &ip);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int loadConfigFromHttp();
|
|
||||||
|
|
||||||
void preTransmission();
|
void preTransmission();
|
||||||
|
|
||||||
@@ -306,8 +319,6 @@ void printConfigSummary();
|
|||||||
|
|
||||||
void setupCmdArduino();
|
void setupCmdArduino();
|
||||||
|
|
||||||
void setupMacAddress();
|
|
||||||
|
|
||||||
void printFirmwareVersionAndBuildOptions();
|
void printFirmwareVersionAndBuildOptions();
|
||||||
|
|
||||||
bool IsThermostat(const aJsonObject *item);
|
bool IsThermostat(const aJsonObject *item);
|
||||||
@@ -316,14 +327,9 @@ bool disabledDisconnected(const aJsonObject *thermoExtensionArray, int thermoLat
|
|||||||
|
|
||||||
void resetHard();
|
void resetHard();
|
||||||
|
|
||||||
void onInitialStateInitLAN();
|
|
||||||
|
|
||||||
void ip_ready_config_loaded_connecting_to_broker();
|
|
||||||
|
|
||||||
void printCurentLanConfig();
|
void printCurentLanConfig();
|
||||||
|
|
||||||
void onMQTTConnect();
|
|
||||||
|
|
||||||
int16_t attachMaturaTimer();
|
int16_t attachMaturaTimer();
|
||||||
|
|
||||||
//void printFreeRam();
|
//void printFreeRam();
|
||||||
|
|||||||
@@ -125,10 +125,13 @@ switch (cmd.getCmd()){
|
|||||||
switch (cType)
|
switch (cType)
|
||||||
{
|
{
|
||||||
case CH_PWM:
|
case CH_PWM:
|
||||||
{ short k;
|
{ short k ;
|
||||||
if (authorized || !isProtectedPin(iaddr))
|
if (authorized || !isProtectedPin(iaddr))
|
||||||
|
{
|
||||||
analogWrite(iaddr, k=cmd.getPercents255(inverse));
|
analogWrite(iaddr, k=cmd.getPercents255(inverse));
|
||||||
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
||||||
|
}
|
||||||
|
else errorSerial<<F("Pin:")<<iaddr<<F(" protected")<<endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case CH_RGB:
|
case CH_RGB:
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ if (item) item->setExt(0);
|
|||||||
//if (item->getCmd()) item->setFlag(FLAG_COMMAND);
|
//if (item->getCmd()) item->setFlag(FLAG_COMMAND);
|
||||||
//if (item->itemVal) item->setFlag(FLAG_PARAMETERS);
|
//if (item->itemVal) item->setFlag(FLAG_PARAMETERS);
|
||||||
setStatus(CST_INITIALIZED);
|
setStatus(CST_INITIALIZED);
|
||||||
if (item->isActive()>0) ///????
|
if (item && (item->isActive()>0)) ///????
|
||||||
{
|
{
|
||||||
item->setExt(millisNZ());
|
item->setExt(millisNZ());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ bool textMode;
|
|||||||
uint16_t contentType;
|
uint16_t contentType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
seekableStream(unsigned int size):Stream(),streamSize(size) {};
|
seekableStream(unsigned int size):Stream(),streamSize(size),textMode(false),contentType(0) {};
|
||||||
virtual bool checkPermissions(char mode) {return true;};
|
virtual bool checkPermissions(char mode) {return true;};
|
||||||
unsigned int getSize() {return streamSize;}
|
unsigned int getSize() {return streamSize;}
|
||||||
void setSize (unsigned int size) {streamSize = size;};
|
void setSize (unsigned int size) {streamSize = size;};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Streamlog::Streamlog (SerialPortType * _serialPort, uint8_t _severity, uint8_t
|
|||||||
{
|
{
|
||||||
serialPort=_serialPort;
|
serialPort=_serialPort;
|
||||||
severity=_severity;
|
severity=_severity;
|
||||||
|
ledPattern=_ledPattern;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ extern aJsonObject * topics;
|
|||||||
class templateStream : public Stream
|
class templateStream : public Stream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
templateStream(char *s, short sfx=0) : str(s), pos(0), val(NULL), valpos(0), bucket(0),suffix(sfx) { }
|
templateStream(char *s, short sfx=0) : str(s), pos(0), val(NULL), valpos(0), bucket(0),suffix(sfx) {buffer[0]='\0'; }
|
||||||
|
|
||||||
// Stream methods
|
// Stream methods
|
||||||
virtual int available() { return str[pos]; }
|
virtual int available() { return str[pos]; }
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ e-mail anklimov@gmail.com
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
|
#if not defined (NOIP)
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
extern PubSubClient mqttClient;
|
||||||
|
extern int8_t ethernetIdleCount;
|
||||||
|
#endif
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
#include "templateStr.h"
|
#include "templateStr.h"
|
||||||
|
|
||||||
@@ -38,10 +42,6 @@ e-mail anklimov@gmail.com
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int8_t configLocked;
|
extern int8_t configLocked;
|
||||||
extern int8_t ethernetIdleCount;
|
|
||||||
extern PubSubClient mqttClient;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32)
|
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@@ -742,12 +742,13 @@ switch (cmdType)
|
|||||||
|
|
||||||
|
|
||||||
//strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
//strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
|
#if not defined (NOIP)
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
{
|
{
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
mqttClient.publish(addrstr, emitCommand , true);
|
mqttClient.publish(addrstr, emitCommand , true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} // emit
|
} // emit
|
||||||
|
|
||||||
if (item && item->type == aJson_String) {
|
if (item && item->type == aJson_String) {
|
||||||
@@ -827,7 +828,7 @@ serialParamType str2SerialParam(char * str)
|
|||||||
{
|
{
|
||||||
|
|
||||||
//debugSerial<< i << F(" ") << pgm_read_word_near(&serialModes_P[i].mode)<< endl;
|
//debugSerial<< i << F(" ") << pgm_read_word_near(&serialModes_P[i].mode)<< endl;
|
||||||
if (sizeof(serialModesNum)==4)
|
if (sizeof(serialParamType)==4)
|
||||||
return pgm_read_dword_near(&serialModes_P[i].mode);
|
return pgm_read_dword_near(&serialModes_P[i].mode);
|
||||||
else
|
else
|
||||||
return pgm_read_word_near(&serialModes_P[i].mode);
|
return pgm_read_word_near(&serialModes_P[i].mode);
|
||||||
|
|||||||
@@ -911,6 +911,76 @@ lib_deps =
|
|||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|
||||||
|
[env:stm32-noip]
|
||||||
|
platform = ststm32
|
||||||
|
board = genericSTM32F103RB
|
||||||
|
;olimexino
|
||||||
|
board_build.mcu = stm32f103rbt6
|
||||||
|
;STM32Duino
|
||||||
|
;generic_stm32f103r
|
||||||
|
;board_build.ldscript=ldscripts\stm32f103rb_bootloader.ld
|
||||||
|
board_build.f_cpu = 72000000L
|
||||||
|
framework = arduino
|
||||||
|
;board_build.core = maple
|
||||||
|
;board_build.core = maple // STM32Duino (DEFAULT) // STM32L0
|
||||||
|
;board_build.core = stm32lo
|
||||||
|
;monitor_dtr = 1
|
||||||
|
upload_protocol = serial
|
||||||
|
;debug_tool = cmsis-dap
|
||||||
|
build_flags = !python get_build_flags.py stm32-noip
|
||||||
|
lib_ignore =
|
||||||
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
|
DHT sensor library for ESPx
|
||||||
|
DmxDue
|
||||||
|
DueFlashStorage
|
||||||
|
ESPDMX
|
||||||
|
ESP-Dmx
|
||||||
|
WifiManager
|
||||||
|
FastLED
|
||||||
|
UIPEthernet
|
||||||
|
DMXSerial
|
||||||
|
DmxSimple
|
||||||
|
httpClient
|
||||||
|
SD
|
||||||
|
PrintEx
|
||||||
|
Ethernet2
|
||||||
|
Artnet
|
||||||
|
Ethernet3
|
||||||
|
WebServer
|
||||||
|
ESP_EEPROM
|
||||||
|
DHT sensor library
|
||||||
|
DallasTemperature
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DS2482_OneWire
|
||||||
|
ModbusMaster
|
||||||
|
Syslog
|
||||||
|
NRFFlashStorage
|
||||||
|
ClosedCube HDC1080
|
||||||
|
SparkFun CCS811 Arduino Library
|
||||||
|
M5Stack
|
||||||
|
ArduinoOTA
|
||||||
|
lib_deps =
|
||||||
|
EEPROM
|
||||||
|
https://github.com/anklimov/aJson
|
||||||
|
https://github.com/anklimov/CmdArduino
|
||||||
|
; ArduinoHttpClient
|
||||||
|
; https://github.com/anklimov/pubsubclient.git
|
||||||
|
Streaming
|
||||||
|
; Ethernet
|
||||||
|
|
||||||
|
Adafruit NeoPixel
|
||||||
|
Adafruit MCP23017 Arduino Library
|
||||||
|
Adafruit BusIO
|
||||||
|
SPI
|
||||||
|
br3ttb/PID@^1.2.1
|
||||||
|
; ArduinoMDNS
|
||||||
|
https://github.com/khoih-prog/TimerInterrupt_Generic.git
|
||||||
|
;https://github.com/anklimov/ModbusMaster
|
||||||
|
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
|
||||||
; Run the following command to upload with this environment
|
; Run the following command to upload with this environment
|
||||||
; pio run -e Upload_ISP -t upload
|
; pio run -e Upload_ISP -t upload
|
||||||
[env:Upload_ISP]
|
[env:Upload_ISP]
|
||||||
|
|||||||
Reference in New Issue
Block a user