Skip to content

Commit 7619c0b

Browse files
[Silabs] Added BSSID and SSID in the ap_info structure for wf200 (project-chip#41778)
* Added BSSID and SSID in the ap_info structure for wf200 * Used span for bssid * Updated the logic so that bssid and ssid will be assigned only in success state * Restyled by clang-format * Updated macSpan and added TODO comment * Restyled by clang-format --------- Co-authored-by: Restyled.io <[email protected]>
1 parent bab3aa0 commit 7619c0b

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/platform/silabs/wifi/wf200/WifiInterfaceImpl.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,13 +698,11 @@ CHIP_ERROR WifiInterfaceImpl::GetAccessPointInfo(wfx_wifi_scan_result_t & info)
698698
{
699699
uint32_t signal_strength = 0;
700700

701-
// TODO: The ap_info.ssid isn't populated anywhere. The returned value is always 0.
702701
chip::ByteSpan apSsidSpan(ap_info.ssid, ap_info.ssid_length);
703702
chip::MutableByteSpan apSsidMutableSpan(info.ssid, WFX_MAX_SSID_LENGTH);
704703
chip::CopySpanToMutableSpan(apSsidSpan, apSsidMutableSpan);
705704
info.ssid_length = apSsidMutableSpan.size();
706705

707-
// TODO: The ap_info.bssid isn't populated anywhere. The returned value is always 0.
708706
chip::ByteSpan apBssidSpan(ap_info.bssid, kWifiMacAddressLength);
709707
chip::MutableByteSpan apBssidMutableSpan(info.bssid, kWifiMacAddressLength);
710708
chip::CopySpanToMutableSpan(apBssidSpan, apBssidMutableSpan);
@@ -869,15 +867,31 @@ void WifiInterfaceImpl::CancelScanNetworks()
869867

870868
void WifiInterfaceImpl::ConnectionEventCallback(sl_wfx_connect_ind_body_t connect_indication_body)
871869
{
872-
uint8_t * mac = connect_indication_body.mac;
873870
uint32_t status = connect_indication_body.status;
874-
ap_info.chan = connect_indication_body.channel;
875-
memcpy(&ap_info.security, &wifi_provision.security, sizeof(wifi_provision.security));
876871
switch (status)
877872
{
878873
case WFM_STATUS_SUCCESS: {
879874
ChipLogProgress(DeviceLayer, "STA-Connected");
880-
memcpy(ap_mac.data(), mac, kWifiMacAddressLength);
875+
876+
ap_info.chan = connect_indication_body.channel;
877+
chip::ByteSpan securitySpan(reinterpret_cast<const uint8_t *>(&wifi_provision.security), sizeof(wifi_provision.security));
878+
chip::MutableByteSpan apSecurityMutableSpan(reinterpret_cast<uint8_t *>(&ap_info.security), sizeof(ap_info.security));
879+
chip::CopySpanToMutableSpan(securitySpan, apSecurityMutableSpan);
880+
881+
// Store SSID
882+
chip::ByteSpan apSsidSpan(wifi_provision.ssid, wifi_provision.ssidLength);
883+
chip::MutableByteSpan apSsidMutableSpan(ap_info.ssid, WFX_MAX_SSID_LENGTH);
884+
chip::CopySpanToMutableSpan(apSsidSpan, apSsidMutableSpan);
885+
ap_info.ssid_length = wifi_provision.ssidLength;
886+
887+
// Store BSSID
888+
chip::ByteSpan macSpan(connect_indication_body.mac, kWifiMacAddressLength);
889+
chip::MutableByteSpan apBssidMutableSpan(ap_info.bssid, kWifiMacAddressLength);
890+
chip::CopySpanToMutableSpan(macSpan, apBssidMutableSpan);
891+
892+
// TODO: Refactor WifiInterface to use single representation of MAC address
893+
chip::MutableByteSpan apMacMutableSpan(ap_mac.data(), kWifiMacAddressLength);
894+
chip::CopySpanToMutableSpan(macSpan, apMacMutableSpan);
881895

882896
wifi_extra.Set(WifiInterface::WifiState::kStationConnected);
883897
xEventGroupSetBits(sl_wfx_event_group, SL_WFX_CONNECT);

0 commit comments

Comments
 (0)