OTA Update
This commit is contained in:
parent
7c8e59d0c0
commit
cda0209f98
@ -15,3 +15,4 @@ framework = arduino
|
||||
lib_deps =
|
||||
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
|
||||
bblanchon/ArduinoJson@^6.17.2
|
||||
ayushsharma82/AsyncElegantOTA@^2.2.5
|
||||
|
@ -63,7 +63,6 @@
|
||||
|
||||
bool skipFrame = false;
|
||||
|
||||
|
||||
int recvTime = 0;
|
||||
int lastSendTime = 0;
|
||||
int lastStateTime = 0;
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include <Arduino.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include "AsyncJson.h"
|
||||
#include "ArduinoJson.h"
|
||||
#include <AsyncElegantOTA.h>
|
||||
#include <AsyncJson.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "hciemulator.h"
|
||||
#include "index_html.h"
|
||||
|
||||
|
||||
/* create this file and add your wlan credentials
|
||||
const char* ssid = "MyWLANSID";
|
||||
const char* password = "MYPASSWORD";
|
||||
@ -126,25 +128,36 @@ void setup(){
|
||||
}
|
||||
request->send(200, "text/plain", "OK");
|
||||
});
|
||||
|
||||
server.on("/sysinfo", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
String freemem;
|
||||
String ResetReason;
|
||||
freemem = ESP.getFreeHeap();
|
||||
rst_info* rinfo = ESP.getResetInfoPtr();
|
||||
|
||||
//JSONencoder["uptimed"] = Day2;
|
||||
//JSONencoder["uptimeh"] = Hour2;
|
||||
//JSONencoder["uptimem"] = Minute2;
|
||||
//JSONencoder["uptimes"] = Second2;
|
||||
|
||||
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
||||
DynamicJsonDocument root(1024);
|
||||
root["freemem"] = freemem;
|
||||
ResetReason += String(rinfo->reason);
|
||||
ResetReason += String(" - ");
|
||||
ResetReason += String(ESP.getResetReason().c_str());
|
||||
root["hostname"] = String(WiFi.hostname());
|
||||
root["dsdd"] = WiFi.localIP().toString();
|
||||
root["ssid"] = String(ssid);
|
||||
root["wifistatus"] = String(WiFi.status());
|
||||
root["resetreason"] =ResetReason;
|
||||
root["errors"] = rinfo->exccause;
|
||||
serializeJson(root,*response);
|
||||
|
||||
server.on("/update", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
if (request->hasParam("channel") && request->hasParam("state")) {
|
||||
String channel = request->getParam("channel")->value();
|
||||
String state = request->getParam("state")->value();
|
||||
if(channel.equals("door")){
|
||||
if(state=="1"){
|
||||
openDoor();
|
||||
}else{
|
||||
closeDoor();
|
||||
}
|
||||
}
|
||||
if(channel.equals("light")){
|
||||
switchLamp(state=="1");
|
||||
}
|
||||
}
|
||||
request->send(200, "text/plain", "OK");
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
AsyncElegantOTA.begin(&server);
|
||||
server.begin();
|
||||
|
||||
//setup relay board
|
||||
@ -166,4 +179,5 @@ void loop(){
|
||||
onStatusChanged(getHCIState());
|
||||
isLampOn = newisLampOn;
|
||||
}
|
||||
AsyncElegantOTA.loop();
|
||||
}
|
Loading…
Reference in New Issue
Block a user