@@ -138,10 +138,15 @@ int nxp_wifi_wlan_event_callback(enum wlan_event_reason reason, void *data)
138138 LOG_ERR ("WLAN: initialization failed" );
139139 break ;
140140 case WLAN_REASON_AUTH_SUCCESS :
141+ #ifndef CONFIG_WIFI_NM_WPA_SUPPLICANT
142+ net_if_dormant_off (g_mlan .netif );
143+ #endif
141144 LOG_DBG ("WLAN: authenticated to nxp_wlan_network" );
142145 break ;
143146 case WLAN_REASON_ASSOC_SUCCESS :
147+ #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT
144148 net_if_dormant_off (g_mlan .netif );
149+ #endif
145150 LOG_DBG ("WLAN: associated to nxp_wlan_network" );
146151 break ;
147152 case WLAN_REASON_SUCCESS :
@@ -186,22 +191,22 @@ int nxp_wifi_wlan_event_callback(enum wlan_event_reason reason, void *data)
186191 wifi_mgmt_raise_connect_result_event (g_mlan .netif , 0 );
187192 break ;
188193 case WLAN_REASON_CONNECT_FAILED :
189- net_eth_carrier_off (g_mlan .netif );
194+ net_if_dormant_on (g_mlan .netif );
190195 LOG_WRN ("WLAN: connect failed" );
191196 break ;
192197 case WLAN_REASON_NETWORK_NOT_FOUND :
193- net_eth_carrier_off (g_mlan .netif );
198+ net_if_dormant_on (g_mlan .netif );
194199 LOG_WRN ("WLAN: nxp_wlan_network not found" );
195200 break ;
196201 case WLAN_REASON_NETWORK_AUTH_FAILED :
197- net_eth_carrier_off (g_mlan .netif );
198202 LOG_WRN ("WLAN: nxp_wlan_network authentication failed" );
199203 auth_fail ++ ;
200204 if (auth_fail >= 3 ) {
201205 LOG_WRN ("Authentication Failed. Disconnecting ... " );
202206 wlan_disconnect ();
203207 auth_fail = 0 ;
204208 }
209+ net_if_dormant_on (g_mlan .netif );
205210 break ;
206211 case WLAN_REASON_ADDRESS_SUCCESS :
207212 LOG_DBG ("wlan_network mgr: DHCP new lease" );
@@ -210,7 +215,7 @@ int nxp_wifi_wlan_event_callback(enum wlan_event_reason reason, void *data)
210215 LOG_WRN ("failed to obtain an IP address" );
211216 break ;
212217 case WLAN_REASON_USER_DISCONNECT :
213- net_eth_carrier_off (g_mlan .netif );
218+ net_if_dormant_on (g_mlan .netif );
214219 LOG_DBG ("disconnected" );
215220 auth_fail = 0 ;
216221 s_nxp_wifi_StaConnected = false;
@@ -438,6 +443,7 @@ static int nxp_wifi_start_ap(const struct device *dev, struct wifi_connect_req_p
438443 int status = NXP_WIFI_RET_SUCCESS ;
439444 int ret ;
440445 struct interface * if_handle = (struct interface * )& g_uap ;
446+ struct ipv4_config * ap_addr4 = & nxp_wlan_network .ip .ipv4 ;
441447
442448 if (if_handle -> state .interface != WLAN_BSS_TYPE_UAP ) {
443449 LOG_ERR ("Wi-Fi not in uAP mode" );
@@ -512,6 +518,17 @@ static int nxp_wifi_start_ap(const struct device *dev, struct wifi_connect_req_p
512518 wlan_uap_set_hidden_ssid (params -> ignore_broadcast_ssid );
513519 }
514520
521+ if (net_addr_pton (AF_INET , CONFIG_NXP_WIFI_SOFTAP_IP_ADDRESS , & ap_addr4 -> address ) < 0 ) {
522+ LOG_ERR ("Invalid CONFIG_NXP_WIFI_SOFTAP_IP_ADDRESS" );
523+ return - ENOENT ;
524+ }
525+ ap_addr4 -> gw = ap_addr4 -> address ;
526+
527+ if (net_addr_pton (AF_INET , CONFIG_NXP_WIFI_SOFTAP_IP_MASK , & ap_addr4 -> netmask ) < 0 ) {
528+ LOG_ERR ("Invalid CONFIG_NXP_WIFI_SOFTAP_IP_MASK" );
529+ return - ENOENT ;
530+ }
531+
515532 ret = wlan_add_network (& nxp_wlan_network );
516533 if (ret != WM_SUCCESS ) {
517534 status = NXP_WIFI_RET_FAIL ;
@@ -961,6 +978,65 @@ static inline enum wifi_security_type nxp_wifi_security_type(enum wlan_security_
961978 }
962979}
963980
981+ #ifdef CONFIG_NXP_WIFI_SOFTAP_SUPPORT
982+ static int nxp_wifi_uap_status (const struct device * dev , struct wifi_iface_status * status )
983+ {
984+ enum wlan_connection_state connection_state = WLAN_DISCONNECTED ;
985+ struct interface * if_handle = (struct interface * )& g_uap ;
986+
987+ wlan_get_uap_connection_state (& connection_state );
988+
989+ if (connection_state == WLAN_UAP_STARTED ) {
990+
991+ if (!wlan_get_current_uap_network (& nxp_wlan_network )) {
992+ strncpy (status -> ssid , nxp_wlan_network .ssid , WIFI_SSID_MAX_LEN );
993+ status -> ssid [WIFI_SSID_MAX_LEN - 1 ] = 0 ;
994+ status -> ssid_len = strlen (status -> ssid );
995+
996+ memcpy (status -> bssid , nxp_wlan_network .bssid , WIFI_MAC_ADDR_LEN );
997+
998+ status -> rssi = nxp_wlan_network .rssi ;
999+
1000+ status -> channel = nxp_wlan_network .channel ;
1001+
1002+ status -> beacon_interval = nxp_wlan_network .beacon_period ;
1003+
1004+ status -> dtim_period = nxp_wlan_network .dtim_period ;
1005+
1006+ if (if_handle -> state .interface == WLAN_BSS_TYPE_STA ) {
1007+ status -> iface_mode = WIFI_MODE_INFRA ;
1008+ } else if (if_handle -> state .interface == WLAN_BSS_TYPE_UAP ) {
1009+ status -> iface_mode = WIFI_MODE_AP ;
1010+ }
1011+
1012+ #ifdef CONFIG_NXP_WIFI_11AX
1013+ if (nxp_wlan_network .dot11ax ) {
1014+ status -> link_mode = WIFI_6 ;
1015+ }
1016+ #endif
1017+ #ifdef CONFIG_NXP_WIFI_11AC
1018+ else if (nxp_wlan_network .dot11ac ) {
1019+ status -> link_mode = WIFI_5 ;
1020+ }
1021+ #endif
1022+ else if (nxp_wlan_network .dot11n ) {
1023+ status -> link_mode = WIFI_4 ;
1024+ } else {
1025+ status -> link_mode = WIFI_3 ;
1026+ }
1027+
1028+ status -> band = nxp_wlan_network .channel > 14 ? WIFI_FREQ_BAND_5_GHZ
1029+ : WIFI_FREQ_BAND_2_4_GHZ ;
1030+ status -> security = nxp_wifi_security_type (nxp_wlan_network .security .type );
1031+ status -> mfp = nxp_wlan_network .security .mfpr ? WIFI_MFP_REQUIRED :
1032+ (nxp_wlan_network .security .mfpc ? WIFI_MFP_OPTIONAL : 0 );
1033+ }
1034+ }
1035+
1036+ return 0 ;
1037+ }
1038+ #endif
1039+
9641040static int nxp_wifi_status (const struct device * dev , struct wifi_iface_status * status )
9651041{
9661042 enum wlan_connection_state connection_state = WLAN_DISCONNECTED ;
@@ -1767,7 +1843,7 @@ NET_DEVICE_INIT_INSTANCE(wifi_nxp_sta, "ml", 0, nxp_wifi_dev_init, PM_DEVICE_DT_
17671843static const struct wifi_mgmt_ops nxp_wifi_uap_mgmt = {
17681844 .ap_enable = nxp_wifi_start_ap ,
17691845 .ap_disable = nxp_wifi_stop_ap ,
1770- .iface_status = nxp_wifi_status ,
1846+ .iface_status = nxp_wifi_uap_status ,
17711847#if defined(CONFIG_NET_STATISTICS_WIFI )
17721848 .get_stats = nxp_wifi_stats ,
17731849#endif
0 commit comments