ajout de l'ota
This commit is contained in:
parent
14cf69cb0d
commit
2c2e43ed4f
@ -37,7 +37,6 @@ Avancement
|
||||
WIP.
|
||||
Le partie arduino fonctionne, mais pour le moment il n'y a pas d'arret automatique de l'alarme.
|
||||
La partie home-assistant fonctionne, le reveil configuré est bien envoyé à l'arduino.
|
||||
TODO: Utiliser ArduinoOTA pour gérer les mises à jours sans fil.
|
||||
TODO: gitlab-ci : on peut checker la syntax en lancant un docker home-assistant !!!
|
||||
TODO: HA Il faut des scenes pour retrouver les couleurs classiques
|
||||
TODO: Ard pas d'arret une fois le reveil lancé
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -3,6 +3,9 @@
|
||||
#define SHOW_FPS 1
|
||||
int fps;
|
||||
|
||||
// OTA
|
||||
#define OTA_PASSWORD "XXX"
|
||||
|
||||
// LED
|
||||
#define LED_NUM 30
|
||||
#define LED_PIN 5 // = D1
|
||||
@ -43,6 +46,7 @@ char message_buff[100];
|
||||
PubSubClient client(espClient);
|
||||
|
||||
|
||||
void setupOTA();
|
||||
void setupWifi();
|
||||
void testConnectMQTT();
|
||||
void callbackMQTT(char* topic, byte* payload, unsigned int length);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user