@@ -346,16 +346,16 @@ sl_status_t ScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_res
346
346
347
347
sl_status_t InitiateScan ()
348
348
{
349
- sl_status_t status = SL_STATUS_OK;
350
-
351
- sl_wifi_ssid_t ssid = { 0 };
352
-
349
+ sl_status_t status = SL_STATUS_OK;
350
+ sl_wifi_ssid_t ssid = { 0 };
353
351
sl_wifi_scan_configuration_t wifi_scan_configuration = default_wifi_scan_configuration;
354
352
355
- ssid.length = wfx_rsi.sec .ssid_length ;
353
+ ssid.length = wfx_rsi.credentials .ssidLength ;
354
+
355
+ chip::ByteSpan requestedSsidSpan (wfx_rsi.credentials .ssid , wfx_rsi.credentials .ssidLength );
356
+ chip::MutableByteSpan ssidSpan (ssid.value , ssid.length );
357
+ chip::CopySpanToMutableSpan (requestedSsidSpan, ssidSpan);
356
358
357
- // TODO: workaround because the string management with the null termination is flawed
358
- chip::Platform::CopyString ((char *) &ssid.value [0 ], ssid.length + 1 , wfx_rsi.sec .ssid );
359
359
sl_wifi_set_scan_callback (ScanCallback, NULL );
360
360
361
361
osSemaphoreAcquire (sScanInProgressSemaphore , osWaitForever);
@@ -394,19 +394,20 @@ sl_status_t SetWifiConfigurations()
394
394
VerifyOrReturnError (status == SL_STATUS_OK, status);
395
395
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
396
396
397
- if (wfx_rsi.sec . passkey_length != 0 )
397
+ if (wfx_rsi.credentials . passkeyLength != 0 )
398
398
{
399
- status = sl_net_set_credential (SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID, SL_NET_WIFI_PSK, &wfx_rsi.sec .passkey [0 ],
400
- wfx_rsi.sec . passkey_length );
399
+ status = sl_net_set_credential (SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID, SL_NET_WIFI_PSK, &wfx_rsi.credentials .passkey [0 ],
400
+ wfx_rsi.credentials . passkeyLength );
401
401
VerifyOrReturnError (status == SL_STATUS_OK, status,
402
402
ChipLogError (DeviceLayer, " sl_net_set_credential failed: 0x%lx" , status));
403
403
}
404
404
405
405
sl_net_wifi_client_profile_t profile = {
406
406
.config = {
407
407
.ssid = {
408
+ .value = { 0 },
408
409
// static cast because the types dont match
409
- .length = static_cast <uint8_t >(wfx_rsi.sec . ssid_length ),
410
+ .length = static_cast <uint8_t >(wfx_rsi.credentials . ssidLength ),
410
411
},
411
412
.channel = {
412
413
.channel = SL_WIFI_AUTO_CHANNEL,
@@ -427,8 +428,10 @@ sl_status_t SetWifiConfigurations()
427
428
.ip = {{{0 }}},
428
429
}
429
430
};
430
- // TODO: memcpy for now since the types dont match
431
- memcpy ((char *) &profile.config .ssid .value , wfx_rsi.sec .ssid , wfx_rsi.sec .ssid_length );
431
+
432
+ chip::MutableByteSpan output (profile.config .ssid .value , WFX_MAX_SSID_LENGTH);
433
+ chip::ByteSpan input (wfx_rsi.credentials .ssid , wfx_rsi.credentials .ssidLength );
434
+ chip::CopySpanToMutableSpan (input, output);
432
435
433
436
status = sl_net_set_profile (SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID, &profile);
434
437
VerifyOrReturnError (status == SL_STATUS_OK, status, ChipLogError (DeviceLayer, " sl_net_set_profile failed: 0x%lx" , status));
@@ -460,7 +463,7 @@ sl_status_t JoinCallback(sl_wifi_event_t event, char * result, uint32_t resultLe
460
463
status = *reinterpret_cast <sl_status_t *>(result);
461
464
ChipLogError (DeviceLayer, " JoinCallback: failed: 0x%lx" , status);
462
465
wfx_rsi.dev_state .Clear (WifiState::kStationConnected );
463
- wfx_retry_connection (++wfx_rsi. join_retries );
466
+ ScheduleConnectionAttempt ( );
464
467
}
465
468
466
469
return status;
@@ -504,9 +507,7 @@ sl_status_t JoinWifiNetwork(void)
504
507
ChipLogError (DeviceLayer, " sl_wifi_connect failed: 0x%lx" , static_cast <uint32_t >(status));
505
508
506
509
wfx_rsi.dev_state .Clear (WifiState::kStationConnecting ).Clear (WifiState::kStationConnected );
507
-
508
- ChipLogProgress (DeviceLayer, " Connection retry attempt %d" , wfx_rsi.join_retries );
509
- wfx_retry_connection (++wfx_rsi.join_retries );
510
+ ScheduleConnectionAttempt ();
510
511
511
512
return status;
512
513
}
@@ -522,12 +523,11 @@ CHIP_ERROR GetAccessPointInfo(wfx_wifi_scan_result_t & info)
522
523
{
523
524
// TODO: Convert this to a int8
524
525
int32_t rssi = 0 ;
525
- info.security = wfx_rsi.sec .security ;
526
+ info.security = wfx_rsi.credentials .security ;
526
527
info.chan = wfx_rsi.ap_chan ;
527
528
528
529
chip::MutableByteSpan output (info.ssid , WFX_MAX_SSID_LENGTH);
529
- // Cast is a workaround until the wfx_rsi structure is refactored
530
- chip::ByteSpan ssid (reinterpret_cast <uint8_t *>(wfx_rsi.sec .ssid ), wfx_rsi.sec .ssid_length );
530
+ chip::ByteSpan ssid (wfx_rsi.credentials .ssid , wfx_rsi.credentials .ssidLength );
531
531
chip::CopySpanToMutableSpan (ssid, output);
532
532
info.ssid_length = output.size ();
533
533
@@ -793,7 +793,7 @@ void MatterWifiTask(void * arg)
793
793
VerifyOrReturn (status == SL_STATUS_OK,
794
794
ChipLogError (DeviceLayer, " MatterWifiTask: sl_wifi_siwx917_init failed: 0x%lx" , static_cast <uint32_t >(status)));
795
795
796
- sl_matter_wifi_task_started ();
796
+ NotifyWifiTaskInitialized ();
797
797
798
798
ChipLogDetail (DeviceLayer, " MatterWifiTask: starting event loop" );
799
799
for (;;)
0 commit comments