From f21de6b6070bf13158911cc2aeeeb6b0f6dc5717 Mon Sep 17 00:00:00 2001 From: Debashish Sahu <debashish.sahu@gmail.com> Date: Mon, 3 Dec 2018 16:35:26 -0500 Subject: [PATCH 1/3] Incremental Update * Contributions by @ MrTheBarbarian from https://github.com/toblum/McLighting/pull/270 Putting Static IP config added in Jun 17th 2018 to definitions.h * rethink ESP.getChipId implementaion * check ArduinoJSON version * Try restting prevmode as suggested in https://github.com/toblum/McLighting/issues/276 --- Arduino/McLighting/McLighting.ino | 19 +++++++++++++++++-- Arduino/McLighting/definitions.h | 15 ++++++++++++--- Arduino/McLighting/version.h | 2 +- Arduino/McLighting/version_info.ino | 6 ++++++ platformio.ini | 2 +- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index 8cc26b4..858022f 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -52,6 +52,12 @@ WiFiEventHandler wifiDisconnectHandler; #endif +#ifdef ARDUINOJSON_VERSION + #if !(ARDUINOJSON_VERSION_MAJOR == 6 and ARDUINOJSON_VERSION_MINOR == 6) + #error "Install ArduinoJson v6.6.0-beta" + #endif +#endif + // *************************************************************************** // Instanciate HTTP(80) / WebSockets(81) Server @@ -317,11 +323,15 @@ void setup() { // Uncomment if you want to restart ESP8266 if it cannot connect to WiFi. // Value in brackets is in seconds that WiFiManger waits until restart - //wifiManager.setConfigPortalTimeout(180); + #ifdef WIFIMGR_PORTAL_TIMEOUT + wifiManager.setConfigPortalTimeout(WIFIMGR_PORTAL_TIMEOUT); + #endif // Uncomment if you want to set static IP // Order is: IP, Gateway and Subnet - //wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,128), IPAddress(192,168,0,1), IPAddress(255,255,255,0)); + #ifdef WIFIMGR_SET_MANUAL_IP + wifiManager.setSTAStaticIPConfig(IPAddress(_ip[0], _ip[1], _ip[2], _ip[3]), IPAddress(_gw[0], _gw[1], _gw[2], _gw[3]), IPAddress(_sn[0], _sn[1], _sn[2], _sn[3])); + #endif //fetches ssid and pass and tries to connect //if it does not connect it starts an access point with the specified name @@ -415,6 +425,10 @@ void setup() { // *************************************************************************** // Configure MQTT // *************************************************************************** + #ifdef ENABLE_MQTT_HOSTNAME_CHIPID + snprintf(mqtt_clientid, 64, "%u-%08X", HOSTNAME, ESP.getChipId()); + #endif + #ifdef ENABLE_MQTT if (mqtt_host != "" && atoi(mqtt_port) > 0) { snprintf(mqtt_intopic, sizeof mqtt_intopic, "%s/in", HOSTNAME); @@ -1007,6 +1021,7 @@ void loop() { exit_func = false; } #endif + if (prevmode == SET_MODE) prevmode = HOLD; } #ifdef ENABLE_LEGACY_ANIMATIONS if (mode == TV) { diff --git a/Arduino/McLighting/definitions.h b/Arduino/McLighting/definitions.h index 50360bf..10440e8 100644 --- a/Arduino/McLighting/definitions.h +++ b/Arduino/McLighting/definitions.h @@ -2,7 +2,7 @@ //#define USE_WS2812FX_UART // Uses PIN is ignored & set to D4/GPIO2 Uses WS2812FX, see: https://github.com/kitesurfer1404/WS2812FX // Neopixel -#define PIN D1 // PIN (14 / D5) where neopixel / WS2811 strip is attached +#define PIN 14 // PIN (14 / D5) where neopixel / WS2811 strip is attached #define NUMLEDS 24 // Number of leds in the strip #define BUILTIN_LED 2 // ESP-12F has the built in LED on GPIO2, see https://github.com/esp8266/Arduino/issues/2192 #define BUTTON 4 // Input pin (4 / D2) for switching the LED strip on / off, connect this PIN to ground to trigger button. @@ -18,6 +18,15 @@ const char HOSTNAME[] = "McLighting01"; // Friedly hostname //#define MQTT_HOME_ASSISTANT_SUPPORT // If defined, use AMQTT and select Tools -> IwIP Variant -> Higher Bandwidth #define ENABLE_LEGACY_ANIMATIONS +//#define WIFIMGR_PORTAL_TIMEOUT 180 +//#define WIFIMGR_SET_MANUAL_IP + +#ifdef WIFIMGR_SET_MANUAL_IP + uint8_t _ip[4] = {192,168,0,128}; + uint8_t _gw[4] = {192,168,0,1}; + uint8_t _sn[4] = {255,255,255,0}; +#endif + #if defined(USE_WS2812FX_DMA) and defined(USE_WS2812FX_UART) #error "Cant have both DMA and UART method." #endif @@ -72,9 +81,9 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds) //#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname #ifdef ENABLE_MQTT_HOSTNAME_CHIPID - const char* mqtt_clientid = String(String(HOSTNAME) + "-" + String(ESP.getChipId())).c_str(); // MQTT ClientID + char mqtt_clientid[64]; #else - const char* mqtt_clientid = HOSTNAME; // MQTT ClientID + const char* mqtt_clientid = HOSTNAME; #endif char mqtt_host[64] = ""; diff --git a/Arduino/McLighting/version.h b/Arduino/McLighting/version.h index b672824..3f7b186 100644 --- a/Arduino/McLighting/version.h +++ b/Arduino/McLighting/version.h @@ -1 +1 @@ -#define SKETCH_VERSION "2.1.6" +#define SKETCH_VERSION "2.1.7" diff --git a/Arduino/McLighting/version_info.ino b/Arduino/McLighting/version_info.ino index 0a72ea9..72639bc 100644 --- a/Arduino/McLighting/version_info.ino +++ b/Arduino/McLighting/version_info.ino @@ -25,4 +25,10 @@ * - Retire NeoAnimationFX * - Use DMA or UART method along with WS2812FX instead * - fix #248 + * + * 3 Dec 2018 v 2.1.7 + * - Contributions by @ MrTheBarbarian from #270 + * - rethink ESP.getChipId implementaion + * - check ArduinoJSON version + * - Try restting prevmode as suggested in #276 */ diff --git a/platformio.ini b/platformio.ini index a82deee..192f8ae 100644 --- a/platformio.ini +++ b/platformio.ini @@ -47,7 +47,7 @@ upload_resetmethod = ${common.upload_resetmethod} lib_deps = WiFiManager@0.14 AsyncMqttClient - https://github.com/bblanchon/ArduinoJson.git#v6.5.0-beta + https://github.com/bblanchon/ArduinoJson.git#v6.6.0-beta WS2812FX NeoPixelBus WebSockets From d2fd2a95433b7d6170311b8d8d5bd99420d9a8ae Mon Sep 17 00:00:00 2001 From: Debashish Sahu <debashish.sahu@gmail.com> Date: Mon, 3 Dec 2018 16:37:58 -0500 Subject: [PATCH 2/3] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 98426ce..f88ff70 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ lib/readme.txt *.h.gch .clang_complete .gcc-flags.json + +.vscode/* \ No newline at end of file From 267a8f0f2e9032853a84f1b4c0cde55470e5aeb0 Mon Sep 17 00:00:00 2001 From: Debashish Sahu <debashish.sahu@gmail.com> Date: Mon, 3 Dec 2018 16:42:06 -0500 Subject: [PATCH 3/3] HOSTNAME is %s --- Arduino/McLighting/McLighting.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index 858022f..4c78190 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -426,7 +426,7 @@ void setup() { // Configure MQTT // *************************************************************************** #ifdef ENABLE_MQTT_HOSTNAME_CHIPID - snprintf(mqtt_clientid, 64, "%u-%08X", HOSTNAME, ESP.getChipId()); + snprintf(mqtt_clientid, 64, "%s-%08X", HOSTNAME, ESP.getChipId()); #endif #ifdef ENABLE_MQTT