|
|
|
@ -1,8 +1,13 @@ |
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
// LED
|
|
|
|
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
|
|
|
|
#include <FastLED.h>
|
|
|
|
|
|
|
|
// WIFI
|
|
|
|
#include <ESP8266WiFi.h>
|
|
|
|
|
|
|
|
// MQTT
|
|
|
|
#include <PubSubClient.h>
|
|
|
|
|
|
|
|
// OTA
|
|
|
|
@ -20,6 +25,9 @@ void setup() |
|
|
|
// WIFI
|
|
|
|
setupWifi(); |
|
|
|
|
|
|
|
// OTA
|
|
|
|
setupOTA(); |
|
|
|
|
|
|
|
// LED
|
|
|
|
maxBrightness = LED_MAXBRIGHTNESS_DEFAULT; |
|
|
|
curbrightness = LED_BRIGHTNESS_DEFAULT; |
|
|
|
@ -49,12 +57,42 @@ void setup() |
|
|
|
} |
|
|
|
|
|
|
|
// OTA
|
|
|
|
ArduinoOTA.setHostname("alarmclock"); // on donne une petit nom a notre module
|
|
|
|
ArduinoOTA.begin(); // initialisation de l'OTA
|
|
|
|
|
|
|
|
|
|
|
|
Serial.println("End of setup"); |
|
|
|
} |
|
|
|
|
|
|
|
// OTA
|
|
|
|
void setupOTA() |
|
|
|
{ |
|
|
|
ArduinoOTA.setHostname("alarmclock"); // on donne une petit nom a notre module
|
|
|
|
ArduinoOTA.setPassword(OTA_PASSWORD); |
|
|
|
ArduinoOTA.onStart([]() { |
|
|
|
Serial.println("OTA Starting"); |
|
|
|
}); |
|
|
|
ArduinoOTA.onEnd([]() { |
|
|
|
Serial.println("\nOTA End"); |
|
|
|
}); |
|
|
|
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { |
|
|
|
Serial.printf("OTA Progress: %u%%\r", (progress / (total / 100))); |
|
|
|
}); |
|
|
|
ArduinoOTA.onError([](ota_error_t error) { |
|
|
|
Serial.printf("OTA Error[%u]: ", error); |
|
|
|
if (error == OTA_AUTH_ERROR) { |
|
|
|
Serial.println("Auth Failed"); |
|
|
|
} else if (error == OTA_BEGIN_ERROR) { |
|
|
|
Serial.println("Begin Failed"); |
|
|
|
} else if (error == OTA_CONNECT_ERROR) { |
|
|
|
Serial.println("Connect Failed"); |
|
|
|
} else if (error == OTA_RECEIVE_ERROR) { |
|
|
|
Serial.println("Receive Failed"); |
|
|
|
} else if (error == OTA_END_ERROR) { |
|
|
|
Serial.println("End Failed"); |
|
|
|
} |
|
|
|
}); |
|
|
|
ArduinoOTA.begin(); |
|
|
|
} |
|
|
|
|
|
|
|
// WIFI
|
|
|
|
void setupWifi() |
|
|
|
{ |
|
|
|
|