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 @@ -80,14 +80,12 @@ class WiFiClass : public NetworkInterface {
80
80
}
81
81
82
82
int status () {
83
- struct wifi_iface_status status = {0 };
84
-
85
- if (net_mgmt (NET_REQUEST_WIFI_IFACE_STATUS, netif, &status,
83
+ if (net_mgmt (NET_REQUEST_WIFI_IFACE_STATUS, netif, &sta_state,
86
84
sizeof (struct wifi_iface_status ))) {
87
85
return WL_NO_SHIELD;
88
86
}
89
87
90
- if (status .state >= WIFI_STATE_ASSOCIATED) {
88
+ if (sta_state .state >= WIFI_STATE_ASSOCIATED) {
91
89
return WL_CONNECTED;
92
90
} else {
93
91
return WL_DISCONNECTED;
@@ -99,12 +97,28 @@ class WiFiClass : public NetworkInterface {
99
97
// TODO: borrow code from mbed core for scan results handling
100
98
}
101
99
100
+ char * SSID () {
101
+ if (status () == WL_CONNECTED) {
102
+ return (char *)sta_state.ssid ;
103
+ }
104
+ return nullptr ;
105
+ }
106
+
107
+ int32_t RSSI () {
108
+ if (status () == WL_CONNECTED) {
109
+ return sta_state.rssi ;
110
+ }
111
+ return 0 ;
112
+ }
113
+
102
114
private:
103
115
struct net_if *sta_iface = nullptr ;
104
116
struct net_if *ap_iface = nullptr ;
105
117
106
118
struct wifi_connect_req_params ap_config;
107
119
struct wifi_connect_req_params sta_config;
120
+
121
+ struct wifi_iface_status sta_state = { 0 };
108
122
};
109
123
110
124
extern WiFiClass WiFi;
You can’t perform that action at this time.
0 commit comments