@@ -92,7 +92,19 @@ bool ConnectivityManagerImpl::_IsWiFiStationProvisioned(void)
92
92
93
93
CHIP_ERROR ConnectivityManagerImpl::_SetWiFiAPMode (WiFiAPMode val)
94
94
{
95
- return CHIP_ERROR_NOT_IMPLEMENTED;
95
+ CHIP_ERROR err = CHIP_NO_ERROR;
96
+
97
+ VerifyOrExit (val != kWiFiAPMode_NotSupported , err = CHIP_ERROR_INVALID_ARGUMENT);
98
+
99
+ if (mWiFiAPMode != val)
100
+ {
101
+ ChipLogDetail (DeviceLayer, " WiFi AP mode change: %s -> %s" , WiFiAPModeToStr (mWiFiAPMode ), WiFiAPModeToStr (val));
102
+ }
103
+
104
+ mWiFiAPMode = val;
105
+
106
+ exit :
107
+ return err;
96
108
}
97
109
98
110
// ==================== ConnectivityManager Platform Internal Methods ====================
@@ -252,10 +264,10 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected()
252
264
ChipLogProgress (DeviceLayer, " Event - StationConnected" );
253
265
}
254
266
255
- // Update IPv4 address
267
+ // Update IP address
256
268
SocketAddress address;
257
269
auto error = mWifiInterface ->get_ip_address (&address);
258
- if (error)
270
+ if (error != NSAPI_ERROR_OK )
259
271
{
260
272
if (mIp4Address != IPAddress::Any)
261
273
{
@@ -268,26 +280,7 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected()
268
280
ReturnErrorOnFailure (PlatformMgr ().PostEvent (&event));
269
281
ChipLogError (DeviceLayer, " Unnexpected loss of Ip4 address" );
270
282
}
271
- }
272
- else
273
- {
274
- IPAddress addr;
275
- if (IPAddress::FromString (address.get_ip_address (), addr) && addr != mIp4Address )
276
- {
277
- mIp4Address = addr;
278
- ChipDeviceEvent event;
279
- event.Type = DeviceEventType::kInternetConnectivityChange ;
280
- event.InternetConnectivityChange .IPv4 = kConnectivity_Established ;
281
- event.InternetConnectivityChange .IPv6 = kConnectivity_NoChange ;
282
- ReturnErrorOnFailure (PlatformMgr ().PostEvent (&event));
283
- ChipLogProgress (DeviceLayer, " New Ip4 address set: %s" , address.get_ip_address ());
284
- }
285
- }
286
283
287
- // Update IPv6 address
288
- error = mWifiInterface ->get_ipv6_link_local_address (&address);
289
- if (error)
290
- {
291
284
if (mIp6Address != IPAddress::Any)
292
285
{
293
286
// Unnexpected change, forward to the application
@@ -303,17 +296,34 @@ CHIP_ERROR ConnectivityManagerImpl::OnStationConnected()
303
296
else
304
297
{
305
298
IPAddress addr;
306
- if (IPAddress::FromString ( address.get_ip_address (), addr) && addr != mIp6Address )
299
+ if (address.get_ip_version () == NSAPI_IPv4 )
307
300
{
308
- mIp6Address = addr;
309
- ChipDeviceEvent event;
310
- event.Type = DeviceEventType::kInternetConnectivityChange ;
311
- event.InternetConnectivityChange .IPv4 = kConnectivity_NoChange ;
312
- event.InternetConnectivityChange .IPv6 = kConnectivity_Established ;
313
- ReturnErrorOnFailure (PlatformMgr ().PostEvent (&event));
314
- ChipLogProgress (DeviceLayer, " New Ip6 address set %s" , address.get_ip_address ());
301
+ if (IPAddress::FromString (address.get_ip_address (), addr) && addr != mIp4Address )
302
+ {
303
+ mIp4Address = addr;
304
+ ChipDeviceEvent event;
305
+ event.Type = DeviceEventType::kInternetConnectivityChange ;
306
+ event.InternetConnectivityChange .IPv4 = kConnectivity_Established ;
307
+ event.InternetConnectivityChange .IPv6 = kConnectivity_NoChange ;
308
+ ReturnErrorOnFailure (PlatformMgr ().PostEvent (&event));
309
+ ChipLogProgress (DeviceLayer, " New Ip4 address set: %s" , address.get_ip_address ());
310
+ }
311
+ }
312
+ else
313
+ {
314
+ if (IPAddress::FromString (address.get_ip_address (), addr) && addr != mIp6Address )
315
+ {
316
+ mIp6Address = addr;
317
+ ChipDeviceEvent event;
318
+ event.Type = DeviceEventType::kInternetConnectivityChange ;
319
+ event.InternetConnectivityChange .IPv4 = kConnectivity_NoChange ;
320
+ event.InternetConnectivityChange .IPv6 = kConnectivity_Established ;
321
+ ReturnErrorOnFailure (PlatformMgr ().PostEvent (&event));
322
+ ChipLogProgress (DeviceLayer, " New Ip6 address set %s" , address.get_ip_address ());
323
+ }
315
324
}
316
325
}
326
+
317
327
return CHIP_NO_ERROR;
318
328
}
319
329
0 commit comments