📦 Moves utilities to own folder
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
**/
|
||||
|
||||
#include <event_socket.h>
|
||||
#include <JsonUtils.h>
|
||||
#include <utils/json_utils.h>
|
||||
#include <Peripherals.h>
|
||||
#include <timing.h>
|
||||
#include <utils/timing.h>
|
||||
|
||||
#define ADC_VOLTAGE 0
|
||||
#define ADC_CURRENT 1
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <event_socket.h>
|
||||
#include <Kinematics.h>
|
||||
#include <ServoController.h>
|
||||
#include <timing.h>
|
||||
#include <utils/timing.h>
|
||||
#include <MathUtils.h>
|
||||
|
||||
#include <gait/state.h>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <stateful_persistence.h>
|
||||
#include <stateful_service.h>
|
||||
#include <MathUtils.h>
|
||||
#include <timing.h>
|
||||
#include <utils/timing.h>
|
||||
#include <filesystem.h>
|
||||
#include <features.h>
|
||||
#include <settings/peripherals_settings.h>
|
||||
|
||||
@@ -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 <SettingValue.h>
|
||||
|
||||
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
|
||||
@@ -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 <Arduino.h>
|
||||
|
||||
namespace SettingValue {
|
||||
String format(String value);
|
||||
};
|
||||
|
||||
#endif // end SettingValue
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stateful_service_endpoint.h>
|
||||
#include <stateful_persistence.h>
|
||||
#include <settings/ap_settings.h>
|
||||
#include <timing.h>
|
||||
#include <utils/timing.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
class APService : public StatefulService<APSettings> {
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <WiFi.h>
|
||||
#include <IPAddress.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <JsonUtils.h>
|
||||
#include <string_utilities.h>
|
||||
#include <IPUtils.h>
|
||||
#include <utils/json_utils.h>
|
||||
#include <utils/string_utils.h>
|
||||
#include <utils/ip_utils.h>
|
||||
#include <state_result.h>
|
||||
|
||||
#include <DNSServer.h>
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <WiFi.h>
|
||||
#include <IPAddress.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <JsonUtils.h>
|
||||
#include <IPUtils.h>
|
||||
#include <string_utilities.h>
|
||||
#include <utils/json_utils.h>
|
||||
#include <utils/ip_utils.h>
|
||||
#include <utils/string_utils.h>
|
||||
#include <state_result.h>
|
||||
|
||||
#ifndef FACTORY_WIFI_SSID
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#define JsonUtils_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <IPUtils.h>
|
||||
#include <utils/ip_utils.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class JsonUtils {
|
||||
@@ -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
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <ESPmDNS.h>
|
||||
|
||||
#include <filesystem.h>
|
||||
#include <timing.h>
|
||||
#include <utils/timing.h>
|
||||
#include <stateful_service.h>
|
||||
#include <stateful_persistence.h>
|
||||
#include <stateful_service_endpoint.h>
|
||||
|
||||
Reference in New Issue
Block a user