Skip to content

Commit

Permalink
Merge pull request zivillian#7 from wib100/esp-infos
Browse files Browse the repository at this point in the history
Added Esp infos to status page
  • Loading branch information
zivillian authored Jan 3, 2023
2 parents 40c7070 + c53151d commit 12b7ec9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Binary file modified doc/img/status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions include/pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
void sendResponseTrailer(AsyncResponseStream *response);
void sendButton(AsyncResponseStream *response, const char *title, const char *action, const char *css = "");
void sendTableRow(AsyncResponseStream *response, const char *name, uint32_t value);
void sendTableRow(AsyncResponseStream *response, const char *name, String value);
void sendDebugForm(AsyncResponseStream *response, String slaveId, String reg, String function, String count);
const String ErrorName(Modbus::Error code);
const String WiFiQuality(int rssiValue);
#endif /* PAGES_H */
30 changes: 30 additions & 0 deletions src/pages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ void setupPages(AsyncWebServer *server, ModbusClientRTU *rtu, ModbusBridgeWiFi *
auto *response = request->beginResponseStream("text/html");
sendResponseHeader(response, "Status");
response->print("<table>");

// show ESP infos...
sendTableRow(response, "ESP Uptime (sec)", esp_timer_get_time() / 1000000);
sendTableRow(response, "ESP SSID", WiFi.SSID());
sendTableRow(response, "ESP RSSI", WiFi.RSSI());
sendTableRow(response, "ESP WiFi Quality", WiFiQuality(WiFi.RSSI()));
sendTableRow(response, "ESP MAC", WiFi.macAddress());
sendTableRow(response, "ESP IP", WiFi.localIP().toString() );

sendTableRow(response, "RTU Messages", rtu->getMessageCount());
sendTableRow(response, "RTU Pending Messages", rtu->pendingRequests());
sendTableRow(response, "RTU Errors", rtu->getErrorCount());
Expand Down Expand Up @@ -469,6 +478,14 @@ void sendButton(AsyncResponseStream *response, const char *title, const char *ac
"<p></p>", action, css, title);
}

void sendTableRow(AsyncResponseStream *response, const char *name, String value){
response->printf(
"<tr>"
"<td>%s:</td>"
"<td>%s</td>"
"</tr>", name, value.c_str());
}

void sendTableRow(AsyncResponseStream *response, const char *name, uint32_t value){
response->printf(
"<tr>"
Expand Down Expand Up @@ -564,3 +581,16 @@ const String ErrorName(Modbus::Error code)
default: return "undefined error";
}
}

// translate RSSI to quality string
const String WiFiQuality(int rssiValue)
{
switch (rssiValue)
{
case -30 ... 0: return "Amazing";
case -67 ... -31: return "Very Good";
case -70 ... -68: return "Okay";
case -80 ... -71: return "Not Good";
default: return "Unusable";
}
}

0 comments on commit 12b7ec9

Please sign in to comment.