Expose timesync error in MQTT and web UI
BACKWARD-INCOMPATIBLE: MQTT faults payload now always includes err_last/err_last_text and err_last_age (schema change).
This commit is contained in:
@@ -59,6 +59,21 @@ static bool auth_required() {
|
||||
return g_is_ap ? WEB_AUTH_REQUIRE_AP : WEB_AUTH_REQUIRE_STA;
|
||||
}
|
||||
|
||||
static const char *fault_text(FaultType fault) {
|
||||
switch (fault) {
|
||||
case FaultType::MeterRead:
|
||||
return "meter";
|
||||
case FaultType::Decode:
|
||||
return "decode";
|
||||
case FaultType::LoraTx:
|
||||
return "loratx";
|
||||
case FaultType::TimeSync:
|
||||
return "timesync";
|
||||
default:
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
static bool ensure_auth() {
|
||||
if (!auth_required()) {
|
||||
return true;
|
||||
@@ -97,6 +112,7 @@ static String format_faults(uint8_t idx) {
|
||||
s += String(g_sender_faults[idx].lora_tx_fail);
|
||||
s += " last:";
|
||||
s += String(static_cast<uint8_t>(g_sender_last_errors[idx]));
|
||||
s += " (" + String(fault_text(g_sender_last_errors[idx])) + ")";
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -335,6 +351,7 @@ static String render_sender_block(const SenderStatus &status) {
|
||||
if (status.has_data) {
|
||||
s += " err_tx:" + String(status.last_data.err_lora_tx);
|
||||
s += " err_last:" + String(static_cast<uint8_t>(status.last_data.last_error));
|
||||
s += " (" + String(fault_text(status.last_data.last_error)) + ")";
|
||||
}
|
||||
s += format_faults(idx);
|
||||
s += "<br>";
|
||||
@@ -588,7 +605,7 @@ static void handle_sender() {
|
||||
html += "<td>" + String(d.link_rssi_dbm) + "</td>";
|
||||
html += "<td>" + String(d.link_snr_db, 1) + "</td>";
|
||||
html += "<td>" + String(d.err_lora_tx) + "</td>";
|
||||
html += "<td>" + String(static_cast<uint8_t>(d.last_error)) + "</td>";
|
||||
html += "<td>" + String(static_cast<uint8_t>(d.last_error)) + " (" + String(fault_text(d.last_error)) + ")</td>";
|
||||
html += "</tr>";
|
||||
}
|
||||
html += "</table>";
|
||||
|
||||
Reference in New Issue
Block a user