mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +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;
|
||||
}
|
||||
|
||||
void Item::Stop()
|
||||
{
|
||||
if (driver)
|
||||
{
|
||||
driver->Stop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Item::~Item()
|
||||
{
|
||||
if (driver)
|
||||
@@ -459,7 +468,6 @@ return suffixCode;
|
||||
int Item::Ctrl(char * payload, char * subItem){
|
||||
if (!payload) return 0;
|
||||
|
||||
bool send = isNotRetainingStatus() ;
|
||||
|
||||
int suffixCode = 0;
|
||||
//int setCommand = CMD_SET; //default SET behavior now - not turn on channels
|
||||
@@ -715,12 +723,13 @@ bool send = isNotRetainingStatus() ;
|
||||
}
|
||||
break;
|
||||
case CMD_NUM:
|
||||
if (itemType == CH_GROUP || n!=1) break;
|
||||
|
||||
//if (itemType == CH_GROUP || n!=1) break;
|
||||
if (n!=1) break;
|
||||
int cType=getChanType();
|
||||
if ( cType == CH_RGB || cType == CH_RGBW)
|
||||
if ( cType == CH_RGB || cType == CH_RGBW || cType == CH_GROUP )
|
||||
{
|
||||
st.aslong = getVal();
|
||||
st.hsv_flag=1;
|
||||
switch (suffixCode)
|
||||
{
|
||||
case S_SAT:
|
||||
@@ -742,6 +751,7 @@ bool send = isNotRetainingStatus() ;
|
||||
n=3;
|
||||
setVal(st.aslong);
|
||||
}
|
||||
//if (itemType == CH_GROUP) break;
|
||||
}
|
||||
else // Non-color channel
|
||||
if (suffixCode == S_SAT || suffixCode == S_HUE) return -3;
|
||||
|
||||
@@ -178,6 +178,7 @@ class Item
|
||||
|
||||
boolean isValid ();
|
||||
boolean Setup();
|
||||
void Stop();
|
||||
int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL);
|
||||
int Ctrl(char * payload, char * subItem=NULL);
|
||||
|
||||
|
||||
@@ -194,7 +194,20 @@ while (configLocked)
|
||||
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();
|
||||
aJson.deleteItem(root);
|
||||
@@ -393,10 +406,27 @@ if (WiFi.status() != WL_CONNECTED)
|
||||
}
|
||||
#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)
|
||||
wdt_dis();
|
||||
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:
|
||||
debugSerial<<F("No link")<<endl;
|
||||
if (mqttClient.connected()) mqttClient.disconnect();
|
||||
@@ -431,7 +461,7 @@ if (WiFi.status() != WL_CONNECTED)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
wdt_en();
|
||||
#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() {
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(WIFI_MANAGER_DISABLE)
|
||||
@@ -736,10 +775,8 @@ wifiManager.setTimeout(30);
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||
#ifdef OTA
|
||||
// start the OTEthernet library with internal (flash) based storage
|
||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||
#endif
|
||||
setupOTA();
|
||||
|
||||
} else
|
||||
{
|
||||
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)
|
||||
#ifdef W5500_CS_PIN
|
||||
#ifndef Wiz5500
|
||||
Ethernet.init(W5500_CS_PIN);
|
||||
#else
|
||||
Ethernet.w5500_cspin = W5500_CS_PIN;
|
||||
#endif
|
||||
debugSerial<<F("Use W5500 pin: ");
|
||||
debugSerial<<(Ethernet.w5500_cspin)<<endl;
|
||||
debugSerial<<QUOTE(W5500_CS_PIN)<<endl;
|
||||
#endif
|
||||
IPAddress ip, dns, gw, mask;
|
||||
int res = 1;
|
||||
@@ -774,10 +815,7 @@ wifiManager.setTimeout(30);
|
||||
} else Ethernet.begin(mac, ip);
|
||||
debugSerial<<endl;
|
||||
lanStatus = HAVE_IP_ADDRESS;
|
||||
#ifdef OTA
|
||||
// start the OTEthernet library with internal (flash) based storage
|
||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||
#endif
|
||||
setupOTA();
|
||||
#ifdef _artnet
|
||||
if (artnet) artnet->begin();
|
||||
#endif
|
||||
@@ -806,10 +844,9 @@ wifiManager.setTimeout(30);
|
||||
debugSerial<<F("Got IP address:");
|
||||
printIPAddress(Ethernet.localIP());
|
||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||
#ifdef OTA
|
||||
// start the OTEthernet library with internal (flash) based storage
|
||||
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||
#endif
|
||||
|
||||
setupOTA();
|
||||
|
||||
#ifdef _artnet
|
||||
if (artnet) artnet->begin();
|
||||
#endif
|
||||
@@ -1524,10 +1561,10 @@ void printFirmwareVersionAndBuildOptions() {
|
||||
#ifdef CONTROLLINO
|
||||
debugSerial<<F("\n(+)CONTROLLINO");
|
||||
#endif
|
||||
#ifdef WATCH_DOG_TICKER_DISABLE
|
||||
debugSerial<<F("\n(-)WATCHDOG");
|
||||
#else
|
||||
#ifndef WATCH_DOG_TICKER_DISABLE
|
||||
debugSerial<<F("\n(+)WATCHDOG");
|
||||
#else
|
||||
debugSerial<<F("\n(-)WATCHDOG");
|
||||
#endif
|
||||
debugSerial<<F("\nConfig server:")<<F(CONFIG_SERVER)<<F("\nFirmware MAC Address ")<<F(QUOTE(CUSTOM_FIRMWARE_MAC));
|
||||
#ifdef DISABLE_FREERAM_PRINT
|
||||
@@ -1546,22 +1583,22 @@ void printFirmwareVersionAndBuildOptions() {
|
||||
debugSerial<<F("\n(+)WizNet5500");
|
||||
#endif
|
||||
|
||||
#ifdef DMX_DISABLE
|
||||
debugSerial<<F("\n(-)DMX");
|
||||
#else
|
||||
#ifndef DMX_DISABLE
|
||||
debugSerial<<F("\n(+)DMX");
|
||||
#else
|
||||
debugSerial<<F("\n(-)DMX");
|
||||
#endif
|
||||
|
||||
#ifdef MODBUS_DISABLE
|
||||
debugSerial<<F("\n(-)MODBUS");
|
||||
#else
|
||||
#ifndef MODBUS_DISABLE
|
||||
debugSerial<<F("\n(+)MODBUS");
|
||||
#else
|
||||
debugSerial<<F("\n(-)MODBUS");
|
||||
#endif
|
||||
|
||||
#ifdef OWIRE_DISABLE
|
||||
debugSerial<<F("\n(-)OWIRE");
|
||||
#else
|
||||
#ifndef OWIRE_DISABLE
|
||||
debugSerial<<F("\n(+)OWIRE");
|
||||
#else
|
||||
debugSerial<<F("\n(-)OWIRE");
|
||||
#endif
|
||||
#ifndef DHT_DISABLE
|
||||
debugSerial<<F("\n(+)DHT");
|
||||
@@ -1592,10 +1629,10 @@ void printFirmwareVersionAndBuildOptions() {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CSSHDC_DISABLE
|
||||
debugSerial<<F("\n(-)CCS811 & HDC1080");
|
||||
#else
|
||||
#ifndef CSSHDC_DISABLE
|
||||
debugSerial<<F("\n(+)CCS811 & HDC1080");
|
||||
#else
|
||||
debugSerial<<F("\n(-)CCS811 & HDC1080");
|
||||
#endif
|
||||
#ifndef AC_DISABLE
|
||||
debugSerial<<F("\n(+)AC HAIER");
|
||||
@@ -1612,14 +1649,20 @@ void printFirmwareVersionAndBuildOptions() {
|
||||
#else
|
||||
debugSerial<<F("\n(-)SPI LED");
|
||||
#endif
|
||||
#ifndef FASTLED
|
||||
#ifdef FASTLED
|
||||
debugSerial<<F("\n(+)FASTLED");
|
||||
#else
|
||||
debugSerial<<F("\n(+)ADAFRUIT LED");
|
||||
#endif
|
||||
debugSerial<<endl;
|
||||
|
||||
#ifdef OTA
|
||||
debugSerial<<F("\n(+)OTA");
|
||||
#else
|
||||
debugSerial<<F("\n(-)OTA");
|
||||
#endif
|
||||
|
||||
debugSerial<<endl;
|
||||
// WDT_Disable( WDT ) ;
|
||||
#if defined(__SAM3X8E__)
|
||||
|
||||
@@ -1718,9 +1761,7 @@ void setupCmdArduino() {
|
||||
}
|
||||
|
||||
void loop_main() {
|
||||
#if defined(OTA)
|
||||
ArduinoOTA.poll();
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(M5STACK)
|
||||
// Initialize the M5Stack object
|
||||
@@ -1731,6 +1772,11 @@ void loop_main() {
|
||||
cmdPoll();
|
||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
||||
mqttClient.loop();
|
||||
|
||||
#if defined(OTA)
|
||||
ArduinoOTA.poll();
|
||||
#endif
|
||||
|
||||
#ifdef _artnet
|
||||
if (artnet) artnet->read(); ///hung
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,7 @@ int in_ccs811::Setup()
|
||||
Serial.println("CCS811 Init");
|
||||
|
||||
Wire.begin(); //Inialize I2C Harware
|
||||
Wire.setClock(4000);
|
||||
|
||||
//It is recommended to check return status on .begin(), but it is not
|
||||
//required.
|
||||
|
||||
@@ -28,6 +28,8 @@ default_envs =
|
||||
; Arduino DUE + Ethernet shield Wiznet 5100
|
||||
; due-5100
|
||||
|
||||
; Generic DUE
|
||||
due
|
||||
; Arduino DUE + Ethernet shield Wiznet 5500
|
||||
; due-5500
|
||||
|
||||
@@ -209,12 +211,13 @@ lib_deps =
|
||||
Adafruit NeoPixel
|
||||
https://github.com/anklimov/ArduinoOTA
|
||||
|
||||
[env:due-5100]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
build_flags = !python get_build_flags.py due-5100
|
||||
lib_ignore =
|
||||
|
||||
[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
|
||||
@@ -231,7 +234,7 @@ lib_ignore =
|
||||
EEPROM
|
||||
M5Stack
|
||||
;ArduinoOTA
|
||||
lib_deps =
|
||||
lib_deps =
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
@@ -255,6 +258,55 @@ lib_deps =
|
||||
Adafruit NeoPixel
|
||||
https://github.com/anklimov/ArduinoOTA
|
||||
|
||||
|
||||
[env:due]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
build_flags = !python get_build_flags.py due
|
||||
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
|
||||
Ethernet2
|
||||
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/arduino-libraries/Ethernet.git
|
||||
;https://github.com/anklimov/Ethernet2.git
|
||||
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:mega2560slim-5100]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
|
||||
Reference in New Issue
Block a user