Merge branch 'feat-sdcard-info' of https://github.com/jpirnay/crosspoint-reader into mybuild

This commit is contained in:
jpirnay
2026-03-17 21:27:10 +01:00
11 changed files with 228 additions and 9 deletions
+10 -8
View File
@@ -12,6 +12,7 @@
#include "CrossPointSettings.h"
#include "SettingsList.h"
#include "SystemStatus.h"
#include "WebDAVHandler.h"
#include "html/FilesPageHtml.generated.h"
#include "html/HomePageHtml.generated.h"
@@ -316,16 +317,17 @@ void CrossPointWebServer::handleNotFound() const {
}
void CrossPointWebServer::handleStatus() const {
// Get correct IP based on AP vs STA mode
const String ipAddr = apMode ? WiFi.softAPIP().toString() : WiFi.localIP().toString();
const auto status = SystemStatus::collect();
JsonDocument doc;
doc["version"] = CROSSPOINT_VERSION;
doc["ip"] = ipAddr;
doc["mode"] = apMode ? "AP" : "STA";
doc["rssi"] = apMode ? 0 : WiFi.RSSI();
doc["freeHeap"] = ESP.getFreeHeap();
doc["uptime"] = millis() / 1000;
doc["version"] = status.version;
doc["ip"] = status.ip;
doc["mode"] = status.wifiMode;
doc["rssi"] = status.rssi;
doc["freeHeap"] = status.freeHeapBytes;
doc["uptime"] = status.uptimeSeconds;
doc["sdTotal"] = status.sdTotalBytes;
doc["sdUsed"] = status.sdUsedBytes;
String json;
serializeJson(doc, json);
-1
View File
@@ -84,7 +84,6 @@ class CrossPointWebServer {
// 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
+15
View File
@@ -124,6 +124,10 @@
<span class="label">Free Memory</span>
<span class="value" id="free-heap"></span>
</div>
<div class="info-row">
<span class="label">SD Card</span>
<span class="value" id="sd-space"></span>
</div>
</div>
<div class="card">
@@ -132,6 +136,14 @@
</p>
</div>
<script>
function formatBytes(bytes) {
if (bytes == null) return 'N/A';
const units = ['B', 'KB', 'MB', 'GB'];
let val = bytes, i = 0;
while (val >= 1024 && i < units.length - 1) { val /= 1024; i++; }
return parseFloat(val.toFixed(2)).toLocaleString() + ' ' + units[i];
}
async function fetchStatus() {
try {
const response = await fetch('/api/status');
@@ -144,6 +156,9 @@
document.getElementById('free-heap').textContent = data.freeHeap
? data.freeHeap.toLocaleString() + ' bytes'
: 'N/A';
document.getElementById('sd-space').textContent = data.sdTotal
? formatBytes(data.sdUsed) + ' / ' + formatBytes(data.sdTotal)
: 'N/A';
} catch (error) {
console.error('Error fetching status:', error);
}