33
33
34
34
extern " C" {
35
35
#include < src/utils/common.h>
36
+ #include < supp_events.h>
36
37
#include < wpa_supplicant/wpa_supplicant_i.h>
37
38
}
38
39
@@ -173,6 +174,7 @@ class WiFiManager
173
174
static constexpr uint32_t kConnectionRecoveryMaxIntervalMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAXIMUM_INTERVAL;
174
175
static constexpr uint32_t kConnectionRecoveryJitterMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_JITTER;
175
176
static constexpr uint32_t kConnectionRecoveryMaxRetries = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAX_RETRIES_NUMBER;
177
+ static constexpr uint32_t kSupplicantReadyTimeoutMs = 500 ;
176
178
177
179
CHIP_ERROR Init ();
178
180
CHIP_ERROR Scan (const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback,
@@ -200,9 +202,13 @@ class WiFiManager
200
202
201
203
constexpr static uint32_t kIPv6ManagementEvents = NET_EVENT_IPV6_ADDR_ADD | NET_EVENT_IPV6_ADDR_DEL;
202
204
205
+ constexpr static uint32_t kSupplicantEvents = NET_EVENT_WPA_SUPP_READY | NET_EVENT_WPA_SUPP_CMD_NOT_READY |
206
+ NET_EVENT_WPA_SUPP_IFACE_ADDED | NET_EVENT_WPA_SUPP_IFACE_REMOVED;
207
+
203
208
// Event handling
204
209
static void WifiMgmtEventHandler (net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
205
210
static void IPv6MgmtEventHandler (net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
211
+ static void WiFiSupplicantEventHandler (net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
206
212
static void ScanResultHandler (Platform::UniquePtr<uint8_t > data);
207
213
static void ScanDoneHandler (Platform::UniquePtr<uint8_t > data);
208
214
static void ConnectHandler (Platform::UniquePtr<uint8_t > data);
@@ -221,16 +227,21 @@ class WiFiManager
221
227
// To avoid frequent recovery attempts when the signal to an access point is poor quality
222
228
// The connection recovery interval will be cleared after the defined delay in kConnectionRecoveryDelayToReset.
223
229
static void Recover (System::Layer * layer, void * param);
230
+ static void SupplicantInitTimeout (System::Layer * layer, void * param);
224
231
void ResetRecoveryTime ();
225
232
System::Clock::Milliseconds32 CalculateNextRecoveryTime ();
226
233
234
+ bool mSupplicantReady { false };
235
+ bool mInterfaceUp { false };
236
+ bool mSupplicantInitTimeoutElapsed { false };
227
237
net_if * mNetIf { nullptr };
228
238
ConnectionParams mWiFiParams {};
229
239
ConnectionHandling mHandling ;
230
240
wifi_iface_state mWiFiState ;
231
241
wifi_iface_state mCachedWiFiState ;
232
242
net_mgmt_event_callback mWiFiMgmtClbk {};
233
243
net_mgmt_event_callback mIPv6MgmtClbk {};
244
+ net_mgmt_event_callback mSuppMgmtClbk {};
234
245
ScanResultCallback mScanResultCallback { nullptr };
235
246
ScanDoneCallback mScanDoneCallback { nullptr };
236
247
WiFiNetwork mWantedNetwork {};
0 commit comments