mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
Beginning to add homie convention compatibility https://homieiot.github.io/specification/
This commit is contained in:
BIN
.vscode/.browse.c_cpp.db
vendored
Normal file
BIN
.vscode/.browse.c_cpp.db
vendored
Normal file
Binary file not shown.
5
.vscode/arduino.json
vendored
Normal file
5
.vscode/arduino.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"board": "esp8266:esp8266:d1",
|
||||||
|
"configuration": "CpuFrequency=80,FlashSize=4M1M,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,UploadSpeed=921600",
|
||||||
|
"port": "/dev/cu.usbmodem1411"
|
||||||
|
}
|
||||||
113
.vscode/c_cpp_properties.json
vendored
Normal file
113
.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
{
|
||||||
|
"!!! WARNING !!!": "PLEASE DO NOT MODIFY THIS FILE! USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Mac",
|
||||||
|
"macFrameworkPath": [],
|
||||||
|
"includePath": [
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/cores/sam",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/libsam",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/CMSIS/Include",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/Device/ATMEL",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/variants/arduino_due_x",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Adafruit Unified Sensor_ID31",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ArduinoHttpClient/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Artnet",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/CmdArduino",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DHT sensor library_ID19",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DS2482_OneWire",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DallasTemperature",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/Wire/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DmxDue",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DueFlashStorage/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Ethernet2/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/FastLED_ID126",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ModbusMaster/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PrintEx/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PubSubClient/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SD_ID161",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/SPI/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SdFat_ID322/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Streaming_ID560",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Syslog/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/aJson",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ArduinoJson_ID64/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/AsyncMqttClient_ID346/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Bounce2_ID1106/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ESP Async WebServer_ID306/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Homie_ID555/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/HttpClient_ID66",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/HID/src",
|
||||||
|
"/Users/andrey/.platformio/packages/tool-unity",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/include",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/lighthub",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"browse": {
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": "${workspaceRoot}/.vscode/.browse.c_cpp.db",
|
||||||
|
"path": [
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/cores/sam",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/libsam",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/CMSIS/Include",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/Device/ATMEL",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/variants/arduino_due_x",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Adafruit Unified Sensor_ID31",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ArduinoHttpClient/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Artnet",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/CmdArduino",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DHT sensor library_ID19",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DS2482_OneWire",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DallasTemperature",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/Wire/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DmxDue",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DueFlashStorage/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Ethernet2/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/FastLED_ID126",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ModbusMaster/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PrintEx/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PubSubClient/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SD_ID161",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/SPI/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SdFat_ID322/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Streaming_ID560",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Syslog/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/aJson",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ArduinoJson_ID64/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/AsyncMqttClient_ID346/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Bounce2_ID1106/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ESP Async WebServer_ID306/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Homie_ID555/src",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/HttpClient_ID66",
|
||||||
|
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/HID/src",
|
||||||
|
"/Users/andrey/.platformio/packages/tool-unity",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/include",
|
||||||
|
"/Users/andrey/Documents/Arduino/lighthub/lighthub",
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"defines": [
|
||||||
|
"PLATFORMIO=30603",
|
||||||
|
"__SAM3X8E__",
|
||||||
|
"ARDUINO_ARCH_SAM",
|
||||||
|
"ARDUINO_SAM_DUE",
|
||||||
|
"Wiz5500",
|
||||||
|
"ARTNET_ENABLE",
|
||||||
|
"F_CPU=84000000L",
|
||||||
|
"USBCON",
|
||||||
|
"ARDUINO=10805",
|
||||||
|
"USB_VID=0x2341",
|
||||||
|
"USB_PID=0x003E",
|
||||||
|
"USB_PRODUCT=\"Arduino Due\"",
|
||||||
|
"USB_MANUFACTURER=\"Arduino\"",
|
||||||
|
"printf=iprintf",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"intelliSenseMode": "clang-x64",
|
||||||
|
"cStandard": "c11",
|
||||||
|
"cppStandard": "c++11",
|
||||||
|
"compilerPath": "/Users/andrey/.platformio/packages/toolchain-gccarmnoneeabi@1.40804.0/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m3"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
7
.vscode/extensions.json
vendored
Normal file
7
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
]
|
||||||
|
}
|
||||||
34
.vscode/launch.json
vendored
Normal file
34
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
||||||
|
|
||||||
|
// PIO Unified Debugger
|
||||||
|
//
|
||||||
|
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
||||||
|
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
||||||
|
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "platformio-debug",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "PIO Debug",
|
||||||
|
"executable": "/Users/andrey/Documents/Arduino/lighthub/.pioenvs/due-5500/firmware.elf",
|
||||||
|
"toolchainBinDir": "/Users/andrey/.platformio/packages/toolchain-gccarmnoneeabi@1.40804.0/bin",
|
||||||
|
"svdPath": "/Users/andrey/.platformio/platforms/atmelsam/misc/svd/ATSAM3X8E.svd",
|
||||||
|
"preLaunchTask": {
|
||||||
|
"type": "PlatformIO",
|
||||||
|
"task": "Pre-Debug"
|
||||||
|
},
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "platformio-debug",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "PIO Debug (skip Pre-Debug)",
|
||||||
|
"executable": "/Users/andrey/Documents/Arduino/lighthub/.pioenvs/due-5500/firmware.elf",
|
||||||
|
"toolchainBinDir": "/Users/andrey/.platformio/packages/toolchain-gccarmnoneeabi@1.40804.0/bin",
|
||||||
|
"svdPath": "/Users/andrey/.platformio/platforms/atmelsam/misc/svd/ATSAM3X8E.svd",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"terminal.integrated.env.osx": {
|
||||||
|
"PATH": "/Users/andrey/.platformio/penv/bin:/Users/andrey/.platformio/penv:/usr/local/opt/python@2/bin:/opt/local/sbin:/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS",
|
||||||
|
"PLATFORMIO_CALLER": "vscode"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,6 @@ GIT: https://github.com/anklimov/lighthub
|
|||||||
e-mail anklimov@gmail.com
|
e-mail anklimov@gmail.com
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define D_UPDATED1 1
|
#define D_UPDATED1 1
|
||||||
#define D_UPDATED2 2
|
#define D_UPDATED2 2
|
||||||
#define D_UPDATED3 4
|
#define D_UPDATED3 4
|
||||||
|
|||||||
31
lighthub/homiedef.h
Normal file
31
lighthub/homiedef.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
const char state_P[] PROGMEM = "$state";
|
||||||
|
const char disconnected_P[] PROGMEM = "disconnected";
|
||||||
|
const char ready_P[] PROGMEM = "ready";
|
||||||
|
|
||||||
|
const char homie_P[] PROGMEM = "$homie";
|
||||||
|
const char homiever_P[] PROGMEM = "2.1.0";
|
||||||
|
|
||||||
|
const char name_P[] PROGMEM = "$name";
|
||||||
|
const char nameval_P[] PROGMEM = "LightHub";
|
||||||
|
|
||||||
|
const char nodes_P[] PROGMEM = "$nodes";
|
||||||
|
const char color_P[] PROGMEM = "color";
|
||||||
|
|
||||||
|
const char datatype_P[] PROGMEM = "$datatype";
|
||||||
|
|
||||||
|
const char float_P[] PROGMEM = "float";
|
||||||
|
const char hsv_P[] PROGMEM = "hsv";
|
||||||
|
const char int_P[] PROGMEM = "integer";
|
||||||
|
const char enum_P[] PROGMEM = "enum";
|
||||||
|
const char format_P[] PROGMEM = "$format";
|
||||||
|
const char true_P[] PROGMEM = "true";
|
||||||
|
const char false_P[] PROGMEM = "false";
|
||||||
|
|
||||||
|
const char enumformat_P[] PROGMEM = "ON,OFF,HALT,REST,XON,XOFF,TOGGLE";
|
||||||
|
const char intformat_P[] PROGMEM = "0-100";
|
||||||
|
|
||||||
|
const char stats_P[] PROGMEM = "$stats";
|
||||||
|
const char statsval_P[] PROGMEM = "uptime,freeheap";
|
||||||
|
const char uptime_P[] PROGMEM = "uptime";
|
||||||
|
const char freeheap_P[] PROGMEM = "freeheap";
|
||||||
@@ -250,9 +250,8 @@ int Item::Ctrl(char * payload, boolean send){
|
|||||||
|
|
||||||
int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||||
|
|
||||||
|
|
||||||
debugSerial<<F(" MEM=")<<freeRam()<<F(" Cmd=")<<cmd<<F(" Par: ");
|
debugSerial<<F(" MEM=")<<freeRam()<<F(" Cmd=")<<cmd<<F(" Par: ");
|
||||||
|
if (!itemArr) return -1;
|
||||||
int Par[MAXCTRLPAR] = {0, 0, 0};
|
int Par[MAXCTRLPAR] = {0, 0, 0};
|
||||||
if (Parameters)
|
if (Parameters)
|
||||||
for (short i=0;i<n && i<MAXCTRLPAR;i++){
|
for (short i=0;i<n && i<MAXCTRLPAR;i++){
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ e-mail anklimov@gmail.com
|
|||||||
#define CH_GROUP 7 //Group pseudochannel
|
#define CH_GROUP 7 //Group pseudochannel
|
||||||
#define CH_VCTEMP 8 //Vacom PID regulator
|
#define CH_VCTEMP 8 //Vacom PID regulator
|
||||||
#define CH_VC 9 //Vacom modbus motor regulator
|
#define CH_VC 9 //Vacom modbus motor regulator
|
||||||
|
#define CH_AC_HAIER 10 //AC Haier
|
||||||
#define CH_WHITE 127//
|
#define CH_WHITE 127//
|
||||||
|
|
||||||
#define CMD_ON 1
|
#define CMD_ON 1
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ PWM Out
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "homiedef.h"
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
DueFlashStorage EEPROM;
|
DueFlashStorage EEPROM;
|
||||||
@@ -121,6 +122,7 @@ const char outprefix[] PROGMEM = OUTTOPIC;
|
|||||||
const char inprefix[] PROGMEM = INTOPIC;
|
const char inprefix[] PROGMEM = INTOPIC;
|
||||||
const char configserver[] PROGMEM = CONFIG_SERVER;
|
const char configserver[] PROGMEM = CONFIG_SERVER;
|
||||||
|
|
||||||
|
|
||||||
unsigned int UniqueID[5] = {0,0,0,0,0};
|
unsigned int UniqueID[5] = {0,0,0,0,0};
|
||||||
|
|
||||||
aJsonObject *root = NULL;
|
aJsonObject *root = NULL;
|
||||||
@@ -349,6 +351,87 @@ lan_status lanLoop() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void onMQTTConnect(){
|
||||||
|
char topic[64] = "";
|
||||||
|
char buf[128] = "";
|
||||||
|
|
||||||
|
// High level homie topics publishing
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, state_P, sizeof(topic));
|
||||||
|
mqttClient.publish_P(topic,ready_P,true);
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, homie_P, sizeof(topic));
|
||||||
|
mqttClient.publish_P(topic,homiever_P,true);
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, name_P, sizeof(topic));
|
||||||
|
mqttClient.publish_P(topic,nameval_P,true);
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, name_P, sizeof(topic));
|
||||||
|
mqttClient.publish_P(topic,nameval_P,true);
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, stats_P, sizeof(topic));
|
||||||
|
mqttClient.publish_P(topic,statsval_P,true);
|
||||||
|
|
||||||
|
strncat_P(topic, stats_P, sizeof(topic));
|
||||||
|
if (items) {
|
||||||
|
char datatype[32]="\0";
|
||||||
|
char format [64]="\0";
|
||||||
|
aJsonObject * item = items->child;
|
||||||
|
while (items && item)
|
||||||
|
if (item->type == aJson_Array && aJson.getArraySize(item)>0) {
|
||||||
|
|
||||||
|
strncat_P(buf,item->name,sizeof(buf));
|
||||||
|
strncat(buf,",",sizeof(buf));
|
||||||
|
|
||||||
|
switch ( aJson.getArrayItem(item, I_TYPE)->valueint) {
|
||||||
|
case CH_THERMO:
|
||||||
|
strncat_P(datatype,float_P,sizeof(datatype));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CH_RELAY:
|
||||||
|
strncpy_P(datatype,enum_P,sizeof(datatype));
|
||||||
|
strncpy_P(format,enumformat_P,sizeof(format));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CH_RGBW:
|
||||||
|
case CH_RGB:
|
||||||
|
strncpy_P(datatype,color_P,sizeof(datatype));
|
||||||
|
strncpy_P(format,hsv_P,sizeof(format));
|
||||||
|
break;
|
||||||
|
case CH_DIMMER:
|
||||||
|
case CH_MODBUS:
|
||||||
|
case CH_PWM:
|
||||||
|
case CH_VCTEMP:
|
||||||
|
case CH_VC:
|
||||||
|
strncpy_P(datatype,int_P,sizeof(datatype));
|
||||||
|
strncpy_P(format,intformat_P,sizeof(format));
|
||||||
|
break;
|
||||||
|
} //switch
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic,item->name,sizeof(topic));
|
||||||
|
strncat(topic,"/",sizeof(topic));
|
||||||
|
strncat_P(topic,datatype_P,sizeof(topic));
|
||||||
|
mqttClient.publish(topic,datatype,true);
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic,item->name,sizeof(topic));
|
||||||
|
strncat(topic,"/",sizeof(topic));
|
||||||
|
strncat_P(topic,format_P,sizeof(topic));
|
||||||
|
mqttClient.publish(topic,format,true);
|
||||||
|
item = item->next;
|
||||||
|
} //if
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, nodes_P, sizeof(topic));
|
||||||
|
mqttClient.publish(topic,buf,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ip_ready_config_loaded_connecting_to_broker() {
|
void ip_ready_config_loaded_connecting_to_broker() {
|
||||||
short n = 0;
|
short n = 0;
|
||||||
int port = 1883;
|
int port = 1883;
|
||||||
@@ -387,9 +470,18 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
mqttClient.setServer(servername, port);
|
mqttClient.setServer(servername, port);
|
||||||
mqttClient.setCallback(mqttCallback);
|
mqttClient.setCallback(mqttCallback);
|
||||||
|
|
||||||
|
char willMessage[16];
|
||||||
|
char willTopic[32];
|
||||||
|
|
||||||
|
strncpy_P(willMessage,disconnected_P,sizeof(willMessage));
|
||||||
|
|
||||||
|
strncpy_P(willTopic, outprefix, sizeof(willTopic));
|
||||||
|
strncat_P(willTopic, state_P, sizeof(willTopic));
|
||||||
|
|
||||||
|
|
||||||
debugSerial<<F("\nAttempting MQTT connection to ")<<servername<<F(":")<<port<<F(" user:")<<user<<F(" ...");
|
debugSerial<<F("\nAttempting MQTT connection to ")<<servername<<F(":")<<port<<F(" user:")<<user<<F(" ...");
|
||||||
wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
|
wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
|
||||||
if (mqttClient.connect(client_id, user, password)) {
|
if (mqttClient.connect(client_id, user, password,willTopic,MQTTQOS1,true,willMessage)) {
|
||||||
mqttErrorRate = 0;
|
mqttErrorRate = 0;
|
||||||
debugSerial<<F("connected as ")<<client_id <<endl;
|
debugSerial<<F("connected as ")<<client_id <<endl;
|
||||||
wdt_en();
|
wdt_en();
|
||||||
@@ -399,14 +491,15 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
|
|
||||||
strncpy_P(buf, outprefix, sizeof(buf));
|
strncpy_P(buf, outprefix, sizeof(buf));
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "#", sizeof(buf));
|
||||||
mqttClient.subscribe(buf);
|
mqttClient.subscribe(buf,MQTTQOS1);
|
||||||
|
|
||||||
//Subscribing for command topics
|
//Subscribing for command topics
|
||||||
strncpy_P(buf, inprefix, sizeof(buf));
|
strncpy_P(buf, inprefix, sizeof(buf));
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "#", sizeof(buf));
|
||||||
mqttClient.subscribe(buf);
|
mqttClient.subscribe(buf,MQTTQOS1);
|
||||||
|
|
||||||
//restoreState();
|
//restoreState();
|
||||||
|
onMQTTConnect();
|
||||||
// if (_once) {DMXput(); _once=0;}
|
// if (_once) {DMXput(); _once=0;}
|
||||||
lanStatus = RETAINING_COLLECTING;//4;
|
lanStatus = RETAINING_COLLECTING;//4;
|
||||||
nextLanCheckTime = millis() + 5000;
|
nextLanCheckTime = millis() + 5000;
|
||||||
@@ -616,7 +709,7 @@ void cmdFunctionHelp(int arg_cnt, char **args)
|
|||||||
// udpSyslog.logf(LOG_INFO, "free RAM: %d",freeRam());
|
// udpSyslog.logf(LOG_INFO, "free RAM: %d",freeRam());
|
||||||
#endif
|
#endif
|
||||||
printCurentLanConfig();
|
printCurentLanConfig();
|
||||||
printFreeRam();
|
// printFreeRam();
|
||||||
debugSerial<<F("\nUse these commands: 'help' - this text\n"
|
debugSerial<<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"
|
||||||
@@ -1215,8 +1308,27 @@ debugSerial<<endl;
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void printFreeRam(){
|
void publishStat(){
|
||||||
debugSerial<<F("\nfree RAM: ")<<freeRam();
|
long fr = freeRam();
|
||||||
|
char topic[64];
|
||||||
|
char intbuf[16];
|
||||||
|
long ut = millis()/1000;
|
||||||
|
|
||||||
|
// debugSerial<<F("\nfree RAM: ")<<fr;
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, stats_P, sizeof(topic));
|
||||||
|
strncat(topic, "/", sizeof(topic));
|
||||||
|
strncat_P(topic, freeheap_P, sizeof(topic));
|
||||||
|
|
||||||
|
mqttClient.publish(topic,itoa(fr,intbuf,10),true);
|
||||||
|
|
||||||
|
strncpy_P(topic, outprefix, sizeof(topic));
|
||||||
|
strncat_P(topic, stats_P, sizeof(topic));
|
||||||
|
strncat(topic, "/", sizeof(topic));
|
||||||
|
strncat_P(topic, uptime_P, sizeof(topic));
|
||||||
|
|
||||||
|
mqttClient.publish(topic,itoa(ut,intbuf,10),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupMacAddress() {
|
void setupMacAddress() {
|
||||||
@@ -1438,10 +1550,12 @@ void thermoLoop(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nextThermostatCheck = millis() + THERMOSTAT_CHECK_PERIOD;
|
nextThermostatCheck = millis() + THERMOSTAT_CHECK_PERIOD;
|
||||||
|
publishStat();
|
||||||
#ifndef DISABLE_FREERAM_PRINT
|
#ifndef DISABLE_FREERAM_PRINT
|
||||||
(thermostatCheckPrinted) ? debugSerial<<F("\nfree:")<<freeRam()<<" " : debugSerial<<F(" ")<<freeRam()<<F(" ");
|
(thermostatCheckPrinted) ? debugSerial<<F("\nfree:")<<freeRam()<<" " : debugSerial<<F(" ")<<freeRam()<<F(" ");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
short thermoSetCurTemp(char *name, float t) {
|
short thermoSetCurTemp(char *name, float t) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
#include "HTTPClient.h"
|
#include "HTTPClientAVR.h"
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
@@ -241,4 +241,4 @@ void ip_ready_config_loaded_connecting_to_broker();
|
|||||||
|
|
||||||
void printCurentLanConfig();
|
void printCurentLanConfig();
|
||||||
|
|
||||||
void printFreeRam();
|
//void printFreeRam();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef OUTTOPIC
|
#ifndef OUTTOPIC
|
||||||
#define OUTTOPIC "/myhome/s_out/"
|
#define OUTTOPIC "homie/s_out/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CMDTOPIC
|
#ifndef CMDTOPIC
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ e-mail anklimov@gmail.com
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "stdarg.h"
|
||||||
|
|
||||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32F1)
|
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32F1)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|||||||
@@ -9,24 +9,29 @@
|
|||||||
; http://docs.platformio.org/page/projectconf.html
|
; http://docs.platformio.org/page/projectconf.html
|
||||||
[platformio]
|
[platformio]
|
||||||
src_dir = lighthub
|
src_dir = lighthub
|
||||||
env_default =
|
env_default = due-5500
|
||||||
|
;monitor_speed = 115200
|
||||||
; megaatmega2560
|
; megaatmega2560
|
||||||
; megaatmega2560-net
|
; megaatmega2560-net
|
||||||
; due
|
; due
|
||||||
; esp8266
|
; esp8266
|
||||||
; esp32
|
; esp32
|
||||||
; megaatmega2560-5500
|
; megaatmega2560-5500
|
||||||
due-5500
|
; due-5500
|
||||||
; controllino
|
; controllino
|
||||||
; stm32
|
; stm32
|
||||||
|
; esp32-evb
|
||||||
|
|
||||||
;build_dir = /tmp/pioenvs
|
;build_dir = /tmp/pioenvs
|
||||||
;libdeps_dir = /tmp/piolibdeps
|
;libdeps_dir = /tmp/piolibdeps
|
||||||
|
|
||||||
[env:esp32]
|
|
||||||
|
[env:esp32-evb]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = pico32
|
board = esp32-evb
|
||||||
|
upload_protocol = esptool
|
||||||
|
upload_speed = 115200
|
||||||
build_flags = !bash check_custom_build_flags_esp32.sh
|
build_flags = !bash check_custom_build_flags_esp32.sh
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DmxSimple
|
DmxSimple
|
||||||
@@ -35,13 +40,51 @@ lib_ignore =
|
|||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
httpClient
|
|
||||||
WifiManager
|
WifiManager
|
||||||
Ethernet
|
Ethernet
|
||||||
|
Ethernet2
|
||||||
|
httpClient
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
Ethernet3
|
Ethernet3
|
||||||
|
ESP8266HTTPClient
|
||||||
|
https://github.com/anklimov/aJson
|
||||||
|
https://github.com/anklimov/CmdArduino
|
||||||
|
https://github.com/anklimov/ModbusMaster
|
||||||
|
https://github.com/knolleary/pubsubclient.git
|
||||||
|
https://github.com/anklimov/Artnet.git
|
||||||
|
FastLED
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library for ESPx
|
||||||
|
DHT sensor library
|
||||||
|
Streaming
|
||||||
|
https://github.com/livello/PrintEx#is-select-redecl
|
||||||
|
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
platform = espressif32
|
||||||
|
framework = arduino
|
||||||
|
board = pico32
|
||||||
|
upload_speed = 115200
|
||||||
|
build_flags = !bash check_custom_build_flags_esp32.sh
|
||||||
|
lib_ignore =
|
||||||
|
DmxSimple
|
||||||
|
DMXSerial
|
||||||
|
DmxDue
|
||||||
|
DueFlashStorage
|
||||||
|
SD
|
||||||
|
SdFat
|
||||||
|
WifiManager
|
||||||
|
Ethernet
|
||||||
|
Ethernet2
|
||||||
|
HTTPClient
|
||||||
|
httpClient
|
||||||
|
lib_deps =
|
||||||
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
|
Ethernet3
|
||||||
|
ESP8266HTTPClient
|
||||||
https://github.com/anklimov/aJson
|
https://github.com/anklimov/aJson
|
||||||
https://github.com/anklimov/CmdArduino
|
https://github.com/anklimov/CmdArduino
|
||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
@@ -66,6 +109,7 @@ lib_ignore =
|
|||||||
httpClient
|
httpClient
|
||||||
ESPDMX
|
ESPDMX
|
||||||
WifiManager
|
WifiManager
|
||||||
|
Ethernet3
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/sebnil/DueFlashStorage
|
https://github.com/sebnil/DueFlashStorage
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
@@ -98,6 +142,8 @@ lib_ignore =
|
|||||||
DmxDue
|
DmxDue
|
||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
WifiManager
|
WifiManager
|
||||||
|
Ethernet3
|
||||||
|
HTTPClient
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
@@ -130,6 +176,7 @@ lib_ignore =
|
|||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
httpClient
|
httpClient
|
||||||
|
Ethernet3
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
@@ -160,6 +207,8 @@ lib_ignore =
|
|||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
ESP-Dmx
|
ESP-Dmx
|
||||||
WifiManager
|
WifiManager
|
||||||
|
Ethernet3
|
||||||
|
Ethernet2
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
@@ -194,6 +243,7 @@ lib_ignore =
|
|||||||
DmxSimple
|
DmxSimple
|
||||||
httpClient
|
httpClient
|
||||||
Ethernet
|
Ethernet
|
||||||
|
Ethernet3
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/sebnil/DueFlashStorage
|
https://github.com/sebnil/DueFlashStorage
|
||||||
@@ -227,6 +277,8 @@ lib_ignore =
|
|||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
ESP-Dmx
|
ESP-Dmx
|
||||||
WifiManager
|
WifiManager
|
||||||
|
Ethernet3
|
||||||
|
Ethernet2
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
@@ -269,6 +321,7 @@ lib_ignore =
|
|||||||
PrintEx
|
PrintEx
|
||||||
Ethernet2
|
Ethernet2
|
||||||
Artnet
|
Artnet
|
||||||
|
Ethernet3
|
||||||
|
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
sed -i -- 's/void USART0_Handler(void)/void USART0_Handler(void ) __attribute__((weak));\nvoid USART0_Handler(void )/g' ~/.platformio/packages/framework-arduinosam/variants/arduino_due_x/variant.cpp
|
sed -i -- 's/void USART0_Handler(void)/void USART0_Handler(void ) __attribute__((weak)); void USART0_Handler(void )/g' ~/.platformio/packages/framework-arduinosam/variants/arduino_due_x/variant.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user