Skip to content

Commit c586d93

Browse files
committed
airoc: enable wifi status
Add wifi status API to airoc wifi driver Signed-off-by: pennam <[email protected]>
1 parent 277ebb6 commit c586d93

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

drivers/wifi/infineon/airoc_wifi.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@ static int airoc_mgmt_connect(const struct device *dev, struct wifi_connect_req_
616616
} else {
617617
net_if_dormant_off(data->iface);
618618
data->is_sta_connected = true;
619+
data->ssid.length = MIN(params->ssid_length, WIFI_SSID_MAX_LEN);
620+
memcpy(data->ssid.value, params->ssid, data->ssid.length);
619621
#if defined(CONFIG_NET_DHCPV4)
620622
net_dhcpv4_restart(data->iface);
621623
#endif /* defined(CONFIG_NET_DHCPV4) */
@@ -750,6 +752,8 @@ static int airoc_mgmt_ap_enable(const struct device *dev, struct wifi_connect_re
750752
}
751753

752754
data->is_ap_up = true;
755+
data->ssid.length = MIN(ssid.length, WIFI_SSID_MAX_LEN);
756+
memcpy(data->ssid.value, ssid.value, data->ssid.length);
753757
airoc_if = airoc_ap_if;
754758
net_if_dormant_off(data->iface);
755759
error:
@@ -780,6 +784,66 @@ static int airoc_mgmt_wifi_stats(const struct device *dev, struct net_stats_wifi
780784
}
781785
#endif
782786

787+
static int airoc_mgmt_wifi_status(const struct device *dev, struct wifi_iface_status *status)
788+
{
789+
struct airoc_wifi_data *data = dev->data;
790+
791+
status->state = WIFI_STATE_DISCONNECTED;
792+
status->ssid_len = 0;
793+
status->ssid[0] = '\0';
794+
status->bssid[0] = '\0';
795+
status->band = WIFI_FREQ_BAND_2_4_GHZ;
796+
status->channel = 0;
797+
status->iface_mode = data->second_interface_init ? WIFI_MODE_AP : WIFI_MODE_INFRA;
798+
status->link_mode = WIFI_LINK_MODE_UNKNOWN;
799+
status->wpa3_ent_type = WIFI_WPA3_ENTERPRISE_NA;
800+
status->security = WIFI_SECURITY_TYPE_UNKNOWN;
801+
status->mfp = WIFI_MFP_DISABLE;
802+
status->rssi = 0;
803+
status->dtim_period = 0;
804+
status->beacon_interval = 0;
805+
806+
if (data->is_ap_up == false && data->is_sta_connected == false) {
807+
return 0;
808+
}
809+
810+
status->state = WIFI_STATE_COMPLETED;
811+
status->ssid_len = MIN(data->ssid.length, WIFI_SSID_MAX_LEN);
812+
memcpy(status->ssid, data->ssid.value, status->ssid_len);
813+
814+
whd_interface_t *if_ptr = data->is_sta_connected ? &airoc_sta_if : &airoc_ap_if;
815+
816+
whd_mac_t bssid;
817+
if (whd_wifi_get_bssid(*if_ptr, &bssid) == WHD_SUCCESS) {
818+
memcpy(status->bssid, bssid.octet, sizeof(bssid.octet));
819+
}
820+
821+
uint32_t channel;
822+
if (whd_wifi_get_channel(*if_ptr, &channel) == WHD_SUCCESS) {
823+
status->channel = channel;
824+
if (channel <= 14) {
825+
status->band = WIFI_FREQ_BAND_2_4_GHZ;
826+
} else {
827+
status->band = WIFI_FREQ_BAND_5_GHZ;
828+
}
829+
}
830+
831+
status->iface_mode = data->is_ap_up ? WIFI_MODE_AP : WIFI_MODE_INFRA;
832+
833+
int32_t rssi;
834+
if (whd_wifi_get_rssi(*if_ptr, &rssi) == WHD_SUCCESS) {
835+
status->rssi = rssi;
836+
}
837+
838+
whd_listen_interval_t li;
839+
if (whd_wifi_get_listen_interval(*if_ptr, &li) == WHD_SUCCESS) {
840+
status->beacon_interval = li.beacon;
841+
status->dtim_period = li.dtim;
842+
}
843+
844+
return 0;
845+
}
846+
783847
static int airoc_mgmt_ap_disable(const struct device *dev)
784848
{
785849
cy_rslt_t whd_ret;
@@ -867,6 +931,7 @@ static const struct wifi_mgmt_ops airoc_wifi_mgmt = {
867931
#if defined(CONFIG_NET_STATISTICS_WIFI)
868932
.get_stats = airoc_mgmt_wifi_stats,
869933
#endif
934+
.iface_status = airoc_mgmt_wifi_status,
870935
};
871936

872937
static const struct net_wifi_mgmt_offload airoc_api = {

0 commit comments

Comments
 (0)