OTA Update on ESP32
This commit is contained in:
parent
26b4fbf393
commit
5fb027b629
@ -16,3 +16,4 @@ lib_deps =
|
||||
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
|
||||
bblanchon/ArduinoJson@^6.17.2
|
||||
plerup/EspSoftwareSerial@^6.11.6
|
||||
ayushsharma82/AsyncElegantOTA@^2.2.5
|
||||
|
@ -216,7 +216,7 @@ void HCIEmulator::processDeviceStatusFrame(){
|
||||
// 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
|
||||
//0011: 02 17 9C B9 00 08 9C 41 00 02 04 3E 03 00 00 EB CC
|
||||
//res=> 02 17 10 3E 00 03 01 00 00 00 00 00 00 00 00 00 00 00 00 74 1B
|
||||
memcpy_P(m_txbuffer, ResponseTemplate_Fcn17_Cmd03_L08, sizeof(ResponseTemplate_Fcn17_Cmd03_L08));
|
||||
memcpy(m_txbuffer, ResponseTemplate_Fcn17_Cmd03_L08, sizeof(ResponseTemplate_Fcn17_Cmd03_L08));
|
||||
m_txbuffer[0] = m_rxbuffer[0];
|
||||
m_txbuffer[3] = counter;
|
||||
m_txbuffer[5] = cmd;
|
||||
@ -326,7 +326,7 @@ void HCIEmulator::processDeviceStatusFrame(){
|
||||
// 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16
|
||||
//0011: 02 17 9C B9 00 02 9C 41 00 02 04 0F 04 17 00 7B 21
|
||||
//res=> 02 17 04 0F 00 04 FD 0A 72
|
||||
memcpy_P(m_txbuffer, ResponseTemplate_Fcn17_Cmd04_L02, sizeof(ResponseTemplate_Fcn17_Cmd04_L02));
|
||||
memcpy(m_txbuffer, ResponseTemplate_Fcn17_Cmd04_L02, sizeof(ResponseTemplate_Fcn17_Cmd04_L02));
|
||||
m_txbuffer[0] = m_rxbuffer[0];
|
||||
m_txbuffer[3] = counter;
|
||||
m_txbuffer[5] = cmd;
|
||||
@ -345,7 +345,7 @@ void HCIEmulator::processDeviceBusScanFrame(){
|
||||
//res=> 02 17 0a 00 00 02 05 04 30 10 ff a8 45 0e df
|
||||
unsigned char counter = m_rxbuffer[11];
|
||||
unsigned char cmd = m_rxbuffer[12];
|
||||
memcpy_P(m_txbuffer, ResponseTemplate_Fcn17_Cmd02_L05, sizeof(ResponseTemplate_Fcn17_Cmd02_L05));
|
||||
memcpy(m_txbuffer, ResponseTemplate_Fcn17_Cmd02_L05, sizeof(ResponseTemplate_Fcn17_Cmd02_L05));
|
||||
m_txbuffer[0] = m_rxbuffer[0];
|
||||
m_txbuffer[3] = counter;
|
||||
m_txbuffer[5] = cmd;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <Arduino.h>
|
||||
#include <AsyncElegantOTA.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include "AsyncJson.h"
|
||||
#include "ArduinoJson.h"
|
||||
@ -163,24 +164,23 @@ void setup(){
|
||||
request->send(200, "text/plain", "OK");
|
||||
});
|
||||
|
||||
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"){
|
||||
emulator.openDoor();
|
||||
}else{
|
||||
emulator.closeDoor();
|
||||
}
|
||||
}
|
||||
if(channel.equals("light")){
|
||||
switchLamp(state=="1");
|
||||
}
|
||||
}
|
||||
request->send(200, "text/plain", "OK");
|
||||
server.on("/sysinfo", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||
|
||||
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
||||
DynamicJsonDocument root(1024);
|
||||
root["freemem"] = ESP.getFreeHeap();
|
||||
root["hostname"] = WiFi.getHostname();
|
||||
root["ip"] = WiFi.localIP().toString();
|
||||
root["ssid"] = String(ssid);
|
||||
root["wifistatus"] = WiFi.status();
|
||||
root["resetreason"] =esp_reset_reason();
|
||||
serializeJson(root,*response);
|
||||
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
AsyncElegantOTA.begin(&server);
|
||||
|
||||
server.begin();
|
||||
|
||||
//setup relay board
|
||||
@ -197,4 +197,5 @@ void setup(){
|
||||
|
||||
// mainloop
|
||||
void loop(){
|
||||
AsyncElegantOTA.loop();
|
||||
}
|
Loading…
Reference in New Issue
Block a user