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
|
ottowinter/ESPAsyncWebServer-esphome@^1.2.7
|
||||||
bblanchon/ArduinoJson@^6.17.2
|
bblanchon/ArduinoJson@^6.17.2
|
||||||
plerup/EspSoftwareSerial@^6.11.6
|
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
|
// 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
|
//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
|
//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[0] = m_rxbuffer[0];
|
||||||
m_txbuffer[3] = counter;
|
m_txbuffer[3] = counter;
|
||||||
m_txbuffer[5] = cmd;
|
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
|
// 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
|
//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
|
//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[0] = m_rxbuffer[0];
|
||||||
m_txbuffer[3] = counter;
|
m_txbuffer[3] = counter;
|
||||||
m_txbuffer[5] = cmd;
|
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
|
//res=> 02 17 0a 00 00 02 05 04 30 10 ff a8 45 0e df
|
||||||
unsigned char counter = m_rxbuffer[11];
|
unsigned char counter = m_rxbuffer[11];
|
||||||
unsigned char cmd = m_rxbuffer[12];
|
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[0] = m_rxbuffer[0];
|
||||||
m_txbuffer[3] = counter;
|
m_txbuffer[3] = counter;
|
||||||
m_txbuffer[5] = cmd;
|
m_txbuffer[5] = cmd;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include <AsyncElegantOTA.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include "AsyncJson.h"
|
#include "AsyncJson.h"
|
||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
@ -163,24 +164,23 @@ void setup(){
|
|||||||
request->send(200, "text/plain", "OK");
|
request->send(200, "text/plain", "OK");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/update", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
server.on("/sysinfo", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
if (request->hasParam("channel") && request->hasParam("state")) {
|
|
||||||
String channel = request->getParam("channel")->value();
|
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
||||||
String state = request->getParam("state")->value();
|
DynamicJsonDocument root(1024);
|
||||||
if(channel.equals("door")){
|
root["freemem"] = ESP.getFreeHeap();
|
||||||
if(state=="1"){
|
root["hostname"] = WiFi.getHostname();
|
||||||
emulator.openDoor();
|
root["ip"] = WiFi.localIP().toString();
|
||||||
}else{
|
root["ssid"] = String(ssid);
|
||||||
emulator.closeDoor();
|
root["wifistatus"] = WiFi.status();
|
||||||
}
|
root["resetreason"] =esp_reset_reason();
|
||||||
}
|
serializeJson(root,*response);
|
||||||
if(channel.equals("light")){
|
|
||||||
switchLamp(state=="1");
|
request->send(response);
|
||||||
}
|
|
||||||
}
|
|
||||||
request->send(200, "text/plain", "OK");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AsyncElegantOTA.begin(&server);
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
//setup relay board
|
//setup relay board
|
||||||
@ -197,4 +197,5 @@ void setup(){
|
|||||||
|
|
||||||
// mainloop
|
// mainloop
|
||||||
void loop(){
|
void loop(){
|
||||||
|
AsyncElegantOTA.loop();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user