Webserver addition and TactilityC symbols (#451)
This commit is contained in:
@@ -52,10 +52,10 @@ public:
|
||||
address(address),
|
||||
stackSize(stackSize),
|
||||
matchUri(matchUri),
|
||||
handlers(handlers)
|
||||
handlers(std::move(handlers))
|
||||
{}
|
||||
|
||||
void start();
|
||||
bool start();
|
||||
|
||||
void stop();
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace tt::service::webserver {
|
||||
|
||||
/**
|
||||
* @brief Asset version tracking for web server content synchronization
|
||||
*
|
||||
* Manages version.json files in both Data partition and SD card to ensure
|
||||
* proper synchronization and recovery of web assets.
|
||||
*/
|
||||
struct AssetVersion {
|
||||
uint32_t version; // Integer version number
|
||||
|
||||
AssetVersion() : version(0) {}
|
||||
explicit AssetVersion(uint32_t v) : version(v) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Load asset version from Data partition
|
||||
* @param[out] version The version structure to populate
|
||||
* @return true if version was loaded successfully
|
||||
*/
|
||||
bool loadDataVersion(AssetVersion& version);
|
||||
|
||||
/**
|
||||
* @brief Load asset version from SD card
|
||||
* @param[out] version The version structure to populate
|
||||
* @return true if version was loaded successfully
|
||||
*/
|
||||
bool loadSdVersion(AssetVersion& version);
|
||||
|
||||
/**
|
||||
* @brief Save asset version to Data partition
|
||||
* @param[in] version The version to save
|
||||
* @return true if version was saved successfully
|
||||
*/
|
||||
bool saveDataVersion(const AssetVersion& version);
|
||||
|
||||
/**
|
||||
* @brief Save asset version to SD card
|
||||
* @param[in] version The version to save
|
||||
* @return true if version was saved successfully
|
||||
*/
|
||||
bool saveSdVersion(const AssetVersion& version);
|
||||
|
||||
/**
|
||||
* @brief Check if Data partition has any web assets
|
||||
* @return true if Data partition contains web assets
|
||||
*/
|
||||
bool hasDataAssets();
|
||||
|
||||
/**
|
||||
* @brief Check if SD card has any web assets
|
||||
* @return true if SD card contains web assets backup
|
||||
*/
|
||||
bool hasSdAssets();
|
||||
|
||||
/**
|
||||
* @brief Synchronize assets between Data partition and SD card based on version
|
||||
*
|
||||
* Logic:
|
||||
* - If Data is empty: Copy from SD card (recovery mode)
|
||||
* - If SD version > Data version: Copy SD -> Data (firmware update)
|
||||
* - If Data version > SD version: Copy Data -> SD (backup customizations)
|
||||
*
|
||||
* @return true if sync completed successfully
|
||||
*/
|
||||
bool syncAssets();
|
||||
|
||||
} // namespace tt::service::webserver
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace tt::settings::webserver {
|
||||
|
||||
enum class WiFiMode : uint8_t {
|
||||
Station = 0, // Connect to existing WiFi network
|
||||
AccessPoint = 1 // Create own WiFi network
|
||||
};
|
||||
|
||||
struct WebServerSettings {
|
||||
// WiFi Configuration
|
||||
bool wifiEnabled = false; // Enable/disable WiFi entirely
|
||||
WiFiMode wifiMode = WiFiMode::Station; // Station or Access Point
|
||||
|
||||
// Access Point Mode Settings
|
||||
std::string apSsid{}; // Default: "Tactility-XXXX" (last 4 of MAC)
|
||||
std::string apPassword{}; // Password for WPA2 (8-63 chars)
|
||||
bool apOpenNetwork = false; // If true, create open network (no password)
|
||||
uint8_t apChannel = 1; // 1-13
|
||||
|
||||
// Web Server Settings
|
||||
bool webServerEnabled = false;
|
||||
uint16_t webServerPort = 80; // Default: 80
|
||||
|
||||
// Optional HTTP Basic Auth
|
||||
bool webServerAuthEnabled = false;
|
||||
std::string webServerUsername{};
|
||||
std::string webServerPassword{};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Load web server settings from persistent storage
|
||||
* @param[out] settings The settings structure to populate
|
||||
* @return true if settings were loaded successfully, false otherwise
|
||||
*/
|
||||
bool load(WebServerSettings& settings);
|
||||
|
||||
/**
|
||||
* @brief Get default web server settings
|
||||
* @return Default settings structure
|
||||
*/
|
||||
WebServerSettings getDefault();
|
||||
|
||||
/**
|
||||
* @brief Load settings or return defaults if loading fails
|
||||
* @return Settings structure (either loaded or default)
|
||||
*/
|
||||
WebServerSettings loadOrGetDefault();
|
||||
|
||||
/**
|
||||
* @brief Save web server settings to persistent storage
|
||||
* @param[in] settings The settings to save
|
||||
* @return true if settings were saved successfully, false otherwise
|
||||
*/
|
||||
bool save(const WebServerSettings& settings);
|
||||
|
||||
/**
|
||||
* @brief Generate default AP SSID based on device MAC address
|
||||
* @return SSID string in format "Tactility-XXXX"
|
||||
*/
|
||||
std::string generateDefaultApSsid();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user