From 86ee523182965adce56465fc4486197c603edd38 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Sun, 30 Aug 2020 00:12:11 +0300 Subject: [PATCH] esp32 compiling version --- include/Consts.h | 6 +++++- include/FSEditor.h | 5 +++-- include/SSDP.h | 4 +++- include/Servo/Servos.h | 6 +++++- platformio.ini | 34 ++++++++++++++++++---------------- src/FSEditor.cpp | 3 ++- src/SSDP.cpp | 4 +++- src/Servo/Servs.cpp | 3 ++- src/Upgrade.cpp | 4 ++-- src/Utils/WiFiUtils.cpp | 2 +- src/WebServer.cpp | 2 ++ src/main.cpp | 4 +++- 12 files changed, 49 insertions(+), 28 deletions(-) diff --git a/include/Consts.h b/include/Consts.h index cf398039..ae6ec4b0 100644 --- a/include/Consts.h +++ b/include/Consts.h @@ -46,11 +46,15 @@ #define BME_ENABLED +//#define FSEditor + +//#define SSDP + /* * Gears */ #define STEPPER_ENABLED -#define SERVO_ENABLED +//#define SERVO_ENABLED /* * Other diff --git a/include/FSEditor.h b/include/FSEditor.h index 394fb0e2..72fefb9d 100644 --- a/include/FSEditor.h +++ b/include/FSEditor.h @@ -1,5 +1,5 @@ #pragma once - +#ifdef FSEditor #include #include @@ -25,4 +25,5 @@ class FSEditor : public AsyncWebHandler { virtual void handleRequest(AsyncWebServerRequest* request) override final; virtual void handleUpload(AsyncWebServerRequest* request, const String& filename, size_t index, uint8_t* data, size_t len, bool final) override final; virtual bool isRequestHandlerTrivial() override final { return false; } -}; \ No newline at end of file +}; +#endif \ No newline at end of file diff --git a/include/SSDP.h b/include/SSDP.h index 12b6f6e1..6eaff70c 100644 --- a/include/SSDP.h +++ b/include/SSDP.h @@ -1,6 +1,8 @@ #pragma once +#ifdef SSDP #include extern void SsdpInit(); extern String xmlNode(String tags, String data); -extern String decToHex(uint32_t decValue, byte desiredStringLength); \ No newline at end of file +extern String decToHex(uint32_t decValue, byte desiredStringLength); +#endif \ No newline at end of file diff --git a/include/Servo/Servos.h b/include/Servo/Servos.h index c4ac44dd..2ff3e1ec 100644 --- a/include/Servo/Servos.h +++ b/include/Servo/Servos.h @@ -1,6 +1,8 @@ #pragma once +#ifdef SERVO_ENABLED #include +#include #include struct Servo_t { @@ -22,4 +24,6 @@ class Servos { std::vector _items; }; -extern Servos myServo; \ No newline at end of file +extern Servos myServo; + +#endif \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 20597547..7e349997 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = esp32 +default_envs = esp8266 [common_env_data] lib_deps_external = @@ -25,21 +25,6 @@ lib_deps_internal = GyverFilters OneWire -[env:esp32] -framework = arduino -board = esp32dev -platform = https://github.com/platformio/platform-espressif32.git -lib_deps = - ${common_env_data.lib_deps_external} - ${common_env_data.lib_deps_internal} - AsyncTCP - ESP32Servo - LITTLEFS -monitor_filters = esp32_exception_decoder -upload_speed = 921600 -monitor_speed = 115200 -board_build.filesystem = littlefs - [env:esp8266_01_1m] framework = arduino board = esp01_1m @@ -73,6 +58,23 @@ monitor_speed = 115200 board_build.filesystem = littlefs board_build.f_cpu = 160000000L +[env:esp32] +framework = arduino +board = esp32dev +platform = https://github.com/platformio/platform-espressif32.git +build_flags = ${env.build_flags} -D=${PIOENV} +extra_scripts = ./tools/littlefsbuilder.py +lib_deps = + ${common_env_data.lib_deps_external} + ${common_env_data.lib_deps_internal} + AsyncTCP + ESP32Servo + LITTLEFS +monitor_filters = esp32_exception_decoder +upload_speed = 921600 +monitor_speed = 115200 +board_build.filesystem = littlefs + ; build_type = debug ; build_flags = ; -DDEBUG_ESP_CORE diff --git a/src/FSEditor.cpp b/src/FSEditor.cpp index bdaa5129..50a53639 100644 --- a/src/FSEditor.cpp +++ b/src/FSEditor.cpp @@ -1,5 +1,5 @@ +#ifdef FSEditor #include "FSEditor.h" - #ifdef ESP32 #include "LITTLEFS.h" #define LittleFS LITTLEFS @@ -324,3 +324,4 @@ void FSEditor::handleUpload(AsyncWebServerRequest *request, const String &filena } } } +#endif \ No newline at end of file diff --git a/src/SSDP.cpp b/src/SSDP.cpp index 0b044e4b..3f0d4544 100644 --- a/src/SSDP.cpp +++ b/src/SSDP.cpp @@ -1,3 +1,4 @@ +#ifdef SSDP #ifdef ESP8266 #include #endif @@ -52,4 +53,5 @@ String decToHex(uint32_t decValue, byte desiredStringLength) { String hexString = String(decValue, HEX); while (hexString.length() < desiredStringLength) hexString = "0" + hexString; return hexString; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/Servo/Servs.cpp b/src/Servo/Servs.cpp index 96ebba91..8667baa0 100644 --- a/src/Servo/Servs.cpp +++ b/src/Servo/Servs.cpp @@ -1,5 +1,5 @@ +#ifdef SERVO_ENABLED #include "Servo/Servos.h" - Servos myServo; Servos::Servos(){}; @@ -38,3 +38,4 @@ Servo *Servos::get(uint8_t num) { size_t Servos::count() { return _items.size(); } +#endif diff --git a/src/Upgrade.cpp b/src/Upgrade.cpp index effac97c..5a38e5cf 100644 --- a/src/Upgrade.cpp +++ b/src/Upgrade.cpp @@ -59,7 +59,7 @@ void upgrade_firmware() { t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(wifiClient, "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin"); #else httpUpdate.rebootOnUpdate(false); - t_httpUpdate_return ret = httpUpdate.updateSpiffs(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin"); + t_httpUpdate_return ret = httpUpdate.updateSpiffs(wifiClient, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin"); #endif if (ret == HTTP_UPDATE_OK) { writeFile(String(DEVICE_SCENARIO_FILE), scanerioBackup); @@ -78,7 +78,7 @@ void upgrade_firmware() { #ifdef ESP8266 ret = ESPhttpUpdate.update(wifiClient, "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin"); #else - ret = httpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin"); + ret = httpUpdate.update(wifiClient, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin"); #endif if (ret == HTTP_UPDATE_OK) { pm.info("done! restart..."); diff --git a/src/Utils/WiFiUtils.cpp b/src/Utils/WiFiUtils.cpp index 950ec1f2..d28a8933 100644 --- a/src/Utils/WiFiUtils.cpp +++ b/src/Utils/WiFiUtils.cpp @@ -20,7 +20,7 @@ void startSTAMode() { bool keepConnecting = true; uint8_t tries = 20; - sint8_t connRes; + int8_t connRes; do { #ifdef ESP8266 connRes = WiFi.waitForConnectResult(1000); diff --git a/src/WebServer.cpp b/src/WebServer.cpp index cf4ef379..7b31056d 100644 --- a/src/WebServer.cpp +++ b/src/WebServer.cpp @@ -15,10 +15,12 @@ void initWS(); void init() { String login = jsonReadStr(configSetupJson, "weblogin"); String pass = jsonReadStr(configSetupJson, "webpass"); +#ifdef FSEditor #ifdef ESP32 server.addHandler(new FSEditor(LittleFS, login, pass)); #else server.addHandler(new FSEditor(login, pass)); +#endif #endif server.serveStatic("/css/", LittleFS, "/css/").setCacheControl("max-age=600"); diff --git a/src/main.cpp b/src/main.cpp index c8c68db9..745e16f2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include + #include "Class/CallBackTest.h" #include "Class/NotAsinc.h" #include "Class/ScenarioClass.h" @@ -72,9 +73,10 @@ void setup() { pm.info("Broadcast UDP"); udpInit(); #endif - +#ifdef SSDP pm.info("Ssdp Init"); SsdpInit(); +#endif ts.add( TEST, 1000 * 60, [&](void*) {