mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 23:57:39 +03:00
Add a new Settings page to the crosspoint.local web interface that allows viewing and editing all device settings via the hotspot. Settings page that auto-generates form from settings metadata New settings added to SettingsList.h automatically appear in both the device UI and web UI - Supports all setting types: toggle, enum, value (range), and string - Settings are saved immediately and persist to SD card API endpoints: - GET /settings - Settings page - GET /api/settings - Returns all settings with metadata as JSON - POST /api/settings - Updates settings (accepts JSON key-value pairs)
62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <WebServer.h>
|
|
|
|
#include <vector>
|
|
|
|
// Structure to hold file information
|
|
struct FileInfo {
|
|
String name;
|
|
size_t size;
|
|
bool isEpub;
|
|
bool isDirectory;
|
|
};
|
|
|
|
class CrossPointWebServer {
|
|
public:
|
|
CrossPointWebServer();
|
|
~CrossPointWebServer();
|
|
|
|
// Start the web server (call after WiFi is connected)
|
|
void begin();
|
|
|
|
// Stop the web server
|
|
void stop();
|
|
|
|
// Call this periodically to handle client requests
|
|
void handleClient() const;
|
|
|
|
// Check if server is running
|
|
bool isRunning() const { return running; }
|
|
|
|
// Get the port number
|
|
uint16_t getPort() const { return port; }
|
|
|
|
private:
|
|
std::unique_ptr<WebServer> server = nullptr;
|
|
bool running = false;
|
|
bool apMode = false; // true when running in AP mode, false for STA mode
|
|
uint16_t port = 80;
|
|
|
|
// File scanning
|
|
void scanFiles(const char* path, const std::function<void(FileInfo)>& callback) const;
|
|
String formatFileSize(size_t bytes) const;
|
|
bool isEpubFile(const String& filename) const;
|
|
|
|
// Request handlers
|
|
void handleRoot() const;
|
|
void handleNotFound() const;
|
|
void handleStatus() const;
|
|
void handleFileList() const;
|
|
void handleFileListData() const;
|
|
void handleUpload() const;
|
|
void handleUploadPost() const;
|
|
void handleCreateFolder() const;
|
|
void handleDelete() const;
|
|
|
|
// Settings handlers
|
|
void handleSettingsPage() const;
|
|
void handleGetSettings() const;
|
|
void handlePostSettings();
|
|
};
|