feat(network): add device serial number to web UI (#2506)
This commit is contained in:
@@ -6,9 +6,12 @@
|
|||||||
#include <HalStorage.h>
|
#include <HalStorage.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
#include <esp_efuse.h>
|
||||||
|
#include <esp_efuse_table.h>
|
||||||
#include <esp_task_wdt.h>
|
#include <esp_task_wdt.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cctype>
|
||||||
|
|
||||||
#include "CrossPointSettings.h"
|
#include "CrossPointSettings.h"
|
||||||
#include "FontInstaller.h"
|
#include "FontInstaller.h"
|
||||||
@@ -368,9 +371,27 @@ void CrossPointWebServer::handleStatus() const {
|
|||||||
doc["uptime"] = millis() / 1000;
|
doc["uptime"] = millis() / 1000;
|
||||||
doc["device"] = gpio.deviceIsX3() ? "X3" : "X4";
|
doc["device"] = gpio.deviceIsX3() ? "X3" : "X4";
|
||||||
|
|
||||||
String json;
|
char snBuf[33] = {0};
|
||||||
serializeJson(doc, json);
|
bool valid = false;
|
||||||
server->send(200, "application/json", json);
|
if (esp_efuse_read_field_blob(ESP_EFUSE_USER_DATA, snBuf, 256) == ESP_OK) {
|
||||||
|
valid = snBuf[0] != '\0' && snBuf[0] != (char)0xFF;
|
||||||
|
for (int i = 0; i < 32 && snBuf[i] != '\0'; i++) {
|
||||||
|
if (!std::isprint(static_cast<unsigned char>(snBuf[i]))) {
|
||||||
|
valid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valid) {
|
||||||
|
doc["serial"] = snBuf;
|
||||||
|
} else {
|
||||||
|
doc["serial"] = "Not found";
|
||||||
|
}
|
||||||
|
|
||||||
|
String response;
|
||||||
|
serializeJson(doc, response);
|
||||||
|
server->send(200, "application/json", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossPointWebServer::scanFiles(const char* path, const std::function<void(FileInfo)>& callback) const {
|
void CrossPointWebServer::scanFiles(const char* path, const std::function<void(FileInfo)>& callback) const {
|
||||||
|
|||||||
@@ -109,6 +109,10 @@
|
|||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2>Device Status</h2>
|
<h2>Device Status</h2>
|
||||||
|
<div class="info-row">
|
||||||
|
<span class="label">Serial #</span>
|
||||||
|
<span class="value" id="serial"></span>
|
||||||
|
</div>
|
||||||
<div class="info-row">
|
<div class="info-row">
|
||||||
<span class="label">Version</span>
|
<span class="label">Version</span>
|
||||||
<span class="value" id="version"></span>
|
<span class="value" id="version"></span>
|
||||||
@@ -141,6 +145,7 @@
|
|||||||
}
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
document.getElementById('version').textContent = data.version || 'N/A';
|
document.getElementById('version').textContent = data.version || 'N/A';
|
||||||
|
document.getElementById('serial').textContent = data.serial;
|
||||||
document.getElementById('ip-address').textContent = data.ip || 'N/A';
|
document.getElementById('ip-address').textContent = data.ip || 'N/A';
|
||||||
document.getElementById('free-heap').textContent = data.freeHeap
|
document.getElementById('free-heap').textContent = data.freeHeap
|
||||||
? data.freeHeap.toLocaleString() + ' bytes'
|
? data.freeHeap.toLocaleString() + ' bytes'
|
||||||
|
|||||||
Reference in New Issue
Block a user