From d0c9bad5bcb9cba1b8d07d68ca7e7aed8c2ebd59 Mon Sep 17 00:00:00 2001 From: elims <46279009+theelims@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:12:40 +0100 Subject: [PATCH] minor fixes --- CHANGELOG.md | 10 +++++++++- factory_settings.ini | 1 + interface/vite.config.ts | 6 +++--- lib/framework/APSettingsService.cpp | 1 - lib/framework/APStatus.cpp | 1 - lib/framework/APStatus.h | 1 - lib/framework/AnalyticsService.h | 2 +- lib/framework/AuthenticationService.cpp | 1 - lib/framework/BatteryService.cpp | 1 - lib/framework/DownloadFirmwareService.cpp | 1 - lib/framework/DownloadFirmwareService.h | 1 - lib/framework/ESP32SvelteKit.cpp | 2 +- lib/framework/ESP32SvelteKit.h | 2 +- lib/framework/FactoryResetService.cpp | 1 - lib/framework/FactoryResetService.h | 1 - lib/framework/FeaturesService.cpp | 3 ++- lib/framework/HttpEndpoint.h | 1 - lib/framework/MqttSettingsService.cpp | 2 -- lib/framework/MqttStatus.cpp | 1 - lib/framework/NTPSettingsService.cpp | 2 -- lib/framework/NTPStatus.cpp | 1 - lib/framework/NotificationEvents.cpp | 1 - lib/framework/NotificationEvents.h | 1 - lib/framework/RestartService.cpp | 1 - lib/framework/RestartService.h | 1 - lib/framework/SecuritySettingsService.cpp | 2 -- lib/framework/SleepService.cpp | 1 - lib/framework/SystemStatus.cpp | 7 +------ lib/framework/UploadFirmwareService.cpp | 1 - lib/framework/WebSocketServer.h | 2 -- lib/framework/WiFiScanner.cpp | 1 - lib/framework/WiFiScanner.h | 1 - lib/framework/WiFiStatus.cpp | 1 - lib/framework/WiFiStatus.h | 1 - platformio.ini | 4 ++-- src/main.cpp | 6 ------ 36 files changed, 21 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2d81476..f16c0b1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -## WIP +## [0.3.0] - WIP > **Warning**: This update has breaking changes! @@ -48,6 +48,14 @@ Remove the following `build_flags`: -D NO_GLOBAL_ARDUINOOTA ``` +Add the following `build_flags` and adjust to your app, if needed: + +```ini + -D BUILD_TARGET=\"$PIOENV\" + -D APP_NAME=\"ESP32-Sveltekit\" ; Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename + -D APP_VERSION=\"0.3.0\" ; semver compatible version string +``` + Change `-D CORE_DEBUG_LEVEL=2` to no higher than 2. Remove the lib dependency `esphome/AsyncTCP-esphome @ ^2.0.0` and add `https://github.com/hoeken/PsychicHttp.git` instead. diff --git a/factory_settings.ini b/factory_settings.ini index 81712ab0..489065fe 100644 --- a/factory_settings.ini +++ b/factory_settings.ini @@ -10,6 +10,7 @@ build_flags = -D FACTORY_WIFI_SSID=\"\" -D FACTORY_WIFI_PASSWORD=\"\" -D FACTORY_WIFI_HOSTNAME=\"#{platform}-#{unique_id}\" ; supports placeholders + -D FACTORY_WIFI_RSSI_THRESHOLD=-80 ; dBm, -80 is a good value for most applications ; Access point settings -D FACTORY_AP_PROVISION_MODE=AP_MODE_DISCONNECTED diff --git a/interface/vite.config.ts b/interface/vite.config.ts index 83a71eac..d82d8e65 100644 --- a/interface/vite.config.ts +++ b/interface/vite.config.ts @@ -16,17 +16,17 @@ const config: UserConfig = { proxy: { // Proxying REST: http://localhost:5173/rest/bar -> http://192.168.1.83/rest/bar '/rest': { - target: 'http://192.168.1.83', + target: 'http://192.168.1.89', changeOrigin: true }, // Proxying REST: http://localhost:5173/rest/bar -> http://192.168.1.83/rest/bar '/events': { - target: 'http://192.168.1.83', + target: 'http://192.168.1.89', changeOrigin: true }, // Proxying websockets ws://localhost:5173/ws -> ws://192.168.1.83/ws '/ws': { - target: 'ws://192.168.1.83', + target: 'ws://192.168.1.89', changeOrigin: true, ws: true } diff --git a/lib/framework/APSettingsService.cpp b/lib/framework/APSettingsService.cpp index 6248f3b9..b88b0c69 100644 --- a/lib/framework/APSettingsService.cpp +++ b/lib/framework/APSettingsService.cpp @@ -25,7 +25,6 @@ APSettingsService::APSettingsService(PsychicHttpServer *server, FS *fs, Security addUpdateHandler([&](const String &originId) { reconfigureAP(); }, false); - ESP_LOGV("APSettingsService", "AP Settings Service initialized"); } void APSettingsService::begin() diff --git a/lib/framework/APStatus.cpp b/lib/framework/APStatus.cpp index 90598930..9b331e68 100644 --- a/lib/framework/APStatus.cpp +++ b/lib/framework/APStatus.cpp @@ -18,7 +18,6 @@ APStatus::APStatus(PsychicHttpServer *server, SecurityManager *securityManager, _securityManager(securityManager), _apSettingsService(apSettingsService) { - ESP_LOGV("APStatus", "AP Status Service initialized"); } void APStatus::begin() { diff --git a/lib/framework/APStatus.h b/lib/framework/APStatus.h index 1979c914..55b2357f 100644 --- a/lib/framework/APStatus.h +++ b/lib/framework/APStatus.h @@ -16,7 +16,6 @@ **/ #include -#include #include #include diff --git a/lib/framework/AnalyticsService.h b/lib/framework/AnalyticsService.h index 81b3be69..70a7e628 100644 --- a/lib/framework/AnalyticsService.h +++ b/lib/framework/AnalyticsService.h @@ -34,7 +34,7 @@ class AnalyticsService "Analytics Service", // Name of the task (for debugging) 4096, // Stack size (bytes) this, // Pass reference to this class instance - (tskIDLE_PRIORITY + 1), // task priority + (tskIDLE_PRIORITY), // task priority NULL, // Task handle ESP32SVELTEKIT_RUNNING_CORE // Pin to application core ); diff --git a/lib/framework/AuthenticationService.cpp b/lib/framework/AuthenticationService.cpp index cdfd33b2..c7f808d5 100644 --- a/lib/framework/AuthenticationService.cpp +++ b/lib/framework/AuthenticationService.cpp @@ -19,7 +19,6 @@ AuthenticationService::AuthenticationService(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("AuthenticationService", "Authentication Service initialized"); } void AuthenticationService::begin() diff --git a/lib/framework/BatteryService.cpp b/lib/framework/BatteryService.cpp index 3100810d..d4003cac 100644 --- a/lib/framework/BatteryService.cpp +++ b/lib/framework/BatteryService.cpp @@ -15,7 +15,6 @@ BatteryService::BatteryService(NotificationEvents *notificationEvents) : _notificationEvents(notificationEvents) { - ESP_LOGV("BatteryService", "Battery Service initialized"); } void BatteryService::batteryEvent() diff --git a/lib/framework/DownloadFirmwareService.cpp b/lib/framework/DownloadFirmwareService.cpp index df0bf316..67dbd929 100644 --- a/lib/framework/DownloadFirmwareService.cpp +++ b/lib/framework/DownloadFirmwareService.cpp @@ -102,7 +102,6 @@ DownloadFirmwareService::DownloadFirmwareService(PsychicHttpServer *server, Secu _notificationEvents(notificationEvents) { - ESP_LOGV("DownloadFirmwareService", "Download Firmware Service initialized"); } void DownloadFirmwareService::begin() diff --git a/lib/framework/DownloadFirmwareService.h b/lib/framework/DownloadFirmwareService.h index b1de1dba..652528a2 100644 --- a/lib/framework/DownloadFirmwareService.h +++ b/lib/framework/DownloadFirmwareService.h @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/lib/framework/ESP32SvelteKit.cpp b/lib/framework/ESP32SvelteKit.cpp index 82cd1d27..a49bd6d4 100644 --- a/lib/framework/ESP32SvelteKit.cpp +++ b/lib/framework/ESP32SvelteKit.cpp @@ -161,7 +161,6 @@ void ESP32SvelteKit::begin() Serial.printf("Running Firmware Version: %s\n", APP_VERSION); // Start the services - ESP_LOGV("ESP32SvelteKit", "Starting services and registering REST endpoints"); _apStatus.begin(); _notificationEvents.begin(); _apSettingsService.begin(); @@ -169,6 +168,7 @@ void ESP32SvelteKit::begin() _featureService.begin(); _restartService.begin(); _systemStatus.begin(); + _wifiSettingsService.begin(); _wifiScanner.begin(); _wifiStatus.begin(); diff --git a/lib/framework/ESP32SvelteKit.h b/lib/framework/ESP32SvelteKit.h index d60f50b2..d62b1123 100644 --- a/lib/framework/ESP32SvelteKit.h +++ b/lib/framework/ESP32SvelteKit.h @@ -66,7 +66,7 @@ class ESP32SvelteKit { public: - ESP32SvelteKit(PsychicHttpServer *server, unsigned int numberEndpoints = 30); + ESP32SvelteKit(PsychicHttpServer *server, unsigned int numberEndpoints = 115); void begin(); diff --git a/lib/framework/FactoryResetService.cpp b/lib/framework/FactoryResetService.cpp index 93fb9d6d..f84d9137 100644 --- a/lib/framework/FactoryResetService.cpp +++ b/lib/framework/FactoryResetService.cpp @@ -20,7 +20,6 @@ FactoryResetService::FactoryResetService(PsychicHttpServer *server, FS *fs, Secu fs(fs), _securityManager(securityManager) { - ESP_LOGV("FactoryResetService", "Factory Reset Service initialized"); } void FactoryResetService::begin() diff --git a/lib/framework/FactoryResetService.h b/lib/framework/FactoryResetService.h index 03ce3a81..9299cb69 100644 --- a/lib/framework/FactoryResetService.h +++ b/lib/framework/FactoryResetService.h @@ -16,7 +16,6 @@ **/ #include -#include #include #include diff --git a/lib/framework/FeaturesService.cpp b/lib/framework/FeaturesService.cpp index eb19025b..b5b53d40 100644 --- a/lib/framework/FeaturesService.cpp +++ b/lib/framework/FeaturesService.cpp @@ -16,7 +16,6 @@ FeaturesService::FeaturesService(PsychicHttpServer *server) : _server(server) { - ESP_LOGV("FeaturesService", "Features Service initialized"); } void FeaturesService::begin() @@ -67,6 +66,8 @@ void FeaturesService::begin() root["analytics"] = false; #endif root["firmware_version"] = APP_VERSION; + root["firmware_name"] = APP_NAME; + root["firmware_built_target"] = BUILD_TARGET; // Iterate over user features for (auto &element : userFeatures) diff --git a/lib/framework/HttpEndpoint.h b/lib/framework/HttpEndpoint.h index d996542e..8e862a07 100644 --- a/lib/framework/HttpEndpoint.h +++ b/lib/framework/HttpEndpoint.h @@ -37,7 +37,6 @@ class HttpEndpoint size_t bufferSize = DEFAULT_BUFFER_SIZE) : _stateReader(stateReader), _stateUpdater(stateUpdater), _statefulService(statefulService), _server(server), _servicePath(servicePath), _securityManager(securityManager), _authenticationPredicate(authenticationPredicate), _bufferSize(bufferSize) { - ESP_LOGV("HttpEndpoint", "HttpEndpoint for %s initialized", _servicePath); } // register the web server on() endpoints diff --git a/lib/framework/MqttSettingsService.cpp b/lib/framework/MqttSettingsService.cpp index db5c2e10..66b2c69f 100644 --- a/lib/framework/MqttSettingsService.cpp +++ b/lib/framework/MqttSettingsService.cpp @@ -52,8 +52,6 @@ MqttSettingsService::MqttSettingsService(PsychicHttpServer *server, FS *fs, Secu addUpdateHandler([&](const String &originId) { onConfigUpdated(); }, false); - - ESP_LOGV("MqttSettingsService", "MQTT Settings Service initialized"); } MqttSettingsService::~MqttSettingsService() diff --git a/lib/framework/MqttStatus.cpp b/lib/framework/MqttStatus.cpp index 7d2247e5..a1884fa4 100644 --- a/lib/framework/MqttStatus.cpp +++ b/lib/framework/MqttStatus.cpp @@ -18,7 +18,6 @@ MqttStatus::MqttStatus(PsychicHttpServer *server, MqttSettingsService *mqttSetti _securityManager(securityManager), _mqttSettingsService(mqttSettingsService) { - ESP_LOGV("MqttStatus", "MQTT Status Service initialized"); } void MqttStatus::begin() diff --git a/lib/framework/NTPSettingsService.cpp b/lib/framework/NTPSettingsService.cpp index db112406..414ebbe9 100644 --- a/lib/framework/NTPSettingsService.cpp +++ b/lib/framework/NTPSettingsService.cpp @@ -22,8 +22,6 @@ NTPSettingsService::NTPSettingsService(PsychicHttpServer *server, FS *fs, Securi addUpdateHandler([&](const String &originId) { configureNTP(); }, false); - - ESP_LOGV("NTPSettingsService", "NTP Settings Service initialized"); } void NTPSettingsService::begin() diff --git a/lib/framework/NTPStatus.cpp b/lib/framework/NTPStatus.cpp index dffa1103..27a9a5c9 100644 --- a/lib/framework/NTPStatus.cpp +++ b/lib/framework/NTPStatus.cpp @@ -17,7 +17,6 @@ NTPStatus::NTPStatus(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("NTPStatus", "NTP Status Service initialized"); } void NTPStatus::begin() diff --git a/lib/framework/NotificationEvents.cpp b/lib/framework/NotificationEvents.cpp index cede962b..aa018f0b 100644 --- a/lib/framework/NotificationEvents.cpp +++ b/lib/framework/NotificationEvents.cpp @@ -17,7 +17,6 @@ NotificationEvents::NotificationEvents(PsychicHttpServer *server) : _server(server) { - ESP_LOGV("NotificationEvents", "Notification Events initialized"); } void NotificationEvents::begin() diff --git a/lib/framework/NotificationEvents.h b/lib/framework/NotificationEvents.h index 11d31902..d33193e9 100644 --- a/lib/framework/NotificationEvents.h +++ b/lib/framework/NotificationEvents.h @@ -14,7 +14,6 @@ **/ #include -#include #include #include diff --git a/lib/framework/RestartService.cpp b/lib/framework/RestartService.cpp index a3454a60..6a918148 100644 --- a/lib/framework/RestartService.cpp +++ b/lib/framework/RestartService.cpp @@ -17,7 +17,6 @@ RestartService::RestartService(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("RestartService", "Restart Service initialized"); } void RestartService::begin() diff --git a/lib/framework/RestartService.h b/lib/framework/RestartService.h index eb0e00ab..56f16840 100644 --- a/lib/framework/RestartService.h +++ b/lib/framework/RestartService.h @@ -16,7 +16,6 @@ **/ #include -#include #include #include diff --git a/lib/framework/SecuritySettingsService.cpp b/lib/framework/SecuritySettingsService.cpp index e1b8eff1..fb169e48 100644 --- a/lib/framework/SecuritySettingsService.cpp +++ b/lib/framework/SecuritySettingsService.cpp @@ -24,8 +24,6 @@ SecuritySettingsService::SecuritySettingsService(PsychicHttpServer *server, FS * addUpdateHandler([&](const String &originId) { configureJWTHandler(); }, false); - - ESP_LOGV("SecuritySettingsService", "Security Settings Service initialized"); } void SecuritySettingsService::begin() diff --git a/lib/framework/SleepService.cpp b/lib/framework/SleepService.cpp index 3c49dc68..1e3bc8e3 100644 --- a/lib/framework/SleepService.cpp +++ b/lib/framework/SleepService.cpp @@ -19,7 +19,6 @@ void (*SleepService::_callbackSleep)() = nullptr; SleepService::SleepService(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("SleepService", "Sleep Service initialized"); } void SleepService::begin() diff --git a/lib/framework/SystemStatus.cpp b/lib/framework/SystemStatus.cpp index 5924cabb..59ed8c25 100644 --- a/lib/framework/SystemStatus.cpp +++ b/lib/framework/SystemStatus.cpp @@ -34,11 +34,7 @@ #ifndef STRINGIZE #define STRINGIZE(s) #s #endif -#if TASMOTA_SDK -#define ARDUINO_VERSION_STR(major, minor, patch) "Tasmota Arduino v" STRINGIZE(major) "." STRINGIZE(minor) "." STRINGIZE(patch) -#else -#define ARDUINO_VERSION_STR(major, minor, patch) "ESP32 Arduino v" STRINGIZE(major) "." STRINGIZE(minor) "." STRINGIZE(patch) -#endif +#define ARDUINO_VERSION_STR(major, minor, patch) "v" STRINGIZE(major) "." STRINGIZE(minor) "." STRINGIZE(patch) #define ARDUINO_VERSION ARDUINO_VERSION_STR(ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH) #endif @@ -99,7 +95,6 @@ String verbosePrintResetReason(int reason) SystemStatus::SystemStatus(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("SystemStatus", "System Status Service initialized"); } void SystemStatus::begin() diff --git a/lib/framework/UploadFirmwareService.cpp b/lib/framework/UploadFirmwareService.cpp index 223ad877..4b1ea776 100644 --- a/lib/framework/UploadFirmwareService.cpp +++ b/lib/framework/UploadFirmwareService.cpp @@ -25,7 +25,6 @@ static FileType fileType = ft_none; UploadFirmwareService::UploadFirmwareService(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("UploadFirmwareService", "Upload Firmware Service initialized"); } void UploadFirmwareService::begin() diff --git a/lib/framework/WebSocketServer.h b/lib/framework/WebSocketServer.h index 97dc46df..0cc80ef6 100644 --- a/lib/framework/WebSocketServer.h +++ b/lib/framework/WebSocketServer.h @@ -49,8 +49,6 @@ class WebSocketServer [&](const String &originId) { transmitData(nullptr, originId); }, false); - - ESP_LOGV("WebSocketServer", "WebSocketServer for %s initialized", _webSocketPath.c_str()); } void begin() diff --git a/lib/framework/WiFiScanner.cpp b/lib/framework/WiFiScanner.cpp index b264f24d..39c25392 100644 --- a/lib/framework/WiFiScanner.cpp +++ b/lib/framework/WiFiScanner.cpp @@ -17,7 +17,6 @@ WiFiScanner::WiFiScanner(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("WiFiScanner", "WiFi Scanner initialized"); } void WiFiScanner::begin() diff --git a/lib/framework/WiFiScanner.h b/lib/framework/WiFiScanner.h index 3f9b8dd1..e963b67a 100644 --- a/lib/framework/WiFiScanner.h +++ b/lib/framework/WiFiScanner.h @@ -16,7 +16,6 @@ **/ #include -#include #include #include diff --git a/lib/framework/WiFiStatus.cpp b/lib/framework/WiFiStatus.cpp index e4fca561..92d6bedc 100644 --- a/lib/framework/WiFiStatus.cpp +++ b/lib/framework/WiFiStatus.cpp @@ -17,7 +17,6 @@ WiFiStatus::WiFiStatus(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server), _securityManager(securityManager) { - ESP_LOGV("WiFiStatus", "WiFi Status Service initialized"); } void WiFiStatus::begin() diff --git a/lib/framework/WiFiStatus.h b/lib/framework/WiFiStatus.h index c874840d..3b761c6d 100644 --- a/lib/framework/WiFiStatus.h +++ b/lib/framework/WiFiStatus.h @@ -16,7 +16,6 @@ **/ #include -#include #include #include diff --git a/platformio.ini b/platformio.ini index 55210a36..37f079ad 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,9 +22,9 @@ platform = espressif32 build_flags = ${factory_settings.build_flags} ${features.build_flags} - -D BUILD_TARGET="$PIOENV" + -D BUILD_TARGET=\"$PIOENV\" -D APP_NAME=\"ESP32-Sveltekit\" ; Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename - -D APP_VERSION=\"0.2.2\" ; semver compatible version string + -D APP_VERSION=\"0.3.0\" ; semver compatible version string ; Uncomment to receive log messages from the ESP Arduino Core -D CORE_DEBUG_LEVEL=5 ; Move all networking stuff to the protocol core 0 and leave business logic on application core 1 diff --git a/src/main.cpp b/src/main.cpp index 7c8be2f9..99b9a1e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,22 +35,16 @@ void setup() // start serial and filesystem Serial.begin(SERIAL_BAUD_RATE); - ESP_LOGI("main", "Starting Psychic HTTP Server"); - // start the framework and demo project esp32sveltekit.setMDNSAppName(APP_NAME); - ESP_LOGI("main", "Starting ESP32-SvelteKit"); // start ESP32-SvelteKit esp32sveltekit.begin(); - ESP_LOGI("main", "Starting LightStateService"); // load the initial light settings lightStateService.begin(); // start the light service lightMqttSettingsService.begin(); - - ESP_LOGI("main", "Ready"); } void loop()