mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
stop channels when get
This commit is contained in:
7
build-flags/build_flags_due
Normal file
7
build-flags/build_flags_due
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
-DW5500_CS_PIN=53
|
||||||
|
-DDMX_SMOOTH
|
||||||
|
#-DSYSLOG_ENABLE
|
||||||
|
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
|
#-DARTNET_ENABLE
|
||||||
|
-DOTA
|
||||||
|
#-DWiz5500
|
||||||
@@ -200,6 +200,15 @@ if (driver)
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Item::Stop()
|
||||||
|
{
|
||||||
|
if (driver)
|
||||||
|
{
|
||||||
|
driver->Stop();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Item::~Item()
|
Item::~Item()
|
||||||
{
|
{
|
||||||
if (driver)
|
if (driver)
|
||||||
@@ -459,7 +468,6 @@ return suffixCode;
|
|||||||
int Item::Ctrl(char * payload, char * subItem){
|
int Item::Ctrl(char * payload, char * subItem){
|
||||||
if (!payload) return 0;
|
if (!payload) return 0;
|
||||||
|
|
||||||
bool send = isNotRetainingStatus() ;
|
|
||||||
|
|
||||||
int suffixCode = 0;
|
int suffixCode = 0;
|
||||||
//int setCommand = CMD_SET; //default SET behavior now - not turn on channels
|
//int setCommand = CMD_SET; //default SET behavior now - not turn on channels
|
||||||
@@ -715,12 +723,13 @@ bool send = isNotRetainingStatus() ;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CMD_NUM:
|
case CMD_NUM:
|
||||||
if (itemType == CH_GROUP || n!=1) break;
|
//if (itemType == CH_GROUP || n!=1) break;
|
||||||
|
if (n!=1) break;
|
||||||
int cType=getChanType();
|
int cType=getChanType();
|
||||||
if ( cType == CH_RGB || cType == CH_RGBW)
|
if ( cType == CH_RGB || cType == CH_RGBW || cType == CH_GROUP )
|
||||||
{
|
{
|
||||||
st.aslong = getVal();
|
st.aslong = getVal();
|
||||||
|
st.hsv_flag=1;
|
||||||
switch (suffixCode)
|
switch (suffixCode)
|
||||||
{
|
{
|
||||||
case S_SAT:
|
case S_SAT:
|
||||||
@@ -742,6 +751,7 @@ bool send = isNotRetainingStatus() ;
|
|||||||
n=3;
|
n=3;
|
||||||
setVal(st.aslong);
|
setVal(st.aslong);
|
||||||
}
|
}
|
||||||
|
//if (itemType == CH_GROUP) break;
|
||||||
}
|
}
|
||||||
else // Non-color channel
|
else // Non-color channel
|
||||||
if (suffixCode == S_SAT || suffixCode == S_HUE) return -3;
|
if (suffixCode == S_SAT || suffixCode == S_HUE) return -3;
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ class Item
|
|||||||
|
|
||||||
boolean isValid ();
|
boolean isValid ();
|
||||||
boolean Setup();
|
boolean Setup();
|
||||||
|
void Stop();
|
||||||
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL);
|
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL);
|
||||||
int Ctrl(char * payload, char * subItem=NULL);
|
int Ctrl(char * payload, char * subItem=NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,20 @@ while (configLocked)
|
|||||||
inputLoop();
|
inputLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
pollingItem = NULL;;
|
//Stoping the channels
|
||||||
|
aJsonObject * item = items->child;
|
||||||
|
while (items && item)
|
||||||
|
{
|
||||||
|
if (item->type == aJson_Array && aJson.getArraySize(item)>0)
|
||||||
|
{
|
||||||
|
Item it(item->name);
|
||||||
|
if (it.isValid()) it.Stop();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
item = item->next;
|
||||||
|
}
|
||||||
|
pollingItem = NULL;
|
||||||
|
|
||||||
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
@@ -393,10 +406,27 @@ if (WiFi.status() != WL_CONNECTED)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef wiz5500
|
||||||
|
|
||||||
|
#define DHCP_CHECK_RENEW_FAIL 1
|
||||||
|
#define DHCP_CHECK_RENEW_OK 2
|
||||||
|
#define DHCP_CHECK_REBIND_FAIL 3
|
||||||
|
#define DHCP_CHECK_REBIND_OK 4
|
||||||
|
#define NO_LINK 5
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined (NRF5)
|
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined (NRF5)
|
||||||
wdt_dis();
|
wdt_dis();
|
||||||
if (lanStatus > 0)
|
if (lanStatus > 0)
|
||||||
switch (Ethernet.maintain()) {
|
{
|
||||||
|
int etherStatus = Ethernet.maintain();
|
||||||
|
|
||||||
|
#ifdef ETHENET_GENERIC
|
||||||
|
if (Ethernet.linkStatus() == LinkOFF) etherStatus = NO_LINK;
|
||||||
|
#endif
|
||||||
|
switch (etherStatus) {
|
||||||
case NO_LINK:
|
case NO_LINK:
|
||||||
debugSerial<<F("No link")<<endl;
|
debugSerial<<F("No link")<<endl;
|
||||||
if (mqttClient.connected()) mqttClient.disconnect();
|
if (mqttClient.connected()) mqttClient.disconnect();
|
||||||
@@ -431,7 +461,7 @@ if (WiFi.status() != WL_CONNECTED)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
wdt_en();
|
wdt_en();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -680,6 +710,15 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupOTA(void)
|
||||||
|
{
|
||||||
|
#ifdef OTA
|
||||||
|
// start the OTEthernet library with internal (flash) based storage
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void onInitialStateInitLAN() {
|
void onInitialStateInitLAN() {
|
||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
#if defined(WIFI_MANAGER_DISABLE)
|
#if defined(WIFI_MANAGER_DISABLE)
|
||||||
@@ -736,10 +775,8 @@ wifiManager.setTimeout(30);
|
|||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
||||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
#ifdef OTA
|
setupOTA();
|
||||||
// start the OTEthernet library with internal (flash) based storage
|
|
||||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
|
||||||
#endif
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
debugSerial<<F("Problem with WiFi!");
|
debugSerial<<F("Problem with WiFi!");
|
||||||
@@ -749,9 +786,13 @@ wifiManager.setTimeout(30);
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__)||defined(ARDUINO_ARCH_STM32) || defined (NRF5)
|
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__)||defined(ARDUINO_ARCH_STM32) || defined (NRF5)
|
||||||
#ifdef W5500_CS_PIN
|
#ifdef W5500_CS_PIN
|
||||||
|
#ifndef Wiz5500
|
||||||
|
Ethernet.init(W5500_CS_PIN);
|
||||||
|
#else
|
||||||
Ethernet.w5500_cspin = W5500_CS_PIN;
|
Ethernet.w5500_cspin = W5500_CS_PIN;
|
||||||
|
#endif
|
||||||
debugSerial<<F("Use W5500 pin: ");
|
debugSerial<<F("Use W5500 pin: ");
|
||||||
debugSerial<<(Ethernet.w5500_cspin)<<endl;
|
debugSerial<<QUOTE(W5500_CS_PIN)<<endl;
|
||||||
#endif
|
#endif
|
||||||
IPAddress ip, dns, gw, mask;
|
IPAddress ip, dns, gw, mask;
|
||||||
int res = 1;
|
int res = 1;
|
||||||
@@ -774,10 +815,7 @@ wifiManager.setTimeout(30);
|
|||||||
} else Ethernet.begin(mac, ip);
|
} else Ethernet.begin(mac, ip);
|
||||||
debugSerial<<endl;
|
debugSerial<<endl;
|
||||||
lanStatus = HAVE_IP_ADDRESS;
|
lanStatus = HAVE_IP_ADDRESS;
|
||||||
#ifdef OTA
|
setupOTA();
|
||||||
// start the OTEthernet library with internal (flash) based storage
|
|
||||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
|
||||||
#endif
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->begin();
|
if (artnet) artnet->begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -806,10 +844,9 @@ wifiManager.setTimeout(30);
|
|||||||
debugSerial<<F("Got IP address:");
|
debugSerial<<F("Got IP address:");
|
||||||
printIPAddress(Ethernet.localIP());
|
printIPAddress(Ethernet.localIP());
|
||||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
#ifdef OTA
|
|
||||||
// start the OTEthernet library with internal (flash) based storage
|
setupOTA();
|
||||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
|
||||||
#endif
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->begin();
|
if (artnet) artnet->begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -1524,10 +1561,10 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#ifdef CONTROLLINO
|
#ifdef CONTROLLINO
|
||||||
debugSerial<<F("\n(+)CONTROLLINO");
|
debugSerial<<F("\n(+)CONTROLLINO");
|
||||||
#endif
|
#endif
|
||||||
#ifdef WATCH_DOG_TICKER_DISABLE
|
#ifndef WATCH_DOG_TICKER_DISABLE
|
||||||
debugSerial<<F("\n(-)WATCHDOG");
|
|
||||||
#else
|
|
||||||
debugSerial<<F("\n(+)WATCHDOG");
|
debugSerial<<F("\n(+)WATCHDOG");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)WATCHDOG");
|
||||||
#endif
|
#endif
|
||||||
debugSerial<<F("\nConfig server:")<<F(CONFIG_SERVER)<<F("\nFirmware MAC Address ")<<F(QUOTE(CUSTOM_FIRMWARE_MAC));
|
debugSerial<<F("\nConfig server:")<<F(CONFIG_SERVER)<<F("\nFirmware MAC Address ")<<F(QUOTE(CUSTOM_FIRMWARE_MAC));
|
||||||
#ifdef DISABLE_FREERAM_PRINT
|
#ifdef DISABLE_FREERAM_PRINT
|
||||||
@@ -1546,22 +1583,22 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
debugSerial<<F("\n(+)WizNet5500");
|
debugSerial<<F("\n(+)WizNet5500");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DMX_DISABLE
|
#ifndef DMX_DISABLE
|
||||||
debugSerial<<F("\n(-)DMX");
|
|
||||||
#else
|
|
||||||
debugSerial<<F("\n(+)DMX");
|
debugSerial<<F("\n(+)DMX");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)DMX");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODBUS_DISABLE
|
#ifndef MODBUS_DISABLE
|
||||||
debugSerial<<F("\n(-)MODBUS");
|
|
||||||
#else
|
|
||||||
debugSerial<<F("\n(+)MODBUS");
|
debugSerial<<F("\n(+)MODBUS");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)MODBUS");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OWIRE_DISABLE
|
#ifndef OWIRE_DISABLE
|
||||||
debugSerial<<F("\n(-)OWIRE");
|
|
||||||
#else
|
|
||||||
debugSerial<<F("\n(+)OWIRE");
|
debugSerial<<F("\n(+)OWIRE");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)OWIRE");
|
||||||
#endif
|
#endif
|
||||||
#ifndef DHT_DISABLE
|
#ifndef DHT_DISABLE
|
||||||
debugSerial<<F("\n(+)DHT");
|
debugSerial<<F("\n(+)DHT");
|
||||||
@@ -1592,10 +1629,10 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef CSSHDC_DISABLE
|
#ifndef CSSHDC_DISABLE
|
||||||
debugSerial<<F("\n(-)CCS811 & HDC1080");
|
|
||||||
#else
|
|
||||||
debugSerial<<F("\n(+)CCS811 & HDC1080");
|
debugSerial<<F("\n(+)CCS811 & HDC1080");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)CCS811 & HDC1080");
|
||||||
#endif
|
#endif
|
||||||
#ifndef AC_DISABLE
|
#ifndef AC_DISABLE
|
||||||
debugSerial<<F("\n(+)AC HAIER");
|
debugSerial<<F("\n(+)AC HAIER");
|
||||||
@@ -1612,14 +1649,20 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#else
|
#else
|
||||||
debugSerial<<F("\n(-)SPI LED");
|
debugSerial<<F("\n(-)SPI LED");
|
||||||
#endif
|
#endif
|
||||||
#ifndef FASTLED
|
#ifdef FASTLED
|
||||||
debugSerial<<F("\n(+)FASTLED");
|
debugSerial<<F("\n(+)FASTLED");
|
||||||
#else
|
#else
|
||||||
debugSerial<<F("\n(+)ADAFRUIT LED");
|
debugSerial<<F("\n(+)ADAFRUIT LED");
|
||||||
#endif
|
#endif
|
||||||
debugSerial<<endl;
|
debugSerial<<endl;
|
||||||
|
|
||||||
|
#ifdef OTA
|
||||||
|
debugSerial<<F("\n(+)OTA");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)OTA");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
debugSerial<<endl;
|
||||||
// WDT_Disable( WDT ) ;
|
// WDT_Disable( WDT ) ;
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
|
|
||||||
@@ -1718,9 +1761,7 @@ void setupCmdArduino() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop_main() {
|
void loop_main() {
|
||||||
#if defined(OTA)
|
|
||||||
ArduinoOTA.poll();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(M5STACK)
|
#if defined(M5STACK)
|
||||||
// Initialize the M5Stack object
|
// Initialize the M5Stack object
|
||||||
@@ -1731,6 +1772,11 @@ void loop_main() {
|
|||||||
cmdPoll();
|
cmdPoll();
|
||||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
if (lanLoop() > HAVE_IP_ADDRESS) {
|
||||||
mqttClient.loop();
|
mqttClient.loop();
|
||||||
|
|
||||||
|
#if defined(OTA)
|
||||||
|
ArduinoOTA.poll();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->read(); ///hung
|
if (artnet) artnet->read(); ///hung
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ int in_ccs811::Setup()
|
|||||||
Serial.println("CCS811 Init");
|
Serial.println("CCS811 Init");
|
||||||
|
|
||||||
Wire.begin(); //Inialize I2C Harware
|
Wire.begin(); //Inialize I2C Harware
|
||||||
|
Wire.setClock(4000);
|
||||||
|
|
||||||
//It is recommended to check return status on .begin(), but it is not
|
//It is recommended to check return status on .begin(), but it is not
|
||||||
//required.
|
//required.
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ default_envs =
|
|||||||
; Arduino DUE + Ethernet shield Wiznet 5100
|
; Arduino DUE + Ethernet shield Wiznet 5100
|
||||||
; due-5100
|
; due-5100
|
||||||
|
|
||||||
|
; Generic DUE
|
||||||
|
due
|
||||||
; Arduino DUE + Ethernet shield Wiznet 5500
|
; Arduino DUE + Ethernet shield Wiznet 5500
|
||||||
; due-5500
|
; due-5500
|
||||||
|
|
||||||
@@ -209,11 +211,59 @@ lib_deps =
|
|||||||
Adafruit NeoPixel
|
Adafruit NeoPixel
|
||||||
https://github.com/anklimov/ArduinoOTA
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:due-5100]
|
|
||||||
|
[env:due-5100]
|
||||||
|
platform = atmelsam
|
||||||
|
framework = arduino
|
||||||
|
board = due
|
||||||
|
build_flags = !python get_build_flags.py due-5100
|
||||||
|
lib_ignore =
|
||||||
|
;DS2482_OneWire //UNCOMMENT for software 1-wire driver
|
||||||
|
DHT sensor library for ESPx
|
||||||
|
ESP_EEPROM
|
||||||
|
DMXSerial
|
||||||
|
DmxSimple
|
||||||
|
httpClient
|
||||||
|
ESPDMX
|
||||||
|
ESP-Dmx
|
||||||
|
WifiManager
|
||||||
|
Ethernet3
|
||||||
|
NRFFlashStorage
|
||||||
|
WebServer
|
||||||
|
UIPEthernet
|
||||||
|
EEPROM
|
||||||
|
M5Stack
|
||||||
|
;ArduinoOTA
|
||||||
|
lib_deps =
|
||||||
|
https://github.com/sebnil/DueFlashStorage
|
||||||
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
|
https://github.com/anklimov/DmxDue
|
||||||
|
ArduinoHttpClient
|
||||||
|
https://github.com/anklimov/aJson
|
||||||
|
https://github.com/anklimov/CmdArduino
|
||||||
|
https://github.com/anklimov/ModbusMaster
|
||||||
|
https://github.com/anklimov/Ethernet
|
||||||
|
https://github.com/knolleary/pubsubclient.git
|
||||||
|
https://github.com/anklimov/Artnet.git
|
||||||
|
FastLED@3.3.2
|
||||||
|
SD
|
||||||
|
SdFat
|
||||||
|
Adafruit Unified Sensor
|
||||||
|
DHT sensor library
|
||||||
|
https://github.com/arcao/Syslog.git
|
||||||
|
Streaming
|
||||||
|
ClosedCube HDC1080
|
||||||
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
|
|
||||||
|
[env:due]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
build_flags = !python get_build_flags.py due-5100
|
build_flags = !python get_build_flags.py due
|
||||||
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
|
||||||
@@ -225,6 +275,7 @@ lib_ignore =
|
|||||||
ESP-Dmx
|
ESP-Dmx
|
||||||
WifiManager
|
WifiManager
|
||||||
Ethernet3
|
Ethernet3
|
||||||
|
Ethernet2
|
||||||
NRFFlashStorage
|
NRFFlashStorage
|
||||||
WebServer
|
WebServer
|
||||||
UIPEthernet
|
UIPEthernet
|
||||||
@@ -240,7 +291,8 @@ lib_deps =
|
|||||||
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
|
||||||
https://github.com/anklimov/Ethernet
|
https://github.com/arduino-libraries/Ethernet.git
|
||||||
|
;https://github.com/anklimov/Ethernet2.git
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED@3.3.2
|
FastLED@3.3.2
|
||||||
|
|||||||
Reference in New Issue
Block a user