Supports AutoConnectUpdate

pull/123/head
Hieromon Ikasamo 6 years ago
parent 9e277af22c
commit 85a1f00417
  1. 15
      examples/Update/Update.ino
  2. 7
      src/AutoConnectUpdate.cpp
  3. 10
      src/AutoConnectUpdate.h

@ -35,8 +35,19 @@ void setup() {
// Responder of root page handled directly from WebServer class.
server.on("/", []() {
String content = "Place the root page with the sketch application. ";
content += AUTOCONNECT_LINK(COG_24);
String content = R"(
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
Place the root page with the sketch application.&ensp;
__AC_LINK__
</body>
</html>
)";
content.replace("__AC_LINK__", String(AUTOCONNECT_LINK(COG_24)));
server.send(200, "text/html", content);
});

@ -7,6 +7,7 @@
* @copyright MIT license.
*/
#include <functional>
#include "AutoConnectUpdate.h"
#include "AutoConnectUpdatePage.h"
#include "AutoConnectJsonDefs.h"
@ -106,6 +107,10 @@ void AutoConnectUpdate::attach(AutoConnect& portal) {
_status = UPDATE_IDLE;
#ifdef ARDUINO_ARCH_ESP32
Update.onProgress(std::bind(&AutoConnectUpdate::_inProgress, this, std::placeholders::_1, std::placeholders::_2));
#endif
// Attach this to the AutoConnectUpdate
portal._update.reset(this);
AC_DBG("AutoConnectUpdate attached\n");
@ -389,7 +394,7 @@ String AutoConnectUpdate::_onResult(AutoConnectAux& result, PageArgument& args)
resColor = String(F("red"));
break;
default:
resForm = String(F("No available update."));
resForm = String(F("<br>No available update."));
resColor = String(F("red"));
break;
}

@ -115,11 +115,21 @@ class AutoConnectUpdate : public HTTPUpdateClass {
String _onUpdate(AutoConnectAux& update, PageArgument& args);
String _onResult(AutoConnectAux& result, PageArgument& args);
size_t _insertCatalog(AutoConnectRadio& radio, JsonVariant & responseBody);
#ifdef ARDUINO_ARCH_ESP32
void _inProgress(size_t amount, size_t size) {
_amount = amount;
_binSize = size;
AC_DBG_DUMB(".");
}
#endif
std::unique_ptr<AutoConnectAux> _catalog; /**< A catalog page for internally generated update binaries */
std::unique_ptr<AutoConnectAux> _progress; /**< An update in-progress page */
std::unique_ptr<AutoConnectAux> _result; /**< A update result page */
size_t _amount; /**< Received amound bytes */
size_t _binSize; /**< Updater binary size */
private:
AC_UPDATESTATUS_t _status;
String _binName; /**< .bin name to update */

Loading…
Cancel
Save