Compare commits
No commits in common. "3267dcfd80e8f2da8a2499c37bd018d71eb98ab4" and "c7547144d2f6b78db2dd58617082b49bd5e9e87d" have entirely different histories.
3267dcfd80
...
c7547144d2
|
@ -4,9 +4,6 @@
|
|||
#include <MD_MAX72xx.h>
|
||||
#include <SPI.h>
|
||||
#include "MD_RobotEyes.h"
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
#define DISPLAY_CLK_PIN D5
|
||||
#define DISPLAY_DATA_PIN D7
|
||||
|
@ -184,7 +181,6 @@ void Display::loop() {
|
|||
}
|
||||
|
||||
void Display::reInitializeDisplay() {
|
||||
uint32_t free = system_get_free_heap_size();
|
||||
#define REINIT_AFTER_ms 5000
|
||||
#define AVOID_REINIT_BEFORE_AND_AFTER_FULLMINUTE_FOR_s 3
|
||||
|
||||
|
@ -194,7 +190,7 @@ void Display::reInitializeDisplay() {
|
|||
&& currentTime->getSeconds() < 60 - AVOID_REINIT_BEFORE_AND_AFTER_FULLMINUTE_FOR_s
|
||||
&& currentTime->getSeconds() > AVOID_REINIT_BEFORE_AND_AFTER_FULLMINUTE_FOR_s) {
|
||||
P.begin();
|
||||
Serial.print("reinit display, free="); Serial.println(free);
|
||||
Serial.println("reinit display");
|
||||
last_reinit_ts = millis();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,51 +133,6 @@ void WebServer::begin() {
|
|||
json = String();
|
||||
});
|
||||
|
||||
server.on("/sys/swupdate", HTTP_GET, [&](AsyncWebServerRequest *request){
|
||||
#define UPDATE_DELAY 100
|
||||
Serial.println(F("\n Check for SWUpdate"));
|
||||
|
||||
// create json return
|
||||
String json = "{";
|
||||
if (ias != NULL) {
|
||||
json += "\"result\":\"OK\"";
|
||||
} else {
|
||||
json += "\"result\":\"FAILED\",";
|
||||
json += "\"message\":\"IAS not initialized in web server, use setIAS method.\"";
|
||||
}
|
||||
json += "}";
|
||||
|
||||
// return json to WebApp
|
||||
request->send(200, F("text/json"), json);
|
||||
json = String();
|
||||
if (ias != NULL) {
|
||||
Serial.println("Checking for software updates");
|
||||
checkSoftwareUpdate_ts = millis() + UPDATE_DELAY;
|
||||
}
|
||||
});
|
||||
|
||||
server.on("/sys/reboot", HTTP_GET, [&](AsyncWebServerRequest *request){
|
||||
#define REBOOT_DELAY 100
|
||||
Serial.println(F("\n Reboot device"));
|
||||
|
||||
String json = "{";
|
||||
json += "\"result\":\"OK\"";
|
||||
json += "}";
|
||||
|
||||
// return json to WebApp
|
||||
request->send(200, F("text/json"), json);
|
||||
json = String();
|
||||
Serial.println("Rebooting device");
|
||||
rebootDevice_ts = millis() + REBOOT_DELAY;
|
||||
});
|
||||
|
||||
server.on("/sys/heap", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
String json = "{";
|
||||
json += "\"result\":\"OK\",";
|
||||
json += "\"heap\":" + String(ESP.getFreeHeap());
|
||||
json += "}";
|
||||
request->send(200, "text/json", json);
|
||||
});
|
||||
|
||||
server.serveStatic("/", SPIFFS, "/");
|
||||
server.onNotFound(onRequest);
|
||||
|
@ -188,24 +143,3 @@ void WebServer::begin() {
|
|||
Serial.println(WiFi.localIP());
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void WebServer::loop() {
|
||||
if (rebootDevice_ts > 0 && rebootDevice_ts < millis()) {
|
||||
rebootDevice_ts = 0;
|
||||
Serial.println("Rebooting device.");
|
||||
delay(20);
|
||||
ESP.restart();
|
||||
}
|
||||
if (checkSoftwareUpdate_ts > 0 && checkSoftwareUpdate_ts < millis()) {
|
||||
checkSoftwareUpdate_ts = 0;
|
||||
Serial.println("Checking for software updates.");
|
||||
delay(20);
|
||||
if (ias != NULL) {
|
||||
ias->callHome(true);
|
||||
} else {
|
||||
Serial.println("ERROR: IAS not set, use setIAS method in web server");
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,23 +5,18 @@
|
|||
#include <ESPAsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <FS.h>
|
||||
#include <IOTAppStory.h>
|
||||
#include "Relays.h"
|
||||
#include "Clock.h"
|
||||
|
||||
class WebServer {
|
||||
public:
|
||||
WebServer(Relays *r, Clock *real_t, Clock *model_t):
|
||||
relays(r),realTime(real_t),modelTime(model_t), checkSoftwareUpdate_ts(0), rebootDevice_ts(0) {};
|
||||
WebServer(Relays *r, Clock *real_t, Clock *model_t):relays(r),realTime(real_t),modelTime(model_t) {};
|
||||
void begin();
|
||||
void loop();
|
||||
void setIAS(IOTAppStory *_ias) { ias = _ias;};
|
||||
|
||||
protected:
|
||||
Relays *relays;
|
||||
Clock *realTime, *modelTime;
|
||||
unsigned long checkSoftwareUpdate_ts, rebootDevice_ts;
|
||||
IOTAppStory *ias;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -83,22 +83,6 @@
|
|||
ajaxGet("/clock/real", handleChangeClockResponse);
|
||||
}
|
||||
|
||||
function handleTriggerSWUpdateCheck(result) {
|
||||
showMessage(JSON.stringify(result, null, 2));
|
||||
};
|
||||
|
||||
function triggerSWUpdateCheck() {
|
||||
ajaxGet("/sys/swupdate", handleTriggerSWUpdateCheck);
|
||||
}
|
||||
|
||||
function handleTriggerReboot(result) {
|
||||
showMessage(JSON.stringify(result, null, 2));
|
||||
};
|
||||
|
||||
function triggerReboot() {
|
||||
ajaxGet("/sys/reboot", handleTriggerReboot);
|
||||
}
|
||||
|
||||
function onBodyLoad() {
|
||||
var button = document.getElementById("button");
|
||||
button.onmousedown = function(event) {
|
||||
|
@ -133,8 +117,6 @@
|
|||
<div>
|
||||
<button onClick="setClockToModel()">Model time</button>
|
||||
<button onClick="setClockToReal()">Real time</button>
|
||||
<button onClick="triggerSWUpdateCheck()">Check SW Update</button>
|
||||
<button onClick="triggerReboot()">Reboot</button>
|
||||
</div>
|
||||
<div id="displayMessageId" class="logmsg"></div>
|
||||
<div class="btn_cnt"><img id="led" src="led-off.png"><a href="#"><img id="button" src="btn.png"></a></div>
|
||||
|
|
|
@ -183,7 +183,6 @@ void setup(void)
|
|||
setupFS();
|
||||
setupIAS();
|
||||
W.begin();
|
||||
W.setIAS(&IAS);
|
||||
delay(100);
|
||||
R.begin(relay1Pin, relay2Pin);
|
||||
timeClient.begin();
|
||||
|
|
Loading…
Reference in New Issue