Skip to content

Commit c6ff6aa

Browse files
committed
Show the station SSID on the INFO page, #7
1 parent 7242a44 commit c6ff6aa

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

components/web_server/www/html/js/info.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
---
33
var versionCell = getE("version"),
44
ipGateway = getE("ipGatewayAddress"),
5+
ssid,
56
ipAddress,
67
dns,
78
connection = getE("connection"),
@@ -27,6 +28,7 @@ function getData() {
2728
return
2829
}
2930
// console.log(res.clients.length)
31+
ssid = res.ssid;
3032
ipAddress = res.ipAddress;
3133
dns = res.dns;
3234
ap_rss = res.rss;
@@ -130,7 +132,7 @@ function ap_connection() {
130132

131133
var tr = '<tr><td>Wifi status</td>';
132134
tr += '<td><div>' + svgImg + '</div><div><span style="background:linear-gradient(135deg, ' + getColor(signalPercent) + ' ' + signalPercent + '%,rgba(0,0,0,0.15) ' + signalPercent + '%)"></span><span style="color:' + getColor(signalPercent, true) + '">' + signalPercent + '</span></div></td>';
133-
tr += '<td class=' + (state ? "green" : "red") + '><b>' + (state ? 'Connected' : (wifiAuthFail ? "wifi Auth Fail" : 'Disconnected')) + '<b></td><tr>';
135+
tr += '<td class=' + (state ? "green" : "red") + '><b>' + (state ? ssid : (wifiAuthFail ? "wifi Auth Fail" : 'Disconnected')) + '<b></td><tr>';
134136
connection.innerHTML = tr;
135137

136138
tr = '<tr><td>{% t info.card-1.table.C %}</td><td><b>' + ipAddress + '</b></td><td>' + dns + '</td></tr>';
7 Bytes
Binary file not shown.

components/wifi_handler/wifi_handler.c

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ char* IRAM_ATTR wifi_info_handler(void)
8686
tcpip_adapter_sta_list_t adapter_sta_list;
8787
tcpip_adapter_ip_info_t ip_info;
8888
tcpip_adapter_dns_info_t dns_info;
89+
char * ssid = "";
8990
int8_t rssi = 0;
9091
char gateway_address[32];
9192
char ip_address[32];
@@ -96,6 +97,7 @@ char* IRAM_ATTR wifi_info_handler(void)
9697
memset(&ip_info, 0, sizeof(ip_info));
9798
if (esp_wifi_sta_get_ap_info(&ap_info) == ESP_OK)
9899
{
100+
ssid = (char *)ap_info.ssid;
99101
rssi = ap_info.rssi;
100102
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
101103
ESP_ERROR_CHECK(tcpip_adapter_get_dns_info(TCPIP_ADAPTER_IF_STA, ESP_NETIF_DNS_MAIN, &dns_info));
@@ -106,6 +108,7 @@ char* IRAM_ATTR wifi_info_handler(void)
106108
}
107109
else
108110
{
111+
ssid = "";
109112
rssi = 0;
110113
strcpy(gateway_address, "");
111114
strcpy(ip_address, "");
@@ -118,6 +121,7 @@ char* IRAM_ATTR wifi_info_handler(void)
118121
ESP_ERROR_CHECK(tcpip_adapter_get_sta_list(&wifi_sta_list, &adapter_sta_list));
119122

120123
cJSON *root = cJSON_CreateObject();
124+
cJSON_AddStringToObject(root, "ssid", ssid);
121125
cJSON_AddStringToObject(root, "gatewayAddress", gateway_address);
122126
cJSON_AddStringToObject(root, "ipAddress", ip_address);
123127
cJSON_AddStringToObject(root, "dns", (has_static_ip || IsCustomDnsEnable) ? customDNSip : dns);

0 commit comments

Comments
 (0)