Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
theelims committed Jan 16, 2024
1 parent 0f820dd commit d0c9bad
Show file tree
Hide file tree
Showing 36 changed files with 21 additions and 52 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions factory_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions interface/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion lib/framework/APSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/APStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ APStatus::APStatus(PsychicHttpServer *server, SecurityManager *securityManager,
_securityManager(securityManager),
_apSettingsService(apSettingsService)
{
ESP_LOGV("APStatus", "AP Status Service initialized");
}
void APStatus::begin()
{
Expand Down
1 change: 0 additions & 1 deletion lib/framework/APStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
**/

#include <WiFi.h>
#include <AsyncTCP.h>

#include <ArduinoJson.h>
#include <PsychicHttp.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/AnalyticsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
1 change: 0 additions & 1 deletion lib/framework/AuthenticationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
AuthenticationService::AuthenticationService(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server),
_securityManager(securityManager)
{
ESP_LOGV("AuthenticationService", "Authentication Service initialized");
}

void AuthenticationService::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/BatteryService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

BatteryService::BatteryService(NotificationEvents *notificationEvents) : _notificationEvents(notificationEvents)
{
ESP_LOGV("BatteryService", "Battery Service initialized");
}

void BatteryService::batteryEvent()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/DownloadFirmwareService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ DownloadFirmwareService::DownloadFirmwareService(PsychicHttpServer *server, Secu
_notificationEvents(notificationEvents)

{
ESP_LOGV("DownloadFirmwareService", "Download Firmware Service initialized");
}

void DownloadFirmwareService::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/DownloadFirmwareService.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <Arduino.h>

#include <WiFi.h>
#include <AsyncTCP.h>
#include <ArduinoJson.h>
#include <PsychicHttp.h>
#include <SecurityManager.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/framework/ESP32SvelteKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ 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();
_factoryResetService.begin();
_featureService.begin();
_restartService.begin();
_systemStatus.begin();
_wifiSettingsService.begin();
_wifiScanner.begin();
_wifiStatus.begin();

Expand Down
2 changes: 1 addition & 1 deletion lib/framework/ESP32SvelteKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
class ESP32SvelteKit
{
public:
ESP32SvelteKit(PsychicHttpServer *server, unsigned int numberEndpoints = 30);
ESP32SvelteKit(PsychicHttpServer *server, unsigned int numberEndpoints = 115);

void begin();

Expand Down
1 change: 0 additions & 1 deletion lib/framework/FactoryResetService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/FactoryResetService.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
**/

#include <WiFi.h>
#include <AsyncTCP.h>

#include <PsychicHttp.h>
#include <SecurityManager.h>
Expand Down
3 changes: 2 additions & 1 deletion lib/framework/FeaturesService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

FeaturesService::FeaturesService(PsychicHttpServer *server) : _server(server)
{
ESP_LOGV("FeaturesService", "Features Service initialized");
}

void FeaturesService::begin()
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion lib/framework/HttpEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions lib/framework/MqttSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/MqttStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ MqttStatus::MqttStatus(PsychicHttpServer *server, MqttSettingsService *mqttSetti
_securityManager(securityManager),
_mqttSettingsService(mqttSettingsService)
{
ESP_LOGV("MqttStatus", "MQTT Status Service initialized");
}

void MqttStatus::begin()
Expand Down
2 changes: 0 additions & 2 deletions lib/framework/NTPSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/NTPStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
NTPStatus::NTPStatus(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server),
_securityManager(securityManager)
{
ESP_LOGV("NTPStatus", "NTP Status Service initialized");
}

void NTPStatus::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/NotificationEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

NotificationEvents::NotificationEvents(PsychicHttpServer *server) : _server(server)
{
ESP_LOGV("NotificationEvents", "Notification Events initialized");
}

void NotificationEvents::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/NotificationEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
**/

#include <WiFi.h>
#include <AsyncTCP.h>

#include <ArduinoJson.h>
#include <PsychicHttp.h>
Expand Down
1 change: 0 additions & 1 deletion lib/framework/RestartService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
RestartService::RestartService(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server),
_securityManager(securityManager)
{
ESP_LOGV("RestartService", "Restart Service initialized");
}

void RestartService::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/RestartService.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
**/

#include <WiFi.h>
#include <AsyncTCP.h>

#include <PsychicHttp.h>
#include <SecurityManager.h>
Expand Down
2 changes: 0 additions & 2 deletions lib/framework/SecuritySettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/SleepService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 1 addition & 6 deletions lib/framework/SystemStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/UploadFirmwareService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions lib/framework/WebSocketServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/WiFiScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
WiFiScanner::WiFiScanner(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server),
_securityManager(securityManager)
{
ESP_LOGV("WiFiScanner", "WiFi Scanner initialized");
}

void WiFiScanner::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/WiFiScanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
**/

#include <WiFi.h>
#include <AsyncTCP.h>

#include <ArduinoJson.h>
#include <PsychicHttp.h>
Expand Down
1 change: 0 additions & 1 deletion lib/framework/WiFiStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
WiFiStatus::WiFiStatus(PsychicHttpServer *server, SecurityManager *securityManager) : _server(server),
_securityManager(securityManager)
{
ESP_LOGV("WiFiStatus", "WiFi Status Service initialized");
}

void WiFiStatus::begin()
Expand Down
1 change: 0 additions & 1 deletion lib/framework/WiFiStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
**/

#include <WiFi.h>
#include <AsyncTCP.h>

#include <ArduinoJson.h>
#include <PsychicHttp.h>
Expand Down
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d0c9bad

Please sign in to comment.