esp32 compat

This commit is contained in:
2018-11-17 15:10:03 +01:00
parent 4fbf9b2090
commit 428b2c209a
4 changed files with 30 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
[platformio]
env_default = basic
;[platformio]
;env_default = basic
[common]
framework = arduino
@@ -27,3 +27,16 @@ upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
framework = ${common.framework}
lib_deps = ${common.lib_deps}
[env:basic_esp32]
src_filter = +<*> -<examples/> +<examples/basic/>
platform = espressif32
board = esp32dev
upload_speed = ${common.upload_speed}
monitor_baud = ${common.monitor_baud}
framework = ${common.framework}
build_flags = -std=c++14 -DESP32
lib_deps = ${common.lib_deps}
AsyncWebServer
AsyncTCP
Update

View File

@@ -3,7 +3,6 @@
WebApiPlugin::WebApiPlugin(AsyncWebServer *_server)
{
server = _server;
Update.runAsync(true);
}
void WebApiPlugin::activate(Scheduler *_scheduler)
@@ -62,8 +61,13 @@ void WebApiPlugin::onFirmwareUpload(AsyncWebServerRequest *request, const String
if (!index)
{
PRINT_MSG(Serial, "OTA", "Update Start %s", filename.c_str());
#ifdef ESP8266
Update.runAsync(true);
if (!Update.begin((ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000))
uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
#elif defined(ESP32)
uint32_t maxSketchSpace = (1048576 - 0x1000) & 0xFFFFF000;
#endif
if (!Update.begin(maxSketchSpace))
{
Update.printError(Serial);
}

View File

@@ -3,8 +3,11 @@
#include <TaskSchedulerDeclarations.h>
#include <Sprocket.h>
#ifdef ESP32
#include <Update.h>
#elif defined(ESP8266)
#include <Updater.h>
#endif
#include "config.h"
#include "utils/print.h"
#include "WebUtils.h"

View File

@@ -4,7 +4,11 @@
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <AsyncWebSocket.h>
#ifdef ESP32
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESPAsyncTCP.h>
#endif
class WebUtils
{