diff --git a/esp32/lib/ESP32-sveltekit/BatteryService.h b/esp32/lib/ESP32-sveltekit/BatteryService.h index 32ef0326..45c872b9 100644 --- a/esp32/lib/ESP32-sveltekit/BatteryService.h +++ b/esp32/lib/ESP32-sveltekit/BatteryService.h @@ -15,9 +15,9 @@ **/ #include -#include +#include #include -#include +#include #define ADC_VOLTAGE 0 #define ADC_CURRENT 1 diff --git a/esp32/lib/ESP32-sveltekit/MotionService.h b/esp32/lib/ESP32-sveltekit/MotionService.h index 31833602..9a3e5a2d 100644 --- a/esp32/lib/ESP32-sveltekit/MotionService.h +++ b/esp32/lib/ESP32-sveltekit/MotionService.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include diff --git a/esp32/lib/ESP32-sveltekit/Peripherals.h b/esp32/lib/ESP32-sveltekit/Peripherals.h index 00dae946..e7697fd9 100644 --- a/esp32/lib/ESP32-sveltekit/Peripherals.h +++ b/esp32/lib/ESP32-sveltekit/Peripherals.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/esp32/lib/ESP32-sveltekit/SettingValue.cpp b/esp32/lib/ESP32-sveltekit/SettingValue.cpp deleted file mode 100644 index 122def23..00000000 --- a/esp32/lib/ESP32-sveltekit/SettingValue.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** - * ESP32 SvelteKit - * - * A simple, secure and extensible framework for IoT projects for ESP32 platforms - * with responsive Sveltekit front-end built with TailwindCSS and DaisyUI. - * https://github.com/theelims/ESP32-sveltekit - * - * Copyright (C) 2018 - 2023 rjwats - * Copyright (C) 2023 theelims - * - * All Rights Reserved. This software may be modified and distributed under - * the terms of the LGPL v3 license. See the LICENSE file for details. - **/ - -#include - -namespace SettingValue { -const String PLATFORM = "esp32"; - -/** - * Returns a new string after replacing each instance of the pattern with a value generated by calling the provided - * callback. - */ -String replaceEach(String value, String pattern, String (*generateReplacement)()) { - while (true) { - int index = value.indexOf(pattern); - if (index == -1) { - break; - } - value = value.substring(0, index) + generateReplacement() + value.substring(index + pattern.length()); - } - return value; -} - -/** - * Generates a random number, encoded as a hex string. - */ -String getRandom() { return String(random(2147483647), HEX); } - -/** - * Uses the station's MAC address to create a unique id for each device. - */ -String getUniqueId() { - uint8_t mac[6]; - esp_read_mac(mac, ESP_MAC_WIFI_STA); - char macStr[13] = {0}; - sprintf(macStr, "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - return String(macStr); -} - -String format(String value) { - value = replaceEach(value, "#{random}", getRandom); - value.replace("#{unique_id}", getUniqueId()); - value.replace("#{platform}", PLATFORM); - return value; -} - -}; // end namespace SettingValue diff --git a/esp32/lib/ESP32-sveltekit/SettingValue.h b/esp32/lib/ESP32-sveltekit/SettingValue.h deleted file mode 100644 index 93dc23a2..00000000 --- a/esp32/lib/ESP32-sveltekit/SettingValue.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SettingValue_h -#define SettingValue_h - -/** - * ESP32 SvelteKit - * - * A simple, secure and extensible framework for IoT projects for ESP32 platforms - * with responsive Sveltekit front-end built with TailwindCSS and DaisyUI. - * https://github.com/theelims/ESP32-sveltekit - * - * Copyright (C) 2018 - 2023 rjwats - * Copyright (C) 2023 theelims - * - * All Rights Reserved. This software may be modified and distributed under - * the terms of the LGPL v3 license. See the LICENSE file for details. - **/ - -#include - -namespace SettingValue { -String format(String value); -}; - -#endif // end SettingValue diff --git a/esp32/lib/ESP32-sveltekit/ap_service.h b/esp32/lib/ESP32-sveltekit/ap_service.h index ab42f0fd..7038c798 100644 --- a/esp32/lib/ESP32-sveltekit/ap_service.h +++ b/esp32/lib/ESP32-sveltekit/ap_service.h @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include class APService : public StatefulService { diff --git a/esp32/lib/ESP32-sveltekit/settings/ap_settings.h b/esp32/lib/ESP32-sveltekit/settings/ap_settings.h index 8a98e3d6..9273671b 100644 --- a/esp32/lib/ESP32-sveltekit/settings/ap_settings.h +++ b/esp32/lib/ESP32-sveltekit/settings/ap_settings.h @@ -3,9 +3,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/esp32/lib/ESP32-sveltekit/settings/wifi_settings.h b/esp32/lib/ESP32-sveltekit/settings/wifi_settings.h index 2ea36615..338c2416 100644 --- a/esp32/lib/ESP32-sveltekit/settings/wifi_settings.h +++ b/esp32/lib/ESP32-sveltekit/settings/wifi_settings.h @@ -3,9 +3,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #ifndef FACTORY_WIFI_SSID diff --git a/esp32/lib/ESP32-sveltekit/IPUtils.h b/esp32/lib/ESP32-sveltekit/utils/ip_utils.h similarity index 100% rename from esp32/lib/ESP32-sveltekit/IPUtils.h rename to esp32/lib/ESP32-sveltekit/utils/ip_utils.h diff --git a/esp32/lib/ESP32-sveltekit/JsonUtils.h b/esp32/lib/ESP32-sveltekit/utils/json_utils.h similarity index 96% rename from esp32/lib/ESP32-sveltekit/JsonUtils.h rename to esp32/lib/ESP32-sveltekit/utils/json_utils.h index b26d847a..5298fdc1 100644 --- a/esp32/lib/ESP32-sveltekit/JsonUtils.h +++ b/esp32/lib/ESP32-sveltekit/utils/json_utils.h @@ -2,7 +2,7 @@ #define JsonUtils_h #include -#include +#include #include class JsonUtils { diff --git a/esp32/lib/ESP32-sveltekit/string_utilities.h b/esp32/lib/ESP32-sveltekit/utils/string_utils.h similarity index 100% rename from esp32/lib/ESP32-sveltekit/string_utilities.h rename to esp32/lib/ESP32-sveltekit/utils/string_utils.h diff --git a/esp32/lib/ESP32-sveltekit/timing.h b/esp32/lib/ESP32-sveltekit/utils/timing.h similarity index 77% rename from esp32/lib/ESP32-sveltekit/timing.h rename to esp32/lib/ESP32-sveltekit/utils/timing.h index c993b0fb..a773f2b6 100644 --- a/esp32/lib/ESP32-sveltekit/timing.h +++ b/esp32/lib/ESP32-sveltekit/utils/timing.h @@ -29,4 +29,14 @@ } \ } +#define CALLS_PER_SECOND(name) \ + static unsigned long name##_count = 0; \ + static unsigned long last_time = 0; \ + name##_count++; \ + if (millis() - last_time >= 1000) { \ + Serial.printf("%s: %lu calls per second\n", #name, name##_count); \ + name##_count = 0; \ + last_time = millis(); \ + } + #endif \ No newline at end of file diff --git a/esp32/lib/ESP32-sveltekit/wifi_service.h b/esp32/lib/ESP32-sveltekit/wifi_service.h index 5996e26e..431e70c8 100644 --- a/esp32/lib/ESP32-sveltekit/wifi_service.h +++ b/esp32/lib/ESP32-sveltekit/wifi_service.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include