forked from jeanjack/PiedThon
Compare commits
No commits in common. "arduinoota-fix" and "master" have entirely different histories.
arduinoota
...
master
70
arduino.cpp
70
arduino.cpp
@ -57,41 +57,6 @@ void setupWifi() {
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
}
|
||||
|
||||
void setupOTA() {
|
||||
ArduinoOTA.setHostname(ESP_HOSTNAME);
|
||||
ArduinoOTA.onStart([]() { // switch off all the GPIOs during upgrade
|
||||
digitalWrite(GPIO_ROUGE, HIGH);
|
||||
digitalWrite(GPIO_VERT, HIGH);
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
/*if (progress % (total / 4) == 0) {
|
||||
digitalWrite(GPIO_ROUGE, random(2) ? LOW : HIGH);
|
||||
digitalWrite(GPIO_VERT, random(2) ? LOW : HIGH);
|
||||
}*/
|
||||
|
||||
});
|
||||
|
||||
ArduinoOTA.onEnd([]() { // do a fancy thing with our board led at end
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int RANDOM_GPIO = GPIO_ROUGE;
|
||||
if (random(2)) { // random(2) returns 0 or 1 randomly
|
||||
RANDOM_GPIO = GPIO_VERT;
|
||||
}
|
||||
digitalWrite(RANDOM_GPIO, !digitalRead(RANDOM_GPIO));
|
||||
delay(400);
|
||||
}
|
||||
digitalWrite(GPIO_ROUGE, LOW);
|
||||
digitalWrite(GPIO_VERT, LOW);
|
||||
});
|
||||
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
(void)error;
|
||||
ESP.restart();
|
||||
});
|
||||
ArduinoOTA.begin();
|
||||
Serial.println(F("End of OTA setup"));
|
||||
}
|
||||
/// MQTT
|
||||
|
||||
#include "Adafruit_MQTT.h"
|
||||
@ -183,16 +148,47 @@ void setup() {
|
||||
randomSeed(analogRead(0));
|
||||
|
||||
setupWifi();
|
||||
setupOTA();
|
||||
|
||||
// Setup MQTT subscription for onoff feed.
|
||||
mqtt.subscribe(&sub_piedthon);
|
||||
|
||||
|
||||
ArduinoOTA.setHostname(ESP_HOSTNAME);
|
||||
ArduinoOTA.onStart([]() { // switch off all the GPIOs during upgrade
|
||||
digitalWrite(GPIO_ROUGE, HIGH);
|
||||
digitalWrite(GPIO_VERT, HIGH);
|
||||
});
|
||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||
/*if (progress % (total / 4) == 0) {
|
||||
digitalWrite(GPIO_ROUGE, random(2) ? LOW : HIGH);
|
||||
digitalWrite(GPIO_VERT, random(2) ? LOW : HIGH);
|
||||
}*/
|
||||
|
||||
});
|
||||
|
||||
ArduinoOTA.onEnd([]() { // do a fancy thing with our board led at end
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int RANDOM_GPIO = GPIO_ROUGE;
|
||||
if (random(2)) { // random(2) returns 0 or 1 randomly
|
||||
RANDOM_GPIO = GPIO_VERT;
|
||||
}
|
||||
digitalWrite(RANDOM_GPIO, !digitalRead(RANDOM_GPIO));
|
||||
delay(400);
|
||||
}
|
||||
digitalWrite(GPIO_ROUGE, LOW);
|
||||
digitalWrite(GPIO_VERT, LOW);
|
||||
});
|
||||
|
||||
ArduinoOTA.onError([](ota_error_t error) {
|
||||
(void)error;
|
||||
ESP.restart();
|
||||
});
|
||||
ArduinoOTA.begin();
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
MQTT_connect();
|
||||
MDNS.update();
|
||||
ArduinoOTA.handle();
|
||||
|
||||
Adafruit_MQTT_Subscribe *subscription;
|
||||
|
Loading…
Reference in New Issue
Block a user