File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -75,14 +75,12 @@ class WiFiClass: public NetworkInterface
7575 }
7676
7777 int status () {
78- struct wifi_iface_status status = { 0 };
79-
80- if (net_mgmt (NET_REQUEST_WIFI_IFACE_STATUS, netif, &status,
78+ if (net_mgmt (NET_REQUEST_WIFI_IFACE_STATUS, netif, &sta_state,
8179 sizeof (struct wifi_iface_status ))) {
8280 return WL_NO_SHIELD;
8381 }
8482
85- if (status .state >= WIFI_STATE_ASSOCIATED) {
83+ if (sta_state .state >= WIFI_STATE_ASSOCIATED) {
8684 return WL_CONNECTED;
8785 } else {
8886 return WL_DISCONNECTED;
@@ -94,12 +92,28 @@ class WiFiClass: public NetworkInterface
9492 // TODO: borrow code from mbed core for scan results handling
9593 }
9694
95+ char * SSID () {
96+ if (status () == WL_CONNECTED) {
97+ return (char *)sta_state.ssid ;
98+ }
99+ return nullptr ;
100+ }
101+
102+ int32_t RSSI () {
103+ if (status () == WL_CONNECTED) {
104+ return sta_state.rssi ;
105+ }
106+ return 0 ;
107+ }
108+
97109private:
98110 struct net_if *sta_iface = nullptr ;
99111 struct net_if *ap_iface = nullptr ;
100112
101113 struct wifi_connect_req_params ap_config;
102114 struct wifi_connect_req_params sta_config;
115+
116+ struct wifi_iface_status sta_state = { 0 };
103117};
104118
105119extern WiFiClass WiFi;
You can’t perform that action at this time.
0 commit comments