bootDelay
This commit is contained in:
parent
5c5fba217c
commit
2d22c2f136
@ -23,8 +23,10 @@ platform = ${common.platform}
|
||||
board = ${common.board}
|
||||
framework = ${common.framework}
|
||||
lib_deps = ${common.lib_deps}
|
||||
upload_port = ${common.upload_port}
|
||||
upload_speed = ${common.upload_speed}
|
||||
upload_port = 10.0.0.119
|
||||
upload_protocol = espota
|
||||
;upload_port = ${common.upload_port}
|
||||
;upload_speed = ${common.upload_speed}
|
||||
monitor_port = ${common.monitor_port}
|
||||
monitor_speed = ${common.monitor_speed}
|
||||
monitor_filters = ${common.monitor_filters}
|
||||
|
||||
@ -4,9 +4,9 @@
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "patrix/Node.h"
|
||||
#include "patrix/mqtt.h"
|
||||
#include "patrix/sensor/Dallas.h"
|
||||
#include "patrix/sensor/DallasSensor.h"
|
||||
#include "patrix/sensor/Max6675Sensor.h"
|
||||
#include "patrix/sensor/DHT22.h"
|
||||
|
||||
class NodeTest final : public Node {
|
||||
|
||||
29
src/patrix/boot.cpp
Normal file
29
src/patrix/boot.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "boot.h"
|
||||
|
||||
#include "wifi.h"
|
||||
#include "clock.h"
|
||||
#include "log.h"
|
||||
|
||||
void bootDelay() {
|
||||
info("Waiting for WiFi...");
|
||||
while (!isWiFiConnected()) {
|
||||
wifiLoop();
|
||||
yield();
|
||||
}
|
||||
|
||||
info("Waiting for clock to be set...");
|
||||
while (!isClockSet()) {
|
||||
wifiLoop();
|
||||
clockLoop();
|
||||
yield();
|
||||
}
|
||||
|
||||
info("Waiting 5 seconds for OTA update...");
|
||||
const auto start = millis();
|
||||
while (millis() - start < 5000) {
|
||||
wifiLoop();
|
||||
yield();
|
||||
}
|
||||
|
||||
info("Boot delay complete.");
|
||||
}
|
||||
6
src/patrix/boot.h
Normal file
6
src/patrix/boot.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef BOOT_H
|
||||
#define BOOT_H
|
||||
|
||||
void bootDelay();
|
||||
|
||||
#endif //BOOT_H
|
||||
@ -1,29 +1,33 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "mqtt.h"
|
||||
#include "boot.h"
|
||||
#include "wifi.h"
|
||||
#include "clock.h"
|
||||
#include "http.h"
|
||||
#include "mqtt.h"
|
||||
|
||||
#ifdef NODE_TEST
|
||||
#include "NodeTest.h"
|
||||
NodeTest node = NodeTest();
|
||||
|
||||
auto node = NodeTest();
|
||||
#endif
|
||||
|
||||
#ifdef NODE_HEIZUNG
|
||||
#include "NodeHeizung.h"
|
||||
NodeHeizung node = NodeHeizung();
|
||||
#include "NodeHeizung.h"
|
||||
|
||||
auto node = NodeHeizung();
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(500);
|
||||
Serial.print("Startup\n");
|
||||
bootDelay();
|
||||
httpSetup();
|
||||
node.setup();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wifiLoop();
|
||||
clockLoop();
|
||||
mqttLoop();
|
||||
node.loop();
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public:
|
||||
void loop() {
|
||||
if (lastMillis == 0 || millis() - lastMillis > DALLAS_TIMEOUT_MILLISECONDS) {
|
||||
if (converting) {
|
||||
error("Dallas timeout!\n");
|
||||
error("Dallas timeout!");
|
||||
}
|
||||
sensors.requestTemperatures();
|
||||
timestamp = time(nullptr);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user