Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Incremental Update
Browse files Browse the repository at this point in the history
* Contributions by @	MrTheBarbarian from #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 #276
  • Loading branch information
debsahu committed Dec 3, 2018
1 parent ac5e873 commit f21de6b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
19 changes: 17 additions & 2 deletions Arduino/McLighting/McLighting.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1007,6 +1021,7 @@ void loop() {
exit_func = false;
}
#endif
if (prevmode == SET_MODE) prevmode = HOLD;
}
#ifdef ENABLE_LEGACY_ANIMATIONS
if (mode == TV) {
Expand Down
15 changes: 12 additions & 3 deletions Arduino/McLighting/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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] = "";
Expand Down
2 changes: 1 addition & 1 deletion Arduino/McLighting/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define SKETCH_VERSION "2.1.6"
#define SKETCH_VERSION "2.1.7"
6 changes: 6 additions & 0 deletions Arduino/McLighting/version_info.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ upload_resetmethod = ${common.upload_resetmethod}
lib_deps =
[email protected]
AsyncMqttClient
https://github.com/bblanchon/ArduinoJson.git#v6.5.0-beta
https://github.com/bblanchon/ArduinoJson.git#v6.6.0-beta
WS2812FX
NeoPixelBus
WebSockets

0 comments on commit f21de6b

Please sign in to comment.