From 39dd28b456bf0d6b49c0a7cc3ab487b446342f8b Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 15 Jul 2021 13:33:45 +0200 Subject: [PATCH] Added wifi scan result to webpage --- components/espwifistack | 2 +- main/webserver.cpp | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/components/espwifistack b/components/espwifistack index 4d0efee..78e55db 160000 --- a/components/espwifistack +++ b/components/espwifistack @@ -1 +1 @@ -Subproject commit 4d0efeea96e93d77d885e998f2f77685592f3c24 +Subproject commit 78e55dbea012e317cbe387ef39c3608366f0536b diff --git a/main/webserver.cpp b/main/webserver.cpp index 0a54cfe..929fdcd 100644 --- a/main/webserver.cpp +++ b/main/webserver.cpp @@ -18,6 +18,7 @@ #include "feature_tsl.h" #include "feature_bmp.h" #include "mymqtt.h" +#include "espwifistack.h" namespace deckenlampe { httpd_handle_t httpdHandle; @@ -122,6 +123,50 @@ esp_err_t webserver_root_handler(httpd_req_t *req) body += "BMP085 not available at the moment
\n"; } + body += "
\n" + "

wifi scan result

\n"; + + if (const auto &scanResult = wifi_stack::get_scan_result()) { + body += "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; + + for (const auto &entry : scanResult->entries) { + body += fmt::format( + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n", + entry.ssid, + wifi_stack::toString(entry.authmode), + wifi_stack::toString(entry.pairwise_cipher), + wifi_stack::toString(entry.group_cipher), + entry.rssi, + entry.primary, + wifi_stack::toString(wifi_stack::mac_t{entry.bssid})); + } + + body += "\n" + "
ssidauthmodepairwise_ciphergroup_cipherrssichannelbssid
{}{}{}{}{}{}{}
\n"; + } else { + body += "no wifi scan result at the moment!
\n"; + } + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_type, req, "text/html") CALL_AND_EXIT_ON_ERROR(httpd_resp_send, req, body.data(), body.size())