[Feature][T108][WIFI][task-view-1467]The addition of 13 interfaces with a priority of 1 for wifi, as well as the optimization of wifi tools

Only Configure: No
Affected branch: GSW_V1453
Affected module: WIFI
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no

Change-Id: Ib4eaf56143294f2ebb7897954dec7f6390f6cec0
diff --git a/config/defconfig_asr1806p301 b/config/defconfig_asr1806p301
index bdb4983..cdbd52d 100755
--- a/config/defconfig_asr1806p301
+++ b/config/defconfig_asr1806p301
@@ -3048,8 +3048,11 @@
 #
 # AIC WiFi driver
 #
-# CONFIG_PACKAGE_aicrf-test is not set
-# CONFIG_PACKAGE_kmod-aic-driver is not set
+CONFIG_PACKAGE_aicrf-test=y
+CONFIG_PACKAGE_kmod-aic-driver=y
+# CONFIG_AIC_PCIE_WIFI is not set
+# CONFIG_AIC_SDIO_WIFI is not set
+CONFIG_AIC_KERNEL_SDIO_WIFI=y
 # end of AIC WiFi driver
 
 #
@@ -5352,7 +5355,7 @@
 CONFIG_PACKAGE_libopenssl-conf=y
 # CONFIG_PACKAGE_libopenssl-devcrypto is not set
 # CONFIG_PACKAGE_libopenssl-gost_engine is not set
-# CONFIG_PACKAGE_libopenssl-legacy is not set
+CONFIG_PACKAGE_libopenssl-legacy=y
 CONFIG_PACKAGE_libwolfssl=y
 
 #
@@ -6734,9 +6737,9 @@
 # CONFIG_WPA_RFKILL_SUPPORT is not set
 CONFIG_WPA_MSG_MIN_PRIORITY=2
 # CONFIG_WPA_WOLFSSL is not set
-# CONFIG_DRIVER_11AC_SUPPORT is not set
-# CONFIG_DRIVER_11AX_SUPPORT is not set
-# CONFIG_WPA_ENABLE_WEP is not set
+CONFIG_DRIVER_11AC_SUPPORT=y
+CONFIG_DRIVER_11AX_SUPPORT=y
+CONFIG_WPA_ENABLE_WEP=y
 CONFIG_WPA_MBO_SUPPORT=y
 # CONFIG_PACKAGE_asr-wpa-supplicant-basic is not set
 # CONFIG_PACKAGE_asr-wpa-supplicant-mbedtls is not set
@@ -6768,10 +6771,12 @@
 # CONFIG_PACKAGE_hostapd-mbedtls is not set
 # CONFIG_PACKAGE_hostapd-mini is not set
 # CONFIG_PACKAGE_hostapd-openssl is not set
+CONFIG_PACKAGE_hostapd-utils=y
 # CONFIG_PACKAGE_hostapd-wolfssl is not set
 # CONFIG_PACKAGE_hs20-client is not set
 # CONFIG_PACKAGE_hs20-common is not set
 # CONFIG_PACKAGE_hs20-server is not set
+CONFIG_PACKAGE_wpa-cli=y
 # CONFIG_PACKAGE_wpa-supplicant is not set
 # CONFIG_DRIVER_11BE_SUPPORT is not set
 # CONFIG_PACKAGE_wpa-supplicant-basic is not set
@@ -6793,7 +6798,7 @@
 # CONFIG_PACKAGE_wpad-mesh-openssl is not set
 # CONFIG_PACKAGE_wpad-mesh-wolfssl is not set
 # CONFIG_PACKAGE_wpad-mini is not set
-# CONFIG_PACKAGE_wpad-openssl is not set
+CONFIG_PACKAGE_wpad-openssl=y
 # CONFIG_PACKAGE_wpad-wolfssl is not set
 # end of WirelessAPD
 
diff --git a/mbtk/include/gsw/gsw_wifi_interface_sdk.h b/mbtk/include/gsw/gsw_wifi_interface_sdk.h
new file mode 100644
index 0000000..110f5c0
--- /dev/null
+++ b/mbtk/include/gsw/gsw_wifi_interface_sdk.h
@@ -0,0 +1,590 @@
+/**
+*  @file  : gsw_wifi_interface_sdk.h
+*  @brief : wifi abstract_sdk
+*  @date : 2022-08-14
+*  @author : zhaohua
+*  @version : v1.0
+*  @copyright Copyright (c) 2022 www.gosuncn.com
+*/
+#ifndef __GSW_WIFI_INTERFACE_SDK_H__
+#define __GSW_WIFI_INTERFACE_SDK_H__
+
+#include "gsw_hal_errcode.h"
+
+#define GSW_WIFI_AP_DEVICE_NUM      8               /**< ap device max num  */
+#define GSW_WIFI_STA_REMEMBER_HOST_NUM      50      /**< sta save ap max num  */
+#define GSW_WIFI_STA_SCANLIST_NUM           100     /**< sta scan list max num */
+
+/**
+ *  @brief ap callback event type
+ */
+typedef enum {
+    GSW_WIFI_STATUS_DISCONNECT = 0,  /**< sta disconnect */
+    GSW_WIFI_STATUS_CONNECT,         /**< sta connect    */
+} gsw_wifi_ap_status_e;
+
+/**
+ *  @brief sta callback event type
+ */
+typedef enum {
+    GSW_WIFI_STA_STATUS_DISCONNECT = 0, /**< sta disconnect   */
+    GSW_WIFI_STA_STATUS_CONNECT,        /**< sta connect      */
+    GSW_WIFI_STA_STATUS_SCAN_RESULT,    /**< sta scan finish  */
+} gsw_wifi_sta_status_e;
+
+/**
+ *  @brief wifi ability type
+ */
+typedef enum {
+    WIFI_MODE_ABILITY_NOWLAN    = 1,    /**< no wlan     */
+    WIFI_MODE_ABILITY_STA_ONLY  = 2,    /**< sta only    */
+    WIFI_MODE_ABILITY_AP_ONLY   = 3,    /**< ap only     */
+    WIFI_MODE_ABILITY_APANDSTA  = 4,    /**< ap and sta  */
+} wifi_mode_ability_e;
+
+/**
+ *  @brief ap bandwidth type
+ */
+typedef enum {
+    GSW_WIFI_BANDWIDTH_HT10 = 0,        /**< 10Mhz   */
+    GSW_WIFI_BANDWIDTH_HT20,            /**< 20Mhz   */
+    GSW_WIFI_BANDWIDTH_HT40,            /**< 40Mhz   */
+    GSW_WIFI_BANDWIDTH_HT80,            /**< 80Mhz   */
+} gsw_wifi_bandwidth_type_e;
+
+/**
+ *  @brief authentication type
+ */
+typedef enum {
+    GSW_WIFI_AUTH_OPEN = 0,     /**< OPEN      */
+    GSW_WIFI_AUTH_WEP,          /**< WEP       */
+    GSW_WIFI_AUTH_WPA_PSK,      /**< WPA_PSK   */
+    GSW_WIFI_AUTH_WPA2_PSK,     /**< WPA2_PSK  */
+    GSW_WIFI_AUTH_WPA3_PSK,     /**< WPA3_PSK  */
+} gsw_wifi_auth_e;
+
+/**
+ *  @brief ap state
+ */
+typedef enum {
+    GSW_WIFI_AP_STATUS_DISABLE = 0, /**< not running  */
+    GSW_WIFI_AP_STATUS_ENABLE,      /**< running      */
+} gsw_wifi_ap_run_status_e;
+
+/**
+ *  @brief sta state
+ */
+typedef enum {
+    GSW_WIFI_STA_STATUS_DISABLE = 0,   /**< not running  */
+    GSW_WIFI_STA_STATUS_ENABLE,        /**< running      */
+} gsw_wifi_sta_run_status_e;
+
+/**
+ *  @brief wifi interface idx
+ */
+typedef enum {
+    GSW_WIFI_INTERFACE_0 = 0,      /**< STA   */
+    GSW_WIFI_INTERFACE_1,          /**< AP   */
+}gsw_wifi_index_e;
+
+/**
+ *  @brief band type
+ */
+typedef enum {
+    GSW_WIFI_2G_band = 1,       /**< 2.4G         */
+    GSW_WIFI_5G_band,           /**< 5G           */
+    GSW_WIFI_2_and_5G_band,     /**< 2.4G and 5G  */
+} gsw_wifi_band_e;
+
+/**
+ *  @brief sta mode dns info
+ */
+typedef struct gsw_sta_dns_info
+{
+    char dnsp[46]; //Primary DNS server address
+    char dnss[46]; //Secondary DNS server address
+} gsw_sta_dns_info_s;
+
+/**
+ *  @brief ap info
+ */
+typedef struct gsw_ap_info
+{
+    char ap_ip[32];         /**< IP Addr         */
+    char ap_mac[32];        /**< IP Addr         */
+    char ap_ssid[32];       /**< ssid            */
+    char psw[64];           /**< password        */
+    gsw_wifi_auth_e auth;   /**< authentication  */
+    gsw_wifi_band_e band;   /**< band            */
+} gsw_ap_info_s;
+
+typedef struct gsw_ap_detail_info
+{
+    struct gsw_ap_info base_info;    /**< ap info       */
+    gsw_wifi_ap_run_status_e status; /**< ap run state  */
+    int rssi;                        /**< rssi[0~199]   */
+} gsw_ap_detail_info_s;
+
+/**
+ *  @brief device info
+ */
+typedef struct gsw_device_info
+{
+    char sta_ip[32];                /**< IP Addr         */
+    char sta_mac[32];               /**< IP Addr         */
+    char hostname[32];              /**< device name     */
+    gsw_wifi_ap_status_e status;    /**< connect state   */
+} gsw_device_info_s;
+
+typedef struct gsw_saved_ap_info
+{
+    struct gsw_ap_info base_info;
+} gsw_saved_ap_info_s;
+
+/**
+ *  @brief error code of sta connect fail
+ *  current only support errcode 1,2
+ */
+typedef enum
+{
+    GSW_REASON_IP_NOT_ACCESS                      = 0, /**< IP connect not access */
+    GSW_REASON_UNSPECIFIED                        = 1, /**< Unspecified reason */
+    GSW_REASON_PREV_AUTH_NOT_VALID                = 2, /**< Previous authentication no longer valid */
+    GSW_REASON_DEAUTH_LEAVING                     = 3, /**< Deauthenticated because sending STA is leaving (or has left) IBSS or ESS */
+    GSW_REASON_DISASSOC_DUE_TO_INACTIVITY         = 4, /**< Disassociated due to inactivity */
+    GSW_REASON_DISASSOC_AP_BUSY                   = 5, /**< Disassociated because AP is unable to handle all currently associated STA */
+    GSW_REASON_CLASS2_FRAME_FROM_NONAUTH_STA      = 6, /**< Class 2 frame received from nonauthenticated STA */
+    GSW_REASON_CLASS3_FRAME_FROM_NONASSOC_STA     = 7, /**< Class 3 frame received from nonassociated STA */
+    GSW_REASON_DISASSOC_STA_HAS_LEFT              = 8, /**< Disassociated because sending STA is leaving (or has left) BSS */
+    GSW_REASON_STA_REQ_ASSOC_WITHOUT_AUTH         = 9, /**< STA requesting (re)association is not authenticated with responding STA */
+    GSW_REASON_PWR_CAPABILITY_NOT_VALID           = 10, /**< Disassociated because the information in the Power Capability element is unacceptable */
+    GSW_REASON_SUPPORTED_CHANNEL_NOT_VALID        = 11, /**< Disassociated because the information in the Supported Channels is unacceptable */
+    GSW_REASON_BSS_TRANSITION_DISASSOC            = 12, /**< Disassociated due to BSS Transition Management */
+    GSW_REASON_INVALID_IE                         = 13, /**< Invalid element, i.e., an element defined in this standard for which the content
+                                                             does not meet the specifications in Clause 8 */
+    GSW_REASON_MICHAEL_MIC_FAILURE                = 14, /**< Message integrity code (MIC) failure */
+    GSW_REASON_4WAY_HANDSHAKE_TIMEOUT             = 15, /**< 4-Way Handshake timeout */
+    GSW_REASON_GROUP_KEY_UPDATE_TIMEOUT           = 16, /**< Group Key Handshake timeout */
+    GSW_REASON_IE_IN_4WAY_DIFFERS                 = 17, /**< Element in 4-Way handshake different from (Re)Association
+                                                             Request/Probe Response/Beacon frame */
+    GSW_REASON_GROUP_CIPHER_NOT_VALID             = 18, /**< Invalid group cipher */
+    GSW_REASON_PAIRWISE_CIPHER_NOT_VALID          = 19, /**< Invalid pairwise cipher */
+    GSW_REASON_AKMP_NOT_VALID                     = 20, /**< Invalid AKMP */
+    GSW_REASON_UNSUPPORTED_RSN_IE_VERSION         = 21, /**< Unsupproted RSNE version */
+    GSW_REASON_INVALID_RSN_IE_CAPAB               = 22, /**< Invalid RSNE capabilities */
+    GSW_REASON_IEEE_802_1X_AUTH_FAILED            = 23, /**< IEEE 802.1X authentication failed */
+    GSW_REASON_CIPHER_SUITE_REJECTED              = 24, /**< Cipher suite rejected because of the security policy */
+    GSW_REASON_TDLS_TEARDOWN_UNREACHABLE          = 25, /**< TDLS direct-link teardown due to TDLS peer STA unreachable via the TDLS direct link */
+    GSW_REASON_TDLS_TEARDOWN_UNSPECIFIED          = 26, /**< TDLS direct-link teardown for unspecified reason */
+    GSW_REASON_SSP_REQUESTED_DISASSOC             = 27, /**< Disassocited because session terminated by SSP request */
+    GSW_REASON_NO_SSP_ROAMING_AGREEMENT           = 28, /**< Disassocited because of lack of SSP roaming agreement */
+    GSW_REASON_BAD_CIPHER_OR_AKM                  = 29, /**< Requested service rejected because of SSP cipher suite or AKM requirment */
+    GSW_REASON_NOT_AUTHORIZED_THIS_LOCATION       = 30, /**< requested service not authorized in this location */
+    GSW_REASON_SERVICE_CHANGE_PRECLUDES_TS        = 31, /**< TS deleted because QoS AP lacks sufficient bandwidth for 
+                                                             this QoS STA due to a change in BSS service characteristics or operational mode 
+                                                             (e.g., an HT BSS change from 40 MHz channel to 20 MHz channel) */
+    GSW_REASON_UNSPECIFIED_QOS_REASON             = 32, /**< Disassocited for unspecified QoS-related reason */
+    GSW_REASON_NOT_ENOUGH_BANDWIDTH               = 33, /**< Disassocited because QoS AP lacks sufficient bandwidth for this QoS STA */
+    GSW_REASON_DISASSOC_LOW_ACK                   = 34, /**< Disassociated because excessive number of frames need to be acknowledged,
+                                                             but are not acknowledged due to AP transmissions and/or poor channel conditions */
+    GSW_REASON_EXCEEDED_TXOP                      = 35, /**< Disassociated because STA is transmitting outside the limits of its TXOPs */
+    GSW_REASON_STA_LEAVING                        = 36, /**< Requested from peer STA as the STA is leaving the BSS (or resetting) */
+    GSW_REASON_END_TS_BA_DLS                      = 37, /**< Requested from peer STA as it does not want to use the mechanism */
+    GSW_REASON_UNKNOWN_TS_BA                      = 38, /**< Requested from peer STA as the STA received frames using
+                                                             the mechanism for which a setup is required */
+    GSW_REASON_TIMEOUT                            = 39, /**< Requested from peer STA due to timeout */
+    GSW_REASON_PEERKEY_MISMATCH                   = 45, /**< Peer STA does not support the requested cipher suite */
+    GSW_REASON_AUTHORIZED_ACCESS_LIMIT_REACHED    = 46, /**< In a DLS Teardown frame: The teardown was initiated by the DLS peer in 
+                                                             a disassociation frame: disassociated because authorized access limit reached*/
+    GSW_REASON_EXTERNAL_SERVICE_REQUIREMENTS      = 47, /**< In a DLS Teardown frame: The teardown was initiated by the AP
+                                                             In a disassociation frame: disassociated due to external service requirments */
+    GSW_REASON_INVALID_FT_ACTION_FRAME_COUNT      = 48, /**< Invalid FT action frame count */
+    GSW_REASON_INVALID_PMKID                      = 49, /**< Invalid pairwise master key identifier (PMKI) */
+    GSW_REASON_INVALID_MDE                        = 50, /**< Invalid MDE */
+    GSW_REASON_INVALID_FTE                        = 51, /**< Invalid FTE */
+    GSW_REASON_MESH_PEERING_CANCELLED             = 52, /**< SME cancels the mesh peering instance with the reason
+                                                             other than reaching the maximum number of peer mesh STAs */
+    GSW_REASON_MESH_MAX_PEERS                     = 53, /**< The mesh STA has reached the supported maximum number of peer mesh STAs */
+    GSW_REASON_MESH_CONFIG_POLICY_VIOLATION       = 54, /**< The received information violates the Mesh Configuration policy configured in the mesh STA profile */
+    GSW_REASON_MESH_CLOSE_RCVD                    = 55, /**< The mesh STA has received a Mesh Peering Close message requesting to close the mesh peering*/
+    GSW_REASON_MESH_MAX_RETRIES                   = 56, /**< the mesh STA has resent dot11MeshMaxRetries Mesh Peering Open messages
+                                                             without receiveing a Mesh Peering Confirm messa*/
+    GSW_REASON_MESH_CONFIRM_TIMEOU                = 57, /**< The confirm Timer for the mesh peering instance times out */
+    GSW_REASON_MESH_INVALID_GTK                   = 58, /**< The mesh STA fails to unwrap the GTK or the values in the wrapped contents do not match */
+    GSW_REASON_MESH_INCONSISTENT_PARAMS           = 59, /**< The mesh STA receives inconsistent information about the mesh parameters
+                                                             between mesh peering management frames */
+    GSW_REASON_MESH_INVALID_SECURITY_CAP          = 60, /**< The mesh STA fails the authenticated mesh peering exchange because due to failure
+                                                             in selecting either in the pairwise ciphersuite or group ciphersuite*/
+    GSW_REASON_MESH_PATH_ERROR_NO_PROXY_INFO      = 61, /**< The mesh STA does not have proxy information for this external destination */
+    GSW_REASON_MESH_PATH_ERROR_NO_FORWARDING_INFO = 62, /**< The mesh STA does not have forwarding infromation for this destination */
+    GSW_REASON_MESH_PATH_ERROR_DEST_UNREACHABLE   = 63, /**< The mesh STA determines that the link to the next hop of an active path in 
+                                                             its forwarding information is no longer usable */
+    GSW_REASON_MAC_ADDRESS_ALREADY_EXISTS_IN_MBSS = 64, /**< The deauthentication frame was sent because the MAC address 
+                                                             of the STA already exists in the mesh BSS.Scc10.3.6 */
+    GSW_REASON_MESH_CHANNEL_SWITCH_REGULATORY_REQ = 65, /**< The mesh STA performs channel switch to meet regulatory requirments */
+    GSW_REASON_MESH_CHANNEL_SWITCH_UNSPECIFIED    = 66, /**< The mesh STA performs channel switch with unspecified reason */
+    GSW_REASON_LOW_SECURITY                       = 67, /**< Low level of network security */
+} error_number_e;
+
+typedef struct gsw_scan_info
+{
+    char mac[32];           /**< MAC addr       */
+    char ssid[33];          /**< ssid           */
+    gsw_wifi_band_e band;   /**< band           */
+    gsw_wifi_auth_e auth;   /**< authentication */
+    int rssi;               /**< rssi           */
+} gsw_scan_info_s;
+
+
+/**
+ * @brief modem sdk wifi service init
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sdk_interface_init(void);
+
+/**
+ * @brief load wifi driver
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_enable(void);
+
+/**
+ * @brief uninstall wifi driver
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_disable(void);
+
+/**
+ * @brief start ap mode
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_start(void);
+
+/**
+ * @brief stop ap mode
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_stop(void);
+
+/**
+ * @brief restart ap
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_restart(void);
+
+int gsw_wifi_stop_ap(wifi_mode_ability_e mode_ability);
+
+/**
+ * @brief set ap ssid
+ * @param  [in] ssid ssid
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_ssid_set(char *ssid);
+
+/**
+ * @brief get ap ssid
+ * @param  [out] ssid ssid
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_ssid_get(char *ssid);
+
+/**
+ * @brief set ap frequency
+ * @param  [in] gsw_wifi_frequency 1 is 2.4G,2 is 5G
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_frequency_set(int gsw_wifi_frequency);
+
+/**
+ * @brief get ap frequency
+ * @param  [out] gsw_wifi_frequency 1 is 2.4G,2 is 5G
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_frequency_get(int *gsw_wifi_frequency);
+
+/**
+ * @brief set ap bandwidth
+ * @param  [in] bandwidth bandwidth
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_bandwidth_set(gsw_wifi_bandwidth_type_e bandwidth);
+
+/**
+ * @brief get ap bandwidth
+ * @param  [out] bandwidth bandwidth
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_bandwidth_get(gsw_wifi_bandwidth_type_e *bandwidth);
+
+/**
+ * @brief set ap channel
+ * @param  [in] channel channel
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_channel_set(int channel);
+
+/**
+ * @brief get ap channel
+ * @param  [out] channel channel
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_channel_get(int *channel);
+
+/**
+ * @brief set ap authentication
+ * @param  [in] auth authentication
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_auth_set(gsw_wifi_auth_e auth);
+
+/**
+ * @brief get ap authentication
+ * @param  [out] auth authentication
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_auth_get(gsw_wifi_auth_e *auth);
+
+/**
+ * @brief set ap password
+ * @param  [in] password password
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_password_set(char *password);
+
+/**
+ * @brief get ap password
+ * @param  [out] password password
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_ap_password_get(char *password);
+
+/**
+ * @brief get ap run state
+ * @param  [out] ap_status ap run state
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_ap_status(gsw_wifi_ap_run_status_e *ap_status);
+
+/**
+ * @brief get sta run state
+ * @param  [out] sta_status sta run state
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_sta_status(gsw_wifi_sta_run_status_e *sta_status);
+
+/**
+ * @brief start sta mode
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sta_start(void);
+
+/**
+ * @brief stop sta mode
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sta_stop(void);
+
+int gsw_wifi_stop_sta(wifi_mode_ability_e mode_ability);
+
+/**
+ * @brief obtain the ssid of the ap currently connected to the sta
+ * @param  [out] sta_ssid ssid
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_sta_ssid(char *sta_ssid);
+
+/**
+ * @brief obtain the authentication of the ap currently connected to the sta
+ * @param  [out] auth authentication
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_sta_auth(gsw_wifi_auth_e *auth);
+
+/**
+ * @brief  connect to target ap
+ * @param  [in] ssid the ssid of the target ap
+ * @param  [in] auth the authentication of the target ap
+ * @param  [in] password the password of the target ap
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sta_connect(char *ssid, gsw_wifi_auth_e auth, char *password);
+
+/**
+ * @brief  disconnect the currently connected ap
+ * @param  [in] ssid the ssid of the target ap
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sta_disconnect(char *ssid);
+
+/**
+ * @brief  delete remembered ap
+ * @param  [in] ssid the ssid of the target ap
+ * @param  [in] auth the authentication of the target ap
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sta_forget_ap(char *ssid, gsw_wifi_auth_e auth);
+
+/**
+ * @brief sta start scan
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_sta_start_scan(void);
+
+/**
+ * @brief  get interface ip addr
+ * @param  [in] idx interface idx
+ * @param  [out] ip interface ip addr
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_interface_ip(gsw_wifi_index_e idx, char *ip);
+
+/**
+ * @brief  get interface mac addr
+ * @param  [in] idx interface idx
+ * @param  [out] mac interface mac addr
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_interface_mac(gsw_wifi_index_e idx, char *mac);
+
+/**
+ * @brief  obtain the mac of the ap currently connected to the sta
+ * @param  [out] mac ap mac addr
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_connect_ap_mac(char *mac);
+
+/**
+ * @brief  obtain the rssi of the ap currently connected to the sta
+ * @param  [out] rssi ap rssi
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_connect_ap_rssi(int *rssi);
+
+/**
+ * @brief  obtain the band of the ap currently connected to the sta
+ * @param  [out] band the ap band
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_connect_ap_band(gsw_wifi_band_e *band);
+
+/**
+ * @brief  obtain the ip of the ap currently connected to the sta
+ * @param  [out] ip the ap ip
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_connect_ap_ip(char *ip);
+
+/**
+ * @brief get the currently connectable AP with the best signal strength
+ * @param  [out] info the ap info
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_sta_available_ap(gsw_ap_detail_info_s *info);
+
+/**
+ * @brief  get ap device list
+ * @param  [in] len  the size of the param[device_list]
+ * @param  [out] ap_info the ap info
+ * @param  [out] device_list the device list
+ * @param  [out] dev_len the device num
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_ap_device_list(gsw_ap_info_s *ap_info, gsw_device_info_s *device_list, int len, int *dev_len);
+
+/**
+ * @brief  get the saved ap list
+ * @param  [in] len  the size of the param[list]
+ * @param  [out] list the saved ap list
+ * @param  [out] list_len the list num
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_sta_saved_ap(gsw_saved_ap_info_s *list, int len, int *list_len);
+
+/**
+ * @brief  get the sta scan list
+ * @param  [in] len  the size of the param[list]
+ * @param  [out] list the scan list
+ * @param  [out] list_len the list num
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_get_scan_list(gsw_scan_info_s *list, int len, int *list_len);
+
+
+typedef void(*GSW_AP_CALLBACK_FUNC_PTR)(void *arg, gsw_wifi_ap_status_e status);
+
+/**
+ * @brief   register ap event notification function
+ * @param  [in] arg  as gsw_cb function parameter, can be NULL
+ * @param  [in] gsw_cb callback
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_reg_ap_event_callback(void *arg, GSW_AP_CALLBACK_FUNC_PTR gsw_cb);
+
+/**
+ * @brief  unregister ap callback function
+ * @param  [in] arg  reserved parameter, can be NULL
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_unreg_ap_event_callback(void *arg);
+
+typedef void(*GSW_STA_CALLBACK_FUNC_PTR)(void *arg, gsw_wifi_sta_status_e status, error_number_e number, gsw_sta_dns_info_s* dns_info);
+
+/**
+ * @brief   register sta event notification function
+ * @param  [in] arg  as gsw_cb function parameter, can be NULL
+ * @param  [in] gsw_cb callback
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_reg_sta_event_callback(void *arg, GSW_STA_CALLBACK_FUNC_PTR gsw_cb);
+
+/**
+ * @brief  unregister sta callback function
+ * @param  [in] arg  reserved parameters, can be NULL
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_unreg_sta_event_callback(void *arg);
+
+
+#endif
diff --git a/mbtk/libgsw_lib/gsw_wifi_interface_sdk.c b/mbtk/libgsw_lib/gsw_wifi_interface_sdk.c
new file mode 100644
index 0000000..489e146
--- /dev/null
+++ b/mbtk/libgsw_lib/gsw_wifi_interface_sdk.c
@@ -0,0 +1,2192 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <pthread.h>
+
+#include "gsw_wifi_interface_sdk.h"
+#include <dlfcn.h>
+#define MAX_COMMAND_LEN 512
+#define MAX_SSID_LEN 32
+#define MIN_PASSWORD_LEN 8
+#define MAX_PASSWORD_LEN 64
+#define MAX_IP_LEN 32
+#define MAX_MAC_LEN 32
+
+#define WLAN_STA_DEV "wlan0-vxd"
+#define WLAN_AP_DEV "wlan0"
+
+#define HOSTAPD_CONF_PATH "/etc/wifi/hostapd.conf"
+#define HOSTAPD_LOG_PATH "/etc/wifi/hostapd.log"
+#define WPA_SUPPLICANT_CONF_PATH "/etc/wifi/wpa_supplicant.conf"
+#define AIC8800_BSP_DRIVER_PATH "aic8800_bsp"
+#define AIC8800_FDRV_DRIVER_PATH "aic8800_fdrv"
+#define CTRL_INTERFACE "/var/run/hostapd"
+
+#define WPA_SUPPLICANT_CTRL_PATH "/var/run/wpa_supplicant"
+
+#define VALID_2G_CHANNELS {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
+#define VALID_5G_CHANNELS {36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}
+
+#ifndef LOG_ERR_LEVEL
+#define LOG_ERR_LEVEL 3 /* error conditions */
+#endif
+#ifndef LOG_WARN_LEVEL
+#define LOG_WARN_LEVEL 4 /* warning conditions */
+#endif
+#ifndef LOG_INFO_LEVEL
+#define LOG_INFO_LEVEL 6 /* informational */
+#endif
+#ifndef LOG_DEBUG_LEVEL
+#define LOG_DEBUG_LEVEL 7 /* debug-level messages */
+#endif
+#ifndef LOG_VERBOSE_LEVEL
+#define LOG_VERBOSE_LEVEL 8
+#endif
+
+#define GSW_UART "[HAL][GSW_WIFI]"
+
+#define LOGV(fmt, args...)                                                                          \
+    do                                                                                              \
+    {                                                                                               \
+        char *file_ptr_1001 = __FILE__;                                                             \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;                                 \
+        char line_1001[10] = {0};                                                                   \
+        sprintf(line_1001, "%d", __LINE__);                                                         \
+        while (ptr_1001 >= file_ptr_1001 && *ptr_1001)                                              \
+        {                                                                                           \
+            if (*ptr_1001 == '/')                                                                   \
+                break;                                                                              \
+            ptr_1001--;                                                                             \
+        }                                                                                           \
+        fun_ptr_log(LOG_VERBOSE_LEVEL, "%s#%s: " GSW_UART "" fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while (0)
+
+#define LOGI(fmt, args...)                                                                       \
+    do                                                                                           \
+    {                                                                                            \
+        char *file_ptr_1001 = __FILE__;                                                          \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;                              \
+        char line_1001[10] = {0};                                                                \
+        sprintf(line_1001, "%d", __LINE__);                                                      \
+        while (ptr_1001 >= file_ptr_1001 && *ptr_1001)                                           \
+        {                                                                                        \
+            if (*ptr_1001 == '/')                                                                \
+                break;                                                                           \
+            ptr_1001--;                                                                          \
+        }                                                                                        \
+        fun_ptr_log(LOG_INFO_LEVEL, "%s#%s: " GSW_UART "" fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while (0)
+
+#define LOGD(fmt, args...)                                                                        \
+    do                                                                                            \
+    {                                                                                             \
+        char *file_ptr_1001 = __FILE__;                                                           \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;                               \
+        char line_1001[10] = {0};                                                                 \
+        sprintf(line_1001, "%d", __LINE__);                                                       \
+        while (ptr_1001 >= file_ptr_1001 && *ptr_1001)                                            \
+        {                                                                                         \
+            if (*ptr_1001 == '/')                                                                 \
+                break;                                                                            \
+            ptr_1001--;                                                                           \
+        }                                                                                         \
+        fun_ptr_log(LOG_DEBUG_LEVEL, "%s#%s: " GSW_UART "" fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while (0)
+
+#define LOGW(fmt, args...)                                                                       \
+    do                                                                                           \
+    {                                                                                            \
+        char *file_ptr_1001 = __FILE__;                                                          \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;                              \
+        char line_1001[10] = {0};                                                                \
+        sprintf(line_1001, "%d", __LINE__);                                                      \
+        while (ptr_1001 >= file_ptr_1001 && *ptr_1001)                                           \
+        {                                                                                        \
+            if (*ptr_1001 == '/')                                                                \
+                break;                                                                           \
+            ptr_1001--;                                                                          \
+        }                                                                                        \
+        fun_ptr_log(LOG_WARN_LEVEL, "%s#%s: " GSW_UART "" fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while (0)
+
+#define LOGE(fmt, args...)                                                                      \
+    do                                                                                          \
+    {                                                                                           \
+        char *file_ptr_1001 = __FILE__;                                                         \
+        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;                             \
+        char line_1001[10] = {0};                                                               \
+        sprintf(line_1001, "%d", __LINE__);                                                     \
+        while (ptr_1001 >= file_ptr_1001 && *ptr_1001)                                          \
+        {                                                                                       \
+            if (*ptr_1001 == '/')                                                               \
+                break;                                                                          \
+            ptr_1001--;                                                                         \
+        }                                                                                       \
+        fun_ptr_log(LOG_ERR_LEVEL, "%s#%s: " GSW_UART "" fmt, ptr_1001 + 1, line_1001, ##args); \
+    } while (0)
+
+typedef void (*mbtk_log)(int level, const char *format, ...);
+static mbtk_log fun_ptr_log = NULL;
+void *dlHandle_wifi = NULL;
+char *lynqLib_wifi = "/lib/libmbtk_lib.so";
+
+static int handle()
+{
+    if (dlHandle_wifi == NULL || fun_ptr_log == NULL)
+    {
+        dlHandle_wifi = dlopen(lynqLib_wifi, RTLD_NOW);
+        fun_ptr_log = (mbtk_log)dlsym(dlHandle_wifi, "mbtk_log");
+        if (fun_ptr_log == NULL || dlHandle_wifi == NULL)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+// 辅助函数:执行系统命令
+int execute_command(const char *cmd)
+{
+    int status = system(cmd);
+    if (status == -1)
+    {
+        LOGE("Failed to execute command");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    if (WIFEXITED(status))
+    {
+        return WEXITSTATUS(status);
+    }
+    else
+    {
+        // 子进程异常退出,比如被信号终止
+        return GSW_HAL_NORMAL_FAIL;
+    }
+}
+
+// 辅助函数:读取文件内容到缓冲区
+int read_file(const char *path, char *buffer, size_t buffer_len)
+{
+    FILE *file = fopen(path, "r");
+    if (!file)
+        return GSW_HAL_NORMAL_FAIL;
+    size_t length = fread(buffer, 1, buffer_len - 1, file);
+    if (length == 0)
+    {
+        fclose(file);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    buffer[length] = '\0';
+    fclose(file);
+    return (int)length;
+}
+
+// 新增:静态互斥锁用于保护文件写入操作
+static pthread_mutex_t write_file_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+int write_file(const char *path, const char *buffer)
+{
+    // 加锁:确保同一时间只有一个线程执行文件写入
+    pthread_mutex_lock(&write_file_mutex);
+
+    FILE *file = fopen(path, "w");
+    if (!file)
+    {
+        // 解锁后返回错误
+        pthread_mutex_unlock(&write_file_mutex);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    fputs(buffer, file);
+    fclose(file);
+
+    // 解锁:释放锁资源
+    pthread_mutex_unlock(&write_file_mutex);
+    return GSW_HAL_SUCCESS;
+}
+
+// 辅助函数:检查 hostapd 是否正在运行
+int is_hostapd_running()
+{
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "ps | grep 'hostapd' | grep -v -E 'grep|global'");
+    FILE *output = popen(cmd, "r");
+    if (!output)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char buffer[1]; // 只需检查是否有输出,读取一个字符即可
+    int result = fread(buffer, 1, 1, output);
+    pclose(output);
+    if (result > 0)
+    {
+        return GSW_HAL_SUCCESS; // 找到指定配置的hostapd进程
+    }
+    return GSW_HAL_NORMAL_FAIL; // 未找到
+}
+
+int gsw_wifi_ap_start()
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    // 强制终止所有hostapd进程(关键新增:避免残留进程占用资源)
+    execute_command("killall -9 hostapd >/dev/null 2>&1"); // 9信号强制终止
+    sleep(1);                                              // 等待进程完全退出
+
+    // 清理网络桥接接口(关键新增:避免br-lan绑定冲突)
+    char brctl_cmd[MAX_COMMAND_LEN];
+    snprintf(brctl_cmd, sizeof(brctl_cmd), "brctl delif br-lan %s >/dev/null 2>&1", WLAN_AP_DEV);
+    execute_command(brctl_cmd);
+
+    // 检查并删除残留的控制接口文件(原有逻辑保留)
+    char ctrl_path[MAX_COMMAND_LEN];
+    snprintf(ctrl_path, sizeof(ctrl_path), "%s/%s", CTRL_INTERFACE, WLAN_AP_DEV);
+    if (access(ctrl_path, F_OK) == 0)
+    {
+        if (remove(ctrl_path) != 0)
+        {
+            LOGE("Failed to remove old hostapd control interface file");
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+
+    // 启动hostapd(原有逻辑保留)
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "echo ap starting > %s ;hostapd -q %s >> %s &", HOSTAPD_LOG_PATH, HOSTAPD_CONF_PATH, HOSTAPD_LOG_PATH);
+    int status = execute_command(cmd);
+    sleep(8);
+
+    char log_buffer[1024] = {0};
+    if (read_file(HOSTAPD_LOG_PATH, log_buffer, sizeof(log_buffer)) != -1)
+    {
+        // 检查日志中是否包含关键错误信息(示例:"Failed"、"error")
+        if (strstr(log_buffer, "failed") || strstr(log_buffer, "error") || strstr(log_buffer, "wasn't started"))
+        {
+            LOGE("Hostapd start failed, check log: %s", log_buffer);
+            return GSW_HAL_NORMAL_FAIL;
+        }
+        if(is_hostapd_running() == GSW_HAL_SUCCESS)
+        {
+            LOGI("Hostapd start success");
+        }
+        else
+        {
+            LOGE("Hostapd start failed, check log: %s", log_buffer);
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        if (is_hostapd_running() != GSW_HAL_SUCCESS)
+        {
+            LOGE("Failed to read hostapd log file: %s", HOSTAPD_LOG_PATH);
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    return status;
+}
+
+// 辅助函数:判断 wpa_supplicant 服务是否起来
+int is_wpa_supplicant_running()
+{
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "ps | grep wpa_supplicant | grep -v grep");
+    FILE *output = popen(cmd, "r");
+    if (!output)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char buffer[1]; // 只需检查是否有输出,读取一个字符即可
+    int result = fread(buffer, 1, 1, output);
+    pclose(output);
+    if (result > 0)
+    {
+        return GSW_HAL_SUCCESS; // wpa_supplicant 服务存在
+    }
+    return GSW_HAL_NORMAL_FAIL; // wpa_supplicant 服务不存在
+}
+
+typedef struct
+{
+    void *arg;
+    GSW_AP_CALLBACK_FUNC_PTR gsw_cb;
+    pthread_t thread_id;
+    int running;
+} AP_Event_Context;
+
+static AP_Event_Context ap_event_context;
+int gsw_wifi_ap_stop()
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_hostapd_running() != 0)
+    {
+        LOGI("Hostapd is not running, no need to stop.\n");
+        return GSW_HAL_SUCCESS;
+    }
+
+    // 先停止事件监听线程
+    if (ap_event_context.running)
+    {
+        ap_event_context.running = 0;
+        if (ap_event_context.thread_id != 0)
+        {
+            pthread_join(ap_event_context.thread_id, NULL);
+            ap_event_context.thread_id = 0;
+        }
+    }
+
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "killall hostapd");
+    int status = execute_command(cmd);
+
+    // 关闭对应的 hostapd 后,删除对应的文件
+    char path[MAX_COMMAND_LEN];
+    snprintf(path, sizeof(path), "%s/%s", CTRL_INTERFACE, WLAN_AP_DEV);
+    if (access(path, F_OK) == 0)
+    {
+        if (remove(path) != 0)
+        {
+            LOGE("Failed to remove hostapd control interface file");
+        }
+    }
+
+    return status;
+}
+
+int gsw_wifi_ap_restart(void)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    int ret = 0;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "killall hostapd");
+    int status = execute_command(cmd);
+    LOGI("killall hostapd status = %d\n", status);
+    // 关闭对应的 hostapd 后,删除对应的文件
+    char path[MAX_COMMAND_LEN];
+    snprintf(path, sizeof(path), "%s/%s", CTRL_INTERFACE, WLAN_AP_DEV);
+    if (access(path, F_OK) == 0)
+    {
+        if (remove(path) != 0)
+        {
+            LOGE("Failed to remove hostapd control interface file");
+        }
+    }
+    ret = gsw_wifi_ap_start();
+    return ret;
+}
+
+int gsw_wifi_ap_ssid_set(char *ssid)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096] = {0};
+    char new_config[4096] = {0};
+    if (ssid == NULL) {
+        LOGE("Password cannot be NULL");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    size_t ssid_len = strlen(ssid);
+    if (ssid_len > MAX_SSID_LEN) {
+        LOGE("Password length must be 8-64 characters, current length: %zu", ssid_len);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    // 读取现有配置
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        // 如果文件不存在,创建新配置(修改默认配置内容)
+        FILE *conf = fopen(HOSTAPD_CONF_PATH, "w");
+        if (!conf)
+            return GSW_HAL_NORMAL_FAIL;
+
+        // 写入用户指定的完整默认配置
+        fprintf(conf, "ctrl_interface=%s\n", CTRL_INTERFACE);
+        fprintf(conf, "ctrl_interface_group=0\n");
+        fprintf(conf, "interface=%s\n", WLAN_AP_DEV);
+        fprintf(conf, "driver=nl80211\n");
+        fprintf(conf, "bridge=br-lan\n");
+        fprintf(conf, "ssid=%s\n", ssid); // 使用传入的ssid
+        fprintf(conf, "hw_mode=a\n");
+        fprintf(conf, "ieee80211d=1\n");
+        fprintf(conf, "channel=36\n");
+        fprintf(conf, "auth_algs=1\n");
+        fprintf(conf, "wme_enabled=1\n");
+        fprintf(conf, "noscan=0\n");
+        fprintf(conf, "beacon_int=100\n");
+        fprintf(conf, "wpa=2\n");
+        fprintf(conf, "wpa_passphrase=12345678\n");
+        fprintf(conf, "ieee80211n=1\n");
+        fprintf(conf, "ieee80211ac=1\n");
+        fprintf(conf, "ieee80211ax=1\n");
+        fprintf(conf, "vht_oper_chwidth=1\n");
+        fprintf(conf, "vht_oper_centr_freq_seg0_idx=42\n");
+        fprintf(conf, "he_oper_chwidth=1\n");
+        fprintf(conf, "he_oper_centr_freq_seg0_idx=42\n");
+        fprintf(conf, "he_basic_mcs_nss_set=65534\n");
+        fprintf(conf, "he_su_beamformee=1\n");
+        fprintf(conf, "he_twt_required=0\n");
+        fprintf(conf, "vht_capab=[SHORT-GI-80][VHT40+][VHT40-][MAX-A-MPDU-LEN-EXP7][RX-STBC-1][RX-LDPC]\n");
+        fprintf(conf, "ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+][HT40-][LDPC][RX-STBC1]\n");
+        fprintf(conf, "wpa_key_mgmt=WPA-PSK\n");
+        fprintf(conf, "rsn_pairwise=CCMP\n");
+        fprintf(conf, "wpa_pairwise=CCMP\n");
+        fprintf(conf, "ignore_broadcast_ssid=0\n");
+        fprintf(conf, "country_code=CN\n");
+        fprintf(conf, "max_num_sta=32\n");
+        fprintf(conf, "macaddr_acl=0\n");
+        fprintf(conf, "deny_mac_file=/etc/wifi/hostapd.deny\n");
+        fprintf(conf, "accept_mac_file=/etc/wifi/hostapd.accept\n");
+        fprintf(conf, "sae_pwe=2\n");
+
+        fclose(conf);
+        return GSW_HAL_SUCCESS;
+    }
+
+    // 处理每一行(新增ctrl_interface和ctrl_interface_group的检查)
+    char *line = strtok(buffer, "\n");
+    int ssid_processed = 0; // 标记是否已处理过ssid行
+    while (line)
+    {
+        if (!ssid_processed && strncmp(line, "ssid=", 5) == 0)
+        {
+            char ssid_line[64];
+            snprintf(ssid_line, sizeof(ssid_line), "ssid=%s", ssid);
+            strcat(new_config, ssid_line);
+            strcat(new_config, "\n");
+            ssid_processed = 1;
+            line = strtok(NULL, "\n");
+            continue;
+        }
+        else if (strncmp(line, "ssid=", 5) == 0)
+        {
+            line = strtok(NULL, "\n");
+            continue;
+        }
+        else if (strncmp(line, "ctrl_interface=", 15) == 0)
+        {
+            char ctrl_line[128];
+            snprintf(ctrl_line, sizeof(ctrl_line), "ctrl_interface=%s", CTRL_INTERFACE);
+            strcat(new_config, ctrl_line);
+            strcat(new_config, "\n");
+        }
+        else if (strncmp(line, "ctrl_interface_group=", 21) == 0)
+        {
+            char ctrl_group_line[64];
+            snprintf(ctrl_group_line, sizeof(ctrl_group_line), "ctrl_interface_group=0");
+            strcat(new_config, ctrl_group_line);
+            strcat(new_config, "\n");
+        }
+        else
+        {
+            strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        line = strtok(NULL, "\n");
+    }
+
+    if (!ssid_processed)
+    {
+        char ssid_line[64];
+        snprintf(ssid_line, sizeof(ssid_line), "ssid=%s\n", ssid);
+        strcat(new_config, ssid_line);
+    }
+
+    return write_file(HOSTAPD_CONF_PATH, new_config);
+}
+
+int gsw_wifi_ap_ssid_get(char *ssid)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[1024] = {0};
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char *ssid_line = strstr(buffer, "ssid=");
+    if (ssid_line)
+    {
+        ssid_line += 5; // 跳过 "ssid="
+        char *end = strchr(ssid_line, '\n');
+        if (end)
+            *end = '\0';
+        strncpy(ssid, ssid_line, MAX_SSID_LEN);
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_ap_frequency_set(int gsw_wifi_frequency)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096] = {0};
+    char new_config[4096] = {0};
+
+    gsw_wifi_bandwidth_type_e gsw_wifi_bandwidth;
+    gsw_wifi_ap_bandwidth_get(&gsw_wifi_bandwidth);
+    if (gsw_wifi_bandwidth == GSW_WIFI_BANDWIDTH_HT80 && gsw_wifi_frequency == 1)
+    {
+        LOGE("HT80 cannot be set to 2.4G");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    // 读取现有配置
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 处理每一行
+    char *line = strtok(buffer, "\n");
+    while (line)
+    {
+        // 如果是hw_mode行,替换为新值
+        if (strstr(line, "hw_mode=") != NULL)
+        {
+            char mode_line[32];
+            snprintf(mode_line, sizeof(mode_line), "hw_mode=%c", gsw_wifi_frequency == 1 ? 'g' : 'a');
+            strcat(new_config, mode_line);
+        }
+        else
+        {
+            strcat(new_config, line);
+        }
+        strcat(new_config, "\n");
+        line = strtok(NULL, "\n");
+    }
+
+    // 如果没有找到hw_mode行,添加新的设置
+    if (strstr(new_config, "hw_mode=") == NULL)
+    {
+        char mode_line[32];
+        snprintf(mode_line, sizeof(mode_line), "hw_mode=%c\n", gsw_wifi_frequency == 1 ? 'g' : 'a');
+        strcat(new_config, mode_line);
+    }
+
+    // 写回文件
+    return write_file(HOSTAPD_CONF_PATH, new_config);
+}
+
+int gsw_wifi_ap_frequency_get(int *gsw_wifi_frequency)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[1024] = {0};
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char *mode_line = strstr(buffer, "hw_mode=");
+    if (mode_line)
+    {
+        mode_line += 8; // 跳过 "hw_mode="
+        *gsw_wifi_frequency = (mode_line[0] == 'g') ? 1 : 2;
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_ap_bandwidth_set(gsw_wifi_bandwidth_type_e bandwidth)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096] = {0};
+    char new_config[4096] = {0};
+
+    int current_freq;
+    if (gsw_wifi_ap_frequency_get(&current_freq) != 0)
+    {
+        LOGI("Failed to get current frequency\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    if (current_freq == 1 && bandwidth == GSW_WIFI_BANDWIDTH_HT80) // 1表示2.4GHz
+    {
+        LOGI("2.4GHz band does not support 80MHz bandwidth");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    // 读取现有配置
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+        return GSW_HAL_NORMAL_FAIL;
+
+    // 定义各带宽类型对应的替换规则(新增三个参数)
+    const char *ht_capab = NULL;
+    const char *vht_capab = NULL;
+    const char *vht_oper_chwidth = NULL;
+    const char *he_oper_chwidth = NULL;
+    int vht_oper_centr_freq_seg0_idx_val = 0;
+    int he_oper_centr_freq_seg0_idx_val = 0;
+    int he_su_beamformee_val = 0;
+
+    // 根据带宽类型初始化替换值(补充新增参数逻辑)
+    switch (bandwidth)
+    {
+    case GSW_WIFI_BANDWIDTH_HT20:
+        ht_capab = "ht_capab=[HT20][SHORT-GI-20][LDPC][RX-STBC1]";
+        vht_capab = "vht_capab=[VHT20][SHORT-GI-20][MAX-A-MPDU-LEN-EXP7]";
+        vht_oper_chwidth = "vht_oper_chwidth=0";
+        he_oper_chwidth = "he_oper_chwidth=0";
+        vht_oper_centr_freq_seg0_idx_val = 0;
+        he_oper_centr_freq_seg0_idx_val = 0;
+        he_su_beamformee_val = 0;
+        break;
+    case GSW_WIFI_BANDWIDTH_HT40:
+        ht_capab = "ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+][HT40-][LDPC][RX-STBC1]";
+        vht_capab = "vht_capab=[SHORT-GI-80][VHT40+][VHT40-][MAX-A-MPDU-LEN-EXP7][RX-STBC-1][RX-LDPC]";
+        vht_oper_chwidth = "vht_oper_chwidth=0";
+        he_oper_chwidth = "he_oper_chwidth=0";
+        vht_oper_centr_freq_seg0_idx_val = 0;
+        he_oper_centr_freq_seg0_idx_val = 0;
+        he_su_beamformee_val = 0;
+        break;
+    case GSW_WIFI_BANDWIDTH_HT80:
+        ht_capab = "ht_capab=[HT20][HT40+][HT40-][SHORT-GI-40][LDPC][RX-STBC1]";
+        vht_capab = "vht_capab=[VHT40][VHT80][SHORT-GI-80][MAX-A-MPDU-LEN-EXP7]";
+        vht_oper_chwidth = "vht_oper_chwidth=1";
+        he_oper_chwidth = "he_oper_chwidth=1";
+        vht_oper_centr_freq_seg0_idx_val = 42;
+        he_oper_centr_freq_seg0_idx_val = 42;
+        he_su_beamformee_val = 1;
+        break;
+    default:
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 新增标记:确保只处理第一个ht_capab行
+    int ht_capab_processed = 0;
+
+    // 逐行处理配置文件(增加新增参数的匹配)
+    char *line = strtok(buffer, "\n");
+    while (line)
+    {
+        // 处理ht_capab行(仅替换第一个以"ht_capab="开头的行)
+        if (!ht_capab_processed && strncmp(line, "ht_capab=", 9) == 0)
+        {
+            if (ht_capab)
+            {
+                strcat(new_config, ht_capab);
+                ht_capab_processed = 1; // 标记已处理
+            }
+            else
+            {
+                strcat(new_config, line);
+            }
+            strcat(new_config, "\n");
+            line = strtok(NULL, "\n");
+            continue;
+        }
+        else if (strncmp(line, "ht_capab=", 9) == 0)
+        {
+            line = strtok(NULL, "\n");
+            continue;
+        }
+        else if (strncmp(line, "vht_oper_centr_freq_seg0_idx=", 25) == 0)
+        {
+            char vht_centr_line[64];
+            snprintf(vht_centr_line, sizeof(vht_centr_line), "vht_oper_centr_freq_seg0_idx=%d", vht_oper_centr_freq_seg0_idx_val);
+            strcat(new_config, vht_centr_line);
+            strcat(new_config, "\n");
+        }
+        else if (strncmp(line, "he_oper_centr_freq_seg0_idx=", 25) == 0)
+        {
+            char he_centr_line[64];
+            snprintf(he_centr_line, sizeof(he_centr_line), "he_oper_centr_freq_seg0_idx=%d", he_oper_centr_freq_seg0_idx_val);
+            strcat(new_config, he_centr_line);
+            strcat(new_config, "\n");
+        }
+        else if (strncmp(line, "he_su_beamformee=", 17) == 0)
+        {
+            char he_beam_line[32];
+            snprintf(he_beam_line, sizeof(he_beam_line), "he_su_beamformee=%d", he_su_beamformee_val);
+            strcat(new_config, he_beam_line);
+            strcat(new_config, "\n");
+        }
+        else if (strncmp(line, "vht_capab=", 10) == 0)
+        {
+            if (vht_capab)
+                strcat(new_config, vht_capab);
+            else
+                strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        else if (strncmp(line, "vht_oper_chwidth=", 17) == 0)
+        {
+            if (vht_oper_chwidth)
+                strcat(new_config, vht_oper_chwidth);
+            else
+                strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        else if (strncmp(line, "he_oper_chwidth=", 16) == 0)
+        {
+            if (he_oper_chwidth)
+                strcat(new_config, he_oper_chwidth);
+            else
+                strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        else
+        {
+            strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        line = strtok(NULL, "\n");
+    }
+
+    // 如果原文件无ht_capab行,补充新行(保持原有逻辑)
+    if (!ht_capab_processed && ht_capab)
+    {
+        strcat(new_config, ht_capab);
+        strcat(new_config, "\n");
+    }
+
+    // 检查vht_oper_centr_freq_seg0_idx是否已处理
+    if (!strstr(new_config, "vht_oper_centr_freq_seg0_idx="))
+    {
+        char vht_centr_line[64];
+        snprintf(vht_centr_line, sizeof(vht_centr_line), "vht_oper_centr_freq_seg0_idx=%d\n", vht_oper_centr_freq_seg0_idx_val);
+        strcat(new_config, vht_centr_line);
+    }
+    // 检查he_oper_centr_freq_seg0_idx是否已处理
+    if (!strstr(new_config, "he_oper_centr_freq_seg0_idx="))
+    {
+        char he_centr_line[64];
+        snprintf(he_centr_line, sizeof(he_centr_line), "he_oper_centr_freq_seg0_idx=%d\n", he_oper_centr_freq_seg0_idx_val);
+        strcat(new_config, he_centr_line);
+    }
+    // 检查he_su_beamformee是否已处理
+    if (!strstr(new_config, "he_su_beamformee="))
+    {
+        char he_beam_line[32];
+        snprintf(he_beam_line, sizeof(he_beam_line), "he_su_beamformee=%d\n", he_su_beamformee_val);
+        strcat(new_config, he_beam_line);
+    }
+
+    return write_file(HOSTAPD_CONF_PATH, new_config);
+}
+
+
+int gsw_wifi_ap_bandwidth_get(gsw_wifi_bandwidth_type_e *bandwidth)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[1024] = {0};
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 精确解析ht_capab参数
+    char *ht_line = strstr(buffer, "ht_capab=");
+    char *vht_line = strstr(buffer, "vht_capab=");
+    char *vht_width = strstr(buffer, "vht_oper_chwidth=1");
+
+    // 优先检查80MHz配置
+    if (vht_width && vht_line && strstr(vht_line, "VHT80"))
+    {
+        *bandwidth = GSW_WIFI_BANDWIDTH_HT80;
+    }
+    else if (ht_line && strstr(ht_line, "HT40+"))
+    {
+        *bandwidth = GSW_WIFI_BANDWIDTH_HT40;
+    }
+    else
+    {
+        *bandwidth = GSW_WIFI_BANDWIDTH_HT20;
+    }
+
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_ap_channel_set(int channel)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    // 新增频率和信道校验
+    int current_freq;
+    if (gsw_wifi_ap_frequency_get(&current_freq) != 0)
+    {
+        LOGE("Failed to get current frequency\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    // 定义各频段支持的信道范围
+    const int valid_2g_channels[] = VALID_2G_CHANNELS;
+    const int valid_5g_channels[] = VALID_5G_CHANNELS;
+
+    int valid = 0;
+    if (current_freq == 1)
+    { // 2.4GHz
+        for (int i = 0; i < sizeof(valid_2g_channels) / sizeof(int); i++)
+        {
+            if (channel == valid_2g_channels[i])
+            {
+                valid = 1;
+                break;
+            }
+        }
+    }
+    else
+    { // 5GHz
+        for (int i = 0; i < sizeof(valid_5g_channels) / sizeof(int); i++)
+        {
+            if (channel == valid_5g_channels[i])
+            {
+                valid = 1;
+                break;
+            }
+        }
+    }
+
+    if (!valid && channel != 0)
+    { // 允许0表示自动选择
+        LOGI("Invalid channel %d for %s band\n",
+             channel, (current_freq == 1) ? "2.4GHz" : "5GHz");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 修改为读取整个文件并替换channel行
+    char buffer[4096] = {0};
+    char new_config[4096] = {0};
+    int noscan_set = 0; // 新增:标记是否已处理noscan行
+
+    // 读取现有配置
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 处理每一行
+    char *line = strtok(buffer, "\n");
+    while (line)
+    {
+        // 新增:处理noscan行
+        if (strstr(line, "noscan=") != NULL)
+        {
+            char noscan_line[32];
+            snprintf(noscan_line, sizeof(noscan_line), "noscan=%d", (channel == 0) ? 0 : 1);
+            strcat(new_config, noscan_line);
+            strcat(new_config, "\n");
+            noscan_set = 1;
+        }
+        // 如果是channel行,替换为新值
+        else if (strstr(line, "channel=") != NULL)
+        {
+            char channel_line[32];
+            snprintf(channel_line, sizeof(channel_line), "channel=%d", channel);
+            strcat(new_config, channel_line);
+            strcat(new_config, "\n");
+        }
+        // 其他行保持不变
+        else
+        {
+            strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        line = strtok(NULL, "\n");
+    }
+
+    // 如果没有找到channel行,添加新的channel设置
+    if (strstr(new_config, "channel=") == NULL)
+    {
+        char channel_line[32];
+        snprintf(channel_line, sizeof(channel_line), "channel=%d\n", channel);
+        strcat(new_config, channel_line);
+    }
+
+    // 新增:如果没有找到noscan行,根据channel值补充
+    if (!noscan_set)
+    {
+        char noscan_line[32];
+        snprintf(noscan_line, sizeof(noscan_line), "noscan=%d\n", (channel == 0) ? 0 : 1);
+        strcat(new_config, noscan_line);
+    }
+
+    // 写回文件
+    return write_file(HOSTAPD_CONF_PATH, new_config);
+}
+
+
+int gsw_wifi_ap_channel_get(int *channel)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (channel == NULL)
+    {
+        LOGI("channel is NULL\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char buffer[1024] = {0};
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char *channel_line = strstr(buffer, "channel=");
+    if (channel_line)
+    {
+        channel_line += 8; // 跳过 "channel="
+        *channel = atoi(channel_line);
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_ap_auth_set(gsw_wifi_auth_e auth)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096] = {0};
+    char new_config[4096] = {0};
+    int wpa_set = 0, key_mgmt_set = 0, wpa_pairwise_set = 0, rsn_pairwise_set = 0, ieee80211w_set = 0, auth_algs_set = 0;
+
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    char *line = strtok(buffer, "\n");
+    while (line)
+    {
+        // 匹配行首为"wpa="的行(长度4)
+        if (strncmp(line, "wpa=", 4) == 0)
+        {
+            char wpa_line[32];
+            if (auth == GSW_WIFI_AUTH_OPEN || auth == GSW_WIFI_AUTH_WEP)
+                snprintf(wpa_line, sizeof(wpa_line), "wpa=%d", 0);
+            else if (auth == GSW_WIFI_AUTH_WPA_PSK)
+                snprintf(wpa_line, sizeof(wpa_line), "wpa=%d", 1);
+            else if (auth == GSW_WIFI_AUTH_WPA2_PSK)
+            {
+                snprintf(wpa_line, sizeof(wpa_line), "wpa=%d", 3);
+            }
+            else if (auth == GSW_WIFI_AUTH_WPA3_PSK)
+                snprintf(wpa_line, sizeof(wpa_line), "wpa=%d", 2);
+            else
+                snprintf(wpa_line, sizeof(wpa_line), "wpa=%d", 2);
+            strcat(new_config, wpa_line);
+            strcat(new_config, "\n");
+            wpa_set = 1;
+        }
+        else if (strncmp(line, "wpa_key_mgmt=", 13) == 0)
+        {
+            const char *key_mgmt = (auth == GSW_WIFI_AUTH_WPA3_PSK) ? "SAE WPA-PSK" : "WPA-PSK";
+            char key_mgmt_line[64];
+            snprintf(key_mgmt_line, sizeof(key_mgmt_line), "wpa_key_mgmt=%s", key_mgmt);
+            strcat(new_config, key_mgmt_line);
+            strcat(new_config, "\n");
+            key_mgmt_set = 1;
+        }
+        else if (strncmp(line, "auth_algs=", 9) == 0)
+        {
+            char auth_algs_line[32];
+            snprintf(auth_algs_line, sizeof(auth_algs_line), "auth_algs=%d", (auth == GSW_WIFI_AUTH_WEP) ? 3 : 1);
+            strcat(new_config, auth_algs_line);
+            strcat(new_config, "\n");
+            auth_algs_set = 1;
+        }
+        else if (strncmp(line, "wpa_pairwise=", 13) == 0)
+        {
+            const char *pairwise = NULL;
+            if (auth == GSW_WIFI_AUTH_WPA_PSK)
+                pairwise = "TKIP";
+            else if (auth == GSW_WIFI_AUTH_WPA2_PSK)
+                pairwise = "TKIP CCMP";
+            else if (auth == GSW_WIFI_AUTH_WPA3_PSK)
+                pairwise = "CCMP";
+            else
+                pairwise = "TKIP CCMP";
+            char pairwise_line[64];
+            snprintf(pairwise_line, sizeof(pairwise_line), "wpa_pairwise=%s", pairwise);
+            strcat(new_config, pairwise_line);
+            strcat(new_config, "\n");
+            wpa_pairwise_set = 1;
+        }
+        else if (strncmp(line, "rsn_pairwise=", 13) == 0)
+        {
+            if (auth == GSW_WIFI_AUTH_WPA2_PSK || auth == GSW_WIFI_AUTH_WPA3_PSK)
+            {
+                strcat(new_config, "rsn_pairwise=CCMP\n");
+            }
+            rsn_pairwise_set = 1;
+        }
+        else if (strncmp(line, "ieee80211w=", 11) == 0)
+        {
+            if (auth == GSW_WIFI_AUTH_WPA3_PSK)
+            {
+                strcat(new_config, "ieee80211w=2\n"); // WPA3 强制 MFP
+                ieee80211w_set = 1;
+            }
+            else if (auth == GSW_WIFI_AUTH_WPA2_PSK)
+            {
+                strcat(new_config, "ieee80211w=1\n"); // WPA2 可选 MFP
+                ieee80211w_set = 1;
+            }
+            // 其他模式不添加该行(直接跳过)
+        }
+        else
+        {
+            strcat(new_config, line);
+            strcat(new_config, "\n");
+        }
+        line = strtok(NULL, "\n");
+    }
+
+    // 补全未匹配的配置项
+    if (!wpa_set)
+    {
+        if (auth == GSW_WIFI_AUTH_OPEN || auth == GSW_WIFI_AUTH_WEP)
+            strcat(new_config, "wpa=0");
+        else if (auth == GSW_WIFI_AUTH_WPA_PSK)
+            strcat(new_config, "wpa=1");
+        else if (auth == GSW_WIFI_AUTH_WPA2_PSK)
+        {
+            strcat(new_config, "wpa=3");
+        }
+        else if (auth == GSW_WIFI_AUTH_WPA3_PSK)
+            strcat(new_config, "wpa=2");
+        else
+            strcat(new_config, "wpa=2");
+        strcat(new_config, "\n");
+    }
+    if (!key_mgmt_set)
+    {
+        const char *key_mgmt = (auth == GSW_WIFI_AUTH_WPA3_PSK) ? "WPA-PSK SAE" : "WPA-PSK";
+        strcat(new_config, "wpa_key_mgmt=");
+        strcat(new_config, key_mgmt);
+        strcat(new_config, "\n");
+    }
+    if (!auth_algs_set)
+    {
+        char auth_algs_line[32];
+        snprintf(auth_algs_line, sizeof(auth_algs_line), "auth_algs=%d\n", (auth == GSW_WIFI_AUTH_WEP) ? 3 : 1);
+        strcat(new_config, auth_algs_line);
+    }
+    if (!wpa_pairwise_set)
+    {
+        const char *pairwise = NULL;
+        if (auth == GSW_WIFI_AUTH_WPA_PSK)
+            pairwise = "TKIP";
+        else if (auth == GSW_WIFI_AUTH_WPA2_PSK)
+            pairwise = "TKIP CCMP";
+        else if (auth == GSW_WIFI_AUTH_WPA3_PSK)
+            pairwise = "CCMP";
+        else
+            pairwise = "TKIP CCMP";
+        strcat(new_config, "wpa_pairwise=");
+        strcat(new_config, pairwise);
+        strcat(new_config, "\n");
+    }
+    if (!rsn_pairwise_set)
+    {
+        if (auth == GSW_WIFI_AUTH_WPA2_PSK || auth == GSW_WIFI_AUTH_WPA3_PSK)
+        {
+            strcat(new_config, "rsn_pairwise=CCMP\n");
+        }
+    }
+    if (!ieee80211w_set && (auth == GSW_WIFI_AUTH_WPA3_PSK || auth == GSW_WIFI_AUTH_WPA2_PSK))
+    {
+        // 仅当需要时补全 ieee80211w 行(其他模式不添加)
+        strcat(new_config, (auth == GSW_WIFI_AUTH_WPA3_PSK) ? "ieee80211w=2\n" : "ieee80211w=1\n");
+    }
+
+    return write_file(HOSTAPD_CONF_PATH, new_config);
+}
+
+int gsw_wifi_ap_auth_get(gsw_wifi_auth_e *auth)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[1024] = {0};
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    char *auth_algs_line = strstr(buffer, "auth_algs=");
+    if (auth_algs_line)
+    {
+        auth_algs_line += 10; // 跳过 "auth_algs="
+        int auth_algs_val = atoi(auth_algs_line);
+        if (auth_algs_val == 3)
+        {
+            *auth = GSW_WIFI_AUTH_WEP;
+            return GSW_HAL_SUCCESS;
+        }
+    }
+    // 优先通过 wpa_key_mgmt 判断 WPA3(包含 SAE 关键字)
+    char *key_mgmt_line = strstr(buffer, "wpa_key_mgmt=");
+    if (key_mgmt_line)
+    {
+        key_mgmt_line += 12; // 跳过 "wpa_key_mgmt="
+        if (strstr(key_mgmt_line, "SAE"))
+        {
+            *auth = GSW_WIFI_AUTH_WPA3_PSK;
+            return GSW_HAL_SUCCESS;
+        }
+    }
+
+    // 若未找到 SAE,再通过 wpa= 判断 WPA2 或开放模式
+    char *wpa_line = strstr(buffer, "wpa=");
+    if (wpa_line)
+    {
+        wpa_line += 4;
+        int wpa_val = atoi(wpa_line);
+        if(wpa_val > 1)
+        {
+            *auth = GSW_WIFI_AUTH_WPA2_PSK;
+        }
+        else if (wpa_val == 1)
+        {
+            *auth = GSW_WIFI_AUTH_WPA_PSK;
+        }
+        else
+        {
+            *auth = GSW_WIFI_AUTH_OPEN;
+        }
+    }
+    else
+    {
+        *auth = GSW_WIFI_AUTH_OPEN; // 默认开放模式
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_ap_password_set(char *password)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096] = {0};
+    char new_config[4096] = {0};
+    int has_passphrase = 0; // 标记是否已处理过密码行
+    if (password == NULL) {
+        LOGE("Password cannot be NULL");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    size_t pass_len = strlen(password);
+    if (pass_len < MIN_PASSWORD_LEN || pass_len > MAX_PASSWORD_LEN) {
+        LOGE("Password length must be 8-63 characters, current length: %zu", pass_len);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    // 读取现有配置文件内容
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 逐行处理配置文件(修改:增加密码行存在标记)
+    char *line = strtok(buffer, "\n");
+    while (line)
+    {
+        // 匹配到原密码行时替换为新密码,并标记已处理
+        if (strstr(line, "wpa_passphrase=") != NULL)
+        {
+            char new_pass_line[128];
+            snprintf(new_pass_line, sizeof(new_pass_line), "wpa_passphrase=%s", password);
+            strcat(new_config, new_pass_line);
+            has_passphrase = 1; // 标记存在密码行
+        }
+        else
+        {
+            strcat(new_config, line);
+        }
+        strcat(new_config, "\n"); // 保留换行符
+        line = strtok(NULL, "\n");
+    }
+
+    // 若原文件无密码行,添加新密码行到末尾
+    if (!has_passphrase)
+    {
+        char new_pass_line[128];
+        snprintf(new_pass_line, sizeof(new_pass_line), "wpa_passphrase=%s\n", password);
+        strcat(new_config, new_pass_line);
+    }
+
+    // 写回配置文件
+    return write_file(HOSTAPD_CONF_PATH, new_config);
+}
+
+int gsw_wifi_ap_password_get(char *password)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096] = {0}; // 使用更大的缓冲区
+    if (read_file(HOSTAPD_CONF_PATH, buffer, sizeof(buffer)) == -1)
+    {
+        LOGI("Failed to read hostapd config file\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 查找密码行
+    char *passphrase_line = strstr(buffer, "wpa_passphrase=");
+    if (!passphrase_line)
+    {
+        LOGI("No password line found in config\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    passphrase_line += 15; // 跳过 "wpa_passphrase="
+
+    // 查找行结束位置
+    char *end = strchr(passphrase_line, '\n');
+    if (end)
+    {
+        *end = '\0'; // 确保字符串正确终止
+    }
+
+    // 检查密码长度是否合法
+    size_t pass_len = strlen(passphrase_line);
+    if (pass_len == 0 || pass_len >= MAX_PASSWORD_LEN)
+    {
+        LOGI("Invalid password length: %zu\n", pass_len);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    // 复制密码
+    strncpy(password, passphrase_line, MAX_PASSWORD_LEN);
+    password[MAX_PASSWORD_LEN] = '\0'; // 确保终止
+
+    return GSW_HAL_SUCCESS;
+}
+
+/**
+ * @brief 获取 AP 模式的运行状态
+ * @param [out] ap_status 用于存储 AP 模式运行状态的指针
+ * @retval 0 表示函数执行成功
+ */
+int gsw_wifi_get_ap_status(gsw_wifi_ap_run_status_e *ap_status)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    int result = is_hostapd_running();
+    if (result == 0)
+    {
+        *ap_status = GSW_WIFI_AP_STATUS_ENABLE;
+    }
+    else
+    {
+        *ap_status = GSW_WIFI_AP_STATUS_DISABLE;
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+/* STA 模式相关函数实现 */
+
+// 辅助函数:更新 wpa_supplicant 配置文件
+int update_wpa_supplicant_conf()
+{
+    char new_config[4096] = {0};
+
+    // 直接写入必需配置项(覆盖原有文件),新增WPA3支持的关键配置
+    const char *required_configs[] = {
+        "ctrl_interface=/var/run/wpa_supplicant", // 接口路径
+        "ctrl_interface_group=root",              // 组设置
+        "update_config=1",                        // 允许自动更新配置
+        "ap_scan=1",                              // 主动扫描AP
+        // 网络块配置调整:使用数值19表示SAE组(替代SUITE_B_192文本标识)
+        "network={\n  key_mgmt=SAE\n  pairwise=CCMP\n  ieee80211w=2\n }"
+    };
+    int config_count = sizeof(required_configs) / sizeof(required_configs[0]);
+
+    // 添加所有必需的配置项(确保顺序)
+    for (int i = 0; i < config_count; i++)
+    {
+        strcat(new_config, required_configs[i]);
+        strcat(new_config, "\n");
+    }
+
+    // 写回文件(完全覆盖)
+    return write_file(WPA_SUPPLICANT_CONF_PATH, new_config);
+}
+
+int gsw_wifi_sta_start()
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    // 更新 wpa_supplicant 配置文件
+    if (update_wpa_supplicant_conf() != 0)
+    {
+        LOGI("Failed to update wpa_supplicant configuration file.\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_supplicant -Dnl80211 -i%s -c%s -B", WLAN_STA_DEV, WPA_SUPPLICANT_CONF_PATH);
+    int status = execute_command(cmd);
+    sleep(5);
+    memset(cmd, 0, sizeof(cmd));
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan > /dev/null", WLAN_STA_DEV);
+    execute_command(cmd);
+    memset(cmd, 0, sizeof(cmd));
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan_results > /dev/null", WLAN_STA_DEV);
+    execute_command(cmd);
+    return status;
+}
+
+int gsw_wifi_sta_stop()
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        LOGI("wpa_supplicant is not running, no need to stop.\n");
+        return GSW_HAL_SUCCESS;
+    }
+
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "killall wpa_supplicant");
+    return execute_command(cmd);
+}
+
+int gsw_wifi_get_sta_status(gsw_wifi_sta_run_status_e *sta_status)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() == 0)
+    {
+        *sta_status = GSW_WIFI_STA_STATUS_ENABLE;
+    }
+    else
+    {
+        *sta_status = GSW_WIFI_STA_STATUS_DISABLE;
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+// 修改涉及 wpa_cli 命令的函数
+int gsw_wifi_get_sta_ssid(char *sta_ssid)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s status | grep 'ssid=' | cut -d '=' -f 2", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[MAX_SSID_LEN + 1];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    strncpy(sta_ssid, buffer, MAX_SSID_LEN);
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_sta_auth(gsw_wifi_auth_e *auth)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        LOGI("wpa_supplicant is not running.\n");
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    // 修改命令,获取 key_mgmt 字段
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s status | grep 'key_mgmt=' | cut -d '=' -f 2", WLAN_STA_DEV);
+    LOGI("Executing command: %s\n", cmd);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+    {
+        LOGI("Failed to execute command: %s\n", cmd);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char buffer[32];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        LOGI("No output from command: %s\n", cmd);
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    LOGI("Command output: %s\n", buffer);
+
+    if (strstr(buffer, "WPA2-PSK"))
+    {
+        *auth = GSW_WIFI_AUTH_WPA2_PSK;
+    }
+    else if (strstr(buffer, "WPA-PSK"))
+    {
+        *auth = GSW_WIFI_AUTH_WPA_PSK;
+    }
+    else if (strstr(buffer, "SAE"))
+    {
+        *auth = GSW_WIFI_AUTH_WPA3_PSK;
+    }
+    else if (strstr(buffer, "NONE"))
+    {
+        *auth = GSW_WIFI_AUTH_OPEN;
+    }
+    else
+    {
+        LOGI("Unknown authentication type: %s. Assuming WPA2-PSK.\n", buffer);
+        *auth = GSW_WIFI_AUTH_WPA2_PSK;
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_sta_connect(char *ssid, gsw_wifi_auth_e auth, char *password)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+
+    char quoted_ssid[MAX_SSID_LEN + 3]; // 为引号和字符串结尾留空间
+    char quoted_password[MAX_PASSWORD_LEN + 3];
+
+    // 添加引号
+    snprintf(quoted_ssid, sizeof(quoted_ssid), "\\\"%s\\\"", ssid);
+    if (auth != GSW_WIFI_AUTH_OPEN)
+    {
+        snprintf(quoted_password, sizeof(quoted_password), "\\\"%s\\\"", password);
+    }
+
+    LOGI("SSID = %s\n", quoted_ssid);
+
+    char cmd[MAX_COMMAND_LEN];
+    int status;
+
+    // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s remove_network 0", WLAN_STA_DEV);
+    LOGI("Executing command type: Remove network\n");
+    status = execute_command(cmd);
+    if (status != 0)
+    {
+        return status;
+    }
+
+    // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s ap_scan 1", WLAN_STA_DEV);
+    LOGI("Executing command type: Set AP scan\n");
+    status = execute_command(cmd);
+    if (status != 0)
+    {
+        return status;
+    }
+
+    // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s add_network", WLAN_STA_DEV);
+    LOGI("Executing command type: Add network\n");
+    status = execute_command(cmd);
+    if (status != 0)
+    {
+        return status;
+    }
+
+    // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 ssid %s", WLAN_STA_DEV, quoted_ssid);
+    LOGI("Executing command type: Set SSID\n");
+    status = execute_command(cmd);
+    if (status != 0)
+    {
+        return status;
+    }
+
+    if (auth != GSW_WIFI_AUTH_OPEN)
+    {
+        const char *key_mgmt;
+        switch (auth)
+        {
+        case GSW_WIFI_AUTH_WEP:
+            key_mgmt = "NONE";
+            // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+            snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 wep_key0 %s", WLAN_STA_DEV, quoted_password);
+            LOGI("Executing command type: Set WEP key\n");
+            status = execute_command(cmd);
+            if (status != 0)
+                return status;
+
+            // 修改:-p 改为 -i 并使用 WLAN_STA_DEV(注意原代码中可能存在拼写错误 "weep_tx_keyidx" 应为 "wep_tx_keyidx")
+            snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 wep_tx_keyidx 0", WLAN_STA_DEV);
+            LOGI("Executing command type: Set WEP TX key index\n");
+            status = execute_command(cmd);
+            if (status != 0)
+                return status;
+            break;
+
+        case GSW_WIFI_AUTH_WPA_PSK:
+            key_mgmt = "WPA-PSK";
+            break;
+        case GSW_WIFI_AUTH_WPA2_PSK:
+            key_mgmt = "WPA-PSK";
+            break;
+        case GSW_WIFI_AUTH_WPA3_PSK:
+            key_mgmt = "SAE";
+            break;
+        default:
+            key_mgmt = "WPA-PSK";
+            break;
+        }
+
+        if (auth != GSW_WIFI_AUTH_WEP)
+        {
+            // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+            snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 key_mgmt %s", WLAN_STA_DEV, key_mgmt);
+            LOGI("Executing command type: Set key management\n");
+            status = execute_command(cmd);
+            if (status != 0)
+                return status;
+
+            if (auth == GSW_WIFI_AUTH_WPA3_PSK)
+            {
+                // WPA3 特有配置:确保在设置key_mgmt后配置SAE参数
+                // 设置椭圆曲线组(使用NIST P-256,组号19)
+                snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 sae_groups 19", WLAN_STA_DEV);
+                status = execute_command(cmd);
+                if (status != 0)
+                    return status;
+
+                // 强制MFP保护(WPA3要求必须启用)
+                snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 sae_require_mfp 1", WLAN_STA_DEV);
+                status = execute_command(cmd);
+                if (status != 0)
+                    return status;
+
+                // 使用SAE+CCMP加密组合(确保与AP端匹配)
+                snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 pairwise CCMP", WLAN_STA_DEV);
+                status = execute_command(cmd);
+                if (status != 0)
+                    return status;
+            }
+
+            // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+            snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 psk %s", WLAN_STA_DEV, quoted_password);
+            LOGI("Executing command type: Set PSK\n");
+            status = execute_command(cmd);
+            if (status != 0)
+                return status;
+        }
+    }
+    else
+    {
+        // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+        snprintf(cmd, sizeof(cmd), "wpa_cli -i %s set_network 0 key_mgmt NONE", WLAN_STA_DEV);
+        LOGI("Executing command type: Set key management for open network\n");
+        status = execute_command(cmd);
+        if (status != 0)
+            return status;
+    }
+
+    // 修改:-p 改为 -i 并使用 WLAN_STA_DEV
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s select_network 0", WLAN_STA_DEV);
+    LOGI("Executing command type: Select network\n");
+    status = execute_command(cmd);
+    if (status != 0)
+    {
+        return status;
+    }
+
+    // udhcpc 命令无需修改(已使用 WLAN_STA_DEV)
+    snprintf(cmd, sizeof(cmd), "udhcpc -i %s -n", WLAN_STA_DEV);
+    LOGI("Executing command type: Request DHCP IP\n");
+    status = execute_command(cmd);
+    return status;
+}
+
+int gsw_wifi_sta_forget_ap(char *ssid, gsw_wifi_auth_e auth)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s remove_network $(wpa_cli -i %s list_networks | grep '%s' | awk '{print $1}')", WLAN_STA_DEV, WLAN_STA_DEV, ssid);
+    return execute_command(cmd);
+}
+
+int gsw_wifi_sta_start_scan(void)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan", WLAN_STA_DEV);
+    return execute_command(cmd);
+}
+
+int gsw_wifi_get_interface_ip(gsw_wifi_index_e idx, char *ip)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "ip addr show dev %s | grep 'inet ' | awk '{print $2}' | cut -d '/' -f 1", idx == GSW_WIFI_INTERFACE_0 ? WLAN_STA_DEV : WLAN_AP_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[MAX_IP_LEN + 1];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    strncpy(ip, buffer, MAX_IP_LEN);
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_interface_mac(gsw_wifi_index_e idx, char *mac)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "ip link show dev %s | grep 'link/ether' | awk '{print $2}'", idx == GSW_WIFI_INTERFACE_0 ? WLAN_STA_DEV : WLAN_AP_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[MAX_MAC_LEN + 1];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    strncpy(mac, buffer, MAX_MAC_LEN);
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_connect_ap_mac(char *mac)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s status | grep 'bssid=' | cut -d '=' -f 2", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[MAX_MAC_LEN + 1];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    strncpy(mac, buffer, MAX_MAC_LEN);
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_connect_ap_rssi(int *rssi)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s status | grep 'signal=' | cut -d '=' -f 2", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[16];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    *rssi = atoi(buffer);
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_connect_ap_band(gsw_wifi_band_e *band)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s status | grep 'frequency=' | cut -d '=' -f 2", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[32];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    int freq = atoi(buffer);
+    if (freq < 2500)
+    {
+        *band = GSW_WIFI_2G_band;
+    }
+    else
+    {
+        *band = GSW_WIFI_5G_band;
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_connect_ap_ip(char *ip)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s status | grep 'ip_address=' | cut -d '=' -f 2", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[MAX_IP_LEN + 1];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    strncpy(ip, buffer, MAX_IP_LEN);
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_sta_available_ap(gsw_ap_detail_info_s *info)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan > /dev/null", WLAN_STA_DEV);
+    execute_command(cmd);
+    sleep(1);
+    memset(cmd, 0, sizeof(cmd));
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan_results | awk '{print $1,$2,$3,$4,$5}' | sort -k3 -nr | head -n 1", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[256];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    pclose(output);
+    buffer[strcspn(buffer, "\n")] = '\0';
+    sscanf(buffer, "%x %d %s %s %s", &info->base_info.auth, &info->rssi, info->base_info.ap_ssid, info->base_info.ap_ip, info->base_info.ap_mac);
+    info->status = GSW_WIFI_AP_STATUS_ENABLE;
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_ap_device_list(gsw_ap_info_s *ap_info, gsw_device_info_s *device_list, int len, int *dev_len)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "hostapd_cli -i %s all_sta", WLAN_AP_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096];
+    size_t length = fread(buffer, 1, sizeof(buffer) - 1, output);
+    if (length == 0)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    buffer[length] = '\0';
+    pclose(output);
+    // 解析 hostapd_cli 输出,填充 device_list
+    *dev_len = 0;
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_sta_saved_ap(gsw_saved_ap_info_s *list, int len, int *list_len)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s list_networks", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096];
+    size_t length = fread(buffer, 1, sizeof(buffer) - 1, output);
+    if (length == 0)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    buffer[length] = '\0';
+    pclose(output);
+    // 解析 wpa_cli 输出,填充 list
+    *list_len = 0;
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_get_scan_list(gsw_scan_info_s *list, int len, int *list_len)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_wpa_supplicant_running() != 0)
+    {
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan > /dev/null", WLAN_STA_DEV);
+    execute_command(cmd);
+    sleep(1);
+    memset(cmd, 0, sizeof(cmd));
+    snprintf(cmd, sizeof(cmd), "wpa_cli -i %s scan_results", WLAN_STA_DEV);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[4096];
+    size_t length = fread(buffer, 1, sizeof(buffer) - 1, output);
+    if (length == 0)
+    {
+        pclose(output);
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    buffer[length] = '\0';
+    pclose(output);
+
+    // 解析 wpa_cli 输出,填充 list
+    *list_len = 0;
+    char *line = strtok(buffer, "\n");
+    // 跳过标题行
+    if (line)
+        line = strtok(NULL, "\n");
+
+    while (line && *list_len < len)
+    {
+        gsw_scan_info_s *info = &list[*list_len];
+        int freq;        // 临时变量用于存储频率,以判断频段
+        char flags[256]; // 临时变量用于存储认证标志
+
+        // 假设输出格式为:bssid freq signal flags ssid
+        // 解析每一行数据
+        sscanf(line, "%31s %d %d %255s %32[^\n]", info->mac, &freq, &info->rssi, flags, info->ssid);
+
+        // 根据频率判断频段
+        if (freq < 2500)
+        {
+            info->band = GSW_WIFI_2G_band;
+        }
+        else
+        {
+            info->band = GSW_WIFI_5G_band;
+        }
+
+        // 根据 flags 判断认证方式
+        if (strstr(flags, "SAE") != NULL || strstr(flags, "WPA3") != NULL)
+        {
+            info->auth = GSW_WIFI_AUTH_WPA3_PSK;
+        }
+        else if (strstr(flags, "WPA2") != NULL)
+        {
+            info->auth = GSW_WIFI_AUTH_WPA2_PSK;
+        }
+        else if (strstr(flags, "WPA") != NULL)
+        {
+            info->auth = GSW_WIFI_AUTH_WPA_PSK;
+        }
+        else
+        {
+            info->auth = GSW_WIFI_AUTH_OPEN;
+        }
+
+        (*list_len)++;
+        line = strtok(NULL, "\n");
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+void *ap_event_listener(void *arg)
+{
+    char list_cmd[MAX_COMMAND_LEN];
+    snprintf(list_cmd, sizeof(list_cmd), "hostapd_cli -i %s all_sta | grep -E '^[0-9a-f:]{17}$|connected_time=' | \
+     awk '/^[0-9a-f:]{17}$/ { mac=$0; getline; if ($0 ~ /connected_time=/) print mac }'",
+             WLAN_AP_DEV);
+
+    // 保存上一次的设备MAC地址列表
+    char prev_macs[GSW_WIFI_AP_DEVICE_NUM][32] = {0};
+    int prev_count = 0;
+    while (ap_event_context.running)
+    {
+        if (is_hostapd_running() != 0)
+        {
+            sleep(5);
+            continue;
+        }
+
+        // 使用list_cmd获取当前设备MAC列表
+        char curr_macs[GSW_WIFI_AP_DEVICE_NUM][32] = {0};
+        int curr_count = 0;
+        FILE *list_output = popen(list_cmd, "r");
+        if (list_output)
+        {
+            char buffer[1024];
+            if (fread(buffer, 1, sizeof(buffer) - 1, list_output) > 0)
+            {
+                buffer[sizeof(buffer) - 1] = '\0';
+                char *line = strtok(buffer, "\n");
+                while (line && curr_count < GSW_WIFI_AP_DEVICE_NUM)
+                {
+                    if (strchr(line, ':'))
+                    {
+                        strncpy(curr_macs[curr_count], line, 17); // 复制MAC地址
+                        curr_count++;
+                    }
+                    line = strtok(NULL, "\n");
+                }
+            }
+            pclose(list_output);
+        }
+
+        // 数量变化时直接触发事件(保持原有逻辑)
+        if (curr_count > prev_count && ap_event_context.gsw_cb)
+        {
+            ap_event_context.gsw_cb(ap_event_context.arg, GSW_WIFI_STATUS_CONNECT);
+        }
+        else if (curr_count < prev_count && ap_event_context.gsw_cb)
+        {
+            ap_event_context.gsw_cb(ap_event_context.arg, GSW_WIFI_STATUS_DISCONNECT);
+        }
+        else if (curr_count == prev_count && ap_event_context.gsw_cb)
+        {
+            int mac_updated = 0;
+            // 遍历检查是否有MAC地址变化
+            for (int i = 0; i < curr_count; i++)
+            {
+                int found = 0;
+                for (int j = 0; j < prev_count; j++)
+                {
+                    if (strcasecmp(curr_macs[i], prev_macs[j]) == 0)
+                    {
+                        found = 1;
+                        break;
+                    }
+                }
+                // 发现新MAC地址(当前存在但之前不存在)
+                if (!found)
+                {
+                    LOGI("New device connected: %s\n", curr_macs[i]);
+                    mac_updated++;
+                    break;
+                }
+            }
+            // 若有更新则触发连接事件(可根据需求扩展为断开事件)
+            if (mac_updated)
+            {
+                ap_event_context.gsw_cb(ap_event_context.arg, GSW_WIFI_STATUS_DISCONNECT);
+                ap_event_context.gsw_cb(ap_event_context.arg, GSW_WIFI_STATUS_CONNECT);
+            }
+        }
+
+        memcpy(prev_macs, curr_macs, sizeof(prev_macs));
+        prev_count = curr_count;
+
+        sleep(2); // 定期轮询
+    }
+    return NULL;
+}
+
+/**
+ * @brief   register ap event notification function
+ * @param  [in] arg  as gsw_cb function parameter, can be NULL
+ * @param  [in] gsw_cb callback
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_reg_ap_event_callback(void *arg, GSW_AP_CALLBACK_FUNC_PTR gsw_cb)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (ap_event_context.running)
+    {
+        return GSW_HAL_NORMAL_FAIL; // 已经注册了回调
+    }
+    ap_event_context.arg = arg;
+    ap_event_context.gsw_cb = gsw_cb;
+    ap_event_context.running = 1;
+    if (pthread_create(&ap_event_context.thread_id, NULL, ap_event_listener, NULL) != 0)
+    {
+        ap_event_context.running = 0;
+        return GSW_HAL_NORMAL_FAIL;
+    }
+    return GSW_HAL_SUCCESS;
+}
+
+/**
+ * @brief  unregister ap callback function
+ * @param  [in] arg  reserved parameter, can be NULL
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_unreg_ap_event_callback(void *arg)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    ap_event_context.running = 0;
+
+    // 检查线程是否存在
+    if (ap_event_context.thread_id != 0)
+    {
+        if (pthread_join(ap_event_context.thread_id, NULL) != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+        ap_event_context.thread_id = 0; // 重置线程ID
+    }
+
+    ap_event_context.arg = NULL;
+    ap_event_context.gsw_cb = NULL;
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_reg_sta_event_callback(void *arg, GSW_STA_CALLBACK_FUNC_PTR gsw_cb)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_unreg_sta_event_callback(void *arg)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    return GSW_HAL_SUCCESS;
+}
+
+int gsw_wifi_sdk_interface_init()
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    return GSW_HAL_SUCCESS;
+}
+
+int is_module_loaded(const char *module_name)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    char cmd[MAX_COMMAND_LEN];
+    snprintf(cmd, sizeof(cmd), "lsmod | grep %s", module_name);
+    FILE *output = popen(cmd, "r");
+    if (!output)
+        return GSW_HAL_NORMAL_FAIL;
+    char buffer[256];
+    if (fgets(buffer, sizeof(buffer), output) == NULL)
+    {
+        pclose(output);
+        return GSW_HAL_SUCCESS;
+    }
+    pclose(output);
+    return 1;
+}
+/**
+ * @brief load wifi driver
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_enable(void)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (!is_module_loaded("cfg80211"))
+    {
+        if (execute_command("modprobe cfg80211") != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        LOGI("cfg80211 has insmod.\n");
+    }
+
+    if (!is_module_loaded("aic8800_bsp"))
+    {
+        char cmd[MAX_COMMAND_LEN];
+        snprintf(cmd, sizeof(cmd), "modprobe %s", AIC8800_BSP_DRIVER_PATH);
+        if (execute_command(cmd) != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        LOGI("aic8800_bsp has insmod.\n");
+    }
+
+    if (!is_module_loaded("aic8800_fdrv"))
+    {
+        char cmd[MAX_COMMAND_LEN];
+        snprintf(cmd, sizeof(cmd), "modprobe %s", AIC8800_FDRV_DRIVER_PATH);
+        if (execute_command(cmd) != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        LOGI("aic8800_fdrv has insmod.\n");
+    }
+
+    return GSW_HAL_SUCCESS;
+}
+
+/**
+ * @brief uninstall wifi driver
+ * @retval 0: success
+ * @retval other: fail
+ */
+int gsw_wifi_disable(void)
+{
+    if (handle())
+        return GSW_HAL_NORMAL_FAIL;
+    if (is_module_loaded("aic8800_fdrv"))
+    {
+        if (execute_command("rmmod aic8800_fdrv") != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        LOGI("aic8800_fdrv not insmod.\n");
+    }
+
+    if (is_module_loaded("aic8800_bsp"))
+    {
+        if (execute_command("rmmod aic8800_bsp") != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        LOGI("aic8800_bsp not insmod.\n");
+    }
+
+    if (is_module_loaded("cfg80211"))
+    {
+        if (execute_command("rmmod cfg80211") != 0)
+        {
+            return GSW_HAL_NORMAL_FAIL;
+        }
+    }
+    else
+    {
+        LOGI("cfg80211 not insmod.\n");
+    }
+
+    return GSW_HAL_SUCCESS;
+}
\ No newline at end of file
diff --git a/mbtk/rootfs/etc/wifi/hostapd.conf b/mbtk/rootfs/etc/wifi/hostapd.conf
index e72bfd2..a44487c 100755
--- a/mbtk/rootfs/etc/wifi/hostapd.conf
+++ b/mbtk/rootfs/etc/wifi/hostapd.conf
@@ -1,31 +1,31 @@
 ctrl_interface=/var/run/hostapd
 ctrl_interface_group=0
 interface=wlan0
-#bridge=br0
+bridge=br-lan
 ssid=mbtk
 hw_mode=a
+ieee80211d=1
 channel=36
+chanlist=1-13,36-64,149-165
 auth_algs=1
 driver=nl80211
 wme_enabled=1
+noscan=0
+beacon_int=100
 wpa=2
 wpa_passphrase=12345678
 ieee80211n=1
 ieee80211ac=1
 ieee80211ax=1
-#ieee80211w=2
 vht_oper_chwidth=1
 vht_oper_centr_freq_seg0_idx=42
-#vht_oper_centr_freq_seg1_idx=4
 he_oper_chwidth=1
 he_oper_centr_freq_seg0_idx=42
-#he_oper_centr_freq_seg1_idx=8
 he_basic_mcs_nss_set=65534
 he_su_beamformee=1
 he_twt_required=0
 vht_capab=[SHORT-GI-80][VHT40+][VHT40-][MAX-A-MPDU-LEN-EXP7][RX-STBC-1][RX-LDPC]
 ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+][HT40-][LDPC][RX-STBC1]
-#wpa_key_mgmt=SAE
 wpa_key_mgmt=WPA-PSK
 rsn_pairwise=CCMP
 ignore_broadcast_ssid=0
@@ -34,5 +34,4 @@
 macaddr_acl=0
 deny_mac_file=/etc/wifi/hostapd.deny
 accept_mac_file=/etc/wifi/hostapd.accept
-ctrl_interface=/var/run/hostapd
-
+sae_pwe=2
diff --git a/mbtk/test/libgsw_lib/gsw_wifi_test.c b/mbtk/test/libgsw_lib/gsw_wifi_test.c
new file mode 100644
index 0000000..e80c937
--- /dev/null
+++ b/mbtk/test/libgsw_lib/gsw_wifi_test.c
@@ -0,0 +1,422 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <signal.h> // Include signal header
+
+#include "gsw_wifi_interface_sdk.h"
+
+// Hostapd 和 wpa_supplicant 进程 ID
+pid_t hostapd_pid = 0;
+pid_t wpa_pid = 0;
+
+// 辅助函数:将认证类型枚举转换为字符串
+const char *auth_type_to_string(gsw_wifi_auth_e auth)
+{
+    switch (auth)
+    {
+    case GSW_WIFI_AUTH_OPEN:
+        return "OPEN";
+    case GSW_WIFI_AUTH_WEP:
+        return "WEP";
+    case GSW_WIFI_AUTH_WPA_PSK:
+        return "WPA_PSK";
+    case GSW_WIFI_AUTH_WPA2_PSK:
+        return "WPA2_PSK";
+    case GSW_WIFI_AUTH_WPA3_PSK:
+        return "WPA3_PSK";
+    // 若有其他认证类型,可继续添加 case
+    default:
+        return "Unknown";
+    }
+}
+
+void handle_ctrl_c(int sig)
+{
+    printf("\nExiting...\n");
+    gsw_wifi_sta_stop();
+    gsw_wifi_ap_stop();
+    gsw_wifi_disable();
+    exit(0);
+}
+
+// 添加AP回调函数
+void ap_event_callback(void *arg, gsw_wifi_ap_status_e status)
+{
+    if (status == GSW_WIFI_STATUS_CONNECT)
+    {
+        printf("AP mode is now running and ready for connections\n");
+    }
+    else if (status == GSW_WIFI_STATUS_DISCONNECT)
+    {
+        printf("AP mode has been stopped\n");
+    }
+}
+
+void ap_setting(void)
+{
+    int ret = 0;
+    char ssid[32] = "mtbk-test";
+    char password[64] = "12345678";
+    gsw_wifi_auth_e auth = GSW_WIFI_AUTH_WPA2_PSK;
+    int frequency = 2;
+    gsw_wifi_bandwidth_type_e bandwidth = GSW_WIFI_BANDWIDTH_HT80;
+    int channel = 0;
+    int temp_auth, temp_bandwidth;
+
+    printf("AP mode configuration:\n");
+    printf("Enter SSID (default: mtbk-test): ");
+    if (scanf("%31s", ssid) != 1)
+    {
+        strcpy(ssid, "mtbk-test");
+    }
+
+    ret = gsw_wifi_ap_ssid_set(ssid);
+    if (ret != 0)
+    {
+        printf("Failed to set SSID\n");
+        gsw_wifi_ap_ssid_set("mtbk-test");
+    }
+
+    printf("Enter password (default: 12345678): ");
+    if (scanf("%63s", password) != 1)
+    {
+        strcpy(password, "12345678");
+    }
+
+    ret = gsw_wifi_ap_password_set(password);
+    if (ret != 0)
+    {
+        printf("Failed to set password\n");
+        gsw_wifi_ap_password_set("12345678");
+    }
+
+    printf("Enter auth type (0: OPEN, 1: WEP(Only support open), 2: WPA_PSK(wifi4 and above are not supported), 3: WPA2_PSK, 4: WPA3_PSK, default: WPA2_PSK): ");
+    if (scanf("%d", &temp_auth) == 1)
+    {
+        auth = (gsw_wifi_auth_e)temp_auth;
+    }
+
+    ret = gsw_wifi_ap_auth_set(auth);
+    if (ret != 0)
+    {
+        printf("Failed to set auth type\n");
+        gsw_wifi_ap_auth_set(GSW_WIFI_AUTH_WPA2_PSK);
+    }
+
+    printf("Enter frequency (1: 2.4G, 2: 5G, default: 2): ");
+    if (scanf("%d", &frequency) != 1)
+    {
+        frequency = 2;
+    }
+
+    ret = gsw_wifi_ap_frequency_set(frequency);
+    if (ret != 0)
+    {
+        printf("Failed to set frequency\n");
+        gsw_wifi_ap_frequency_set(2);
+    }
+
+    printf("Enter bandwidth (0: HT10, 1: HT20, 2: HT40, 3: HT80, default: HT40): ");
+    if (scanf("%d", &temp_bandwidth) == 1)
+    {
+        bandwidth = (gsw_wifi_bandwidth_type_e)temp_bandwidth;
+    }
+
+    ret = gsw_wifi_ap_bandwidth_set(bandwidth);
+    if (ret != 0)
+    {
+        printf("Failed to set bandwidth\n");
+        gsw_wifi_ap_bandwidth_set(GSW_WIFI_BANDWIDTH_HT40);
+    }
+
+    printf("Enter channel (0: auto, 2.4G: 1-13, 5G: 36-165, default: 0): ");
+    if (scanf("%d", &channel) != 1)
+    {
+        channel = 0;
+    }
+
+    ret = gsw_wifi_ap_channel_set(channel);
+    if (ret != 0)
+    {
+        printf("Failed to set channel\n");
+        gsw_wifi_ap_channel_set(0);
+    }
+
+    printf("AP mode configuration set.\n");
+}
+
+int main()
+{
+    signal(SIGINT, handle_ctrl_c); // Register signal handler
+    int ret = 0;
+    gsw_wifi_ap_run_status_e ap_status;
+    // 加载 Wi-Fi 驱动并启动 AP 模式
+    if (gsw_wifi_enable() != 0)
+    {
+        printf("Failed to enable Wi-Fi driver\n");
+        return -1;
+    }
+    gsw_wifi_get_ap_status(&ap_status);
+    printf("ap status: %s\n", ap_status == GSW_WIFI_AP_STATUS_ENABLE ? "enable" : "disable");
+begin:
+    printf("Do you want to set default AP mode? (y/n): ");
+    char ap_seting;
+    if (scanf(" %c", &ap_seting) != 1)
+    {
+        printf("Error reading input\n");
+        return -1;
+    }
+
+    if (ap_seting == 'y' || ap_seting == 'Y')
+    {
+        gsw_wifi_ap_ssid_set("mtbk-测试");
+        gsw_wifi_ap_password_set("12345678");
+        gsw_wifi_ap_auth_set(GSW_WIFI_AUTH_WPA2_PSK);
+        gsw_wifi_ap_frequency_set(2);
+        gsw_wifi_ap_bandwidth_set(GSW_WIFI_BANDWIDTH_HT40);
+        gsw_wifi_ap_channel_set(0);
+    }
+    else if (ap_seting == 'n' || ap_seting == 'N')
+    {
+        ap_setting();
+    }
+    else
+    {
+        printf("Invalid input\n");
+        return -1;
+    }
+
+    if (gsw_wifi_ap_start() != 0)
+    {
+        printf("Failed to start AP mode\n");
+        goto begin;
+    }
+    // 注册AP回调
+    if (gsw_wifi_reg_ap_event_callback(NULL, ap_event_callback) != 0)
+    {
+        printf("Failed to register AP event callback\n");
+        return -1;
+    }
+    gsw_wifi_get_ap_status(&ap_status);
+    printf("ap status: %s\n", ap_status == GSW_WIFI_AP_STATUS_ENABLE ? "enable" : "disable");
+    printf("Wi-Fi driver loaded and AP mode started.\n");
+
+    while (1)
+    {
+        char input[64];
+        printf("\nEnter command (1: start STA; 2: scan hotspots; 3: connect to hotspot; 4: ap get; q: exit; ap-status: check ap status; restart-ap .) ");
+        if (scanf("%63s", input) != 1)
+        { // Check scanf return value
+            printf("Error reading input\n");
+            break;
+        }
+
+        if (strcmp(input, "q") == 0)
+        {
+            break;
+        }
+        else if (strcmp(input, "ap-status") == 0)
+        {
+            gsw_wifi_get_ap_status(&ap_status);
+            printf("ap status: %s\n", ap_status == GSW_WIFI_AP_STATUS_ENABLE ? "enable" : "disable");
+        }
+        else if (strcmp(input, "restart-ap") == 0)
+        {
+            printf("Restarting AP...\n");
+            ap_setting();
+            gsw_wifi_ap_restart();
+            gsw_wifi_get_ap_status(&ap_status);
+            printf("ap status: %s\n", ap_status == GSW_WIFI_AP_STATUS_ENABLE ? "enable" : "disable");
+        }
+
+        else if (strcmp(input, "1") == 0)
+        {
+            // 启动 STA 模式
+            if (gsw_wifi_sta_start() != 0)
+            {
+                printf("Failed to start STA mode\n");
+            }
+            else
+            {
+                printf("STA mode started.\n");
+            }
+        }
+        else if (strcmp(input, "2") == 0)
+        {
+            // 搜索热点
+            gsw_scan_info_s scan_list[100];
+            int list_len;
+            if (gsw_wifi_get_scan_list(scan_list, 100, &list_len) == 0)
+            {
+                printf("Available hotspots:\n");
+                for (int i = 0; i < list_len; i++)
+                {
+                    const char *auth_str = auth_type_to_string(scan_list[i].auth);
+                    printf("%d. SSID: %s, BSSID: %s, RSSI: %d, Auth: %s\n", i + 1, scan_list[i].ssid, scan_list[i].mac, scan_list[i].rssi, auth_str);
+                }
+            }
+            else
+            {
+                printf("Failed to scan for hotspots\n");
+            }
+        }
+        else if (strcmp(input, "3") == 0)
+        {
+            // 输入对应的账户和密码进行连接,从扫描结果获取认证方式
+            gsw_scan_info_s scan_list[100];
+            int list_len;
+            if (gsw_wifi_get_scan_list(scan_list, 100, &list_len) == 0)
+            {
+                printf("Available hotspots:\n");
+                for (int i = 0; i < list_len; i++)
+                {
+                    const char *auth_str = auth_type_to_string(scan_list[i].auth);
+                    printf("%d. SSID: %s, BSSID: %s, RSSI: %d, Auth: %s\n", i + 1, scan_list[i].ssid, scan_list[i].mac, scan_list[i].rssi, auth_str);
+                }
+
+                int choice;
+                printf("Enter the number of the hotspot to connect: ");
+                if (scanf("%d", &choice) != 1)
+                { // Check scanf return value
+                    printf("Error reading input\n");
+                    continue;
+                }
+                if (choice < 1 || choice > list_len)
+                {
+                    printf("Invalid choice\n");
+                    continue;
+                }
+
+                // 直接从扫描结果中获取认证方式
+                gsw_wifi_auth_e auth = scan_list[choice - 1].auth;
+                const char *auth_str = auth_type_to_string(auth);
+                printf("Got authentication type from scan result: %s\n", auth_str);
+
+                char password[64] = ""; // 默认空密码
+                if (auth != GSW_WIFI_AUTH_OPEN)
+                {
+                    printf("Enter password for SSID %s: ", scan_list[choice - 1].ssid);
+                    if (scanf("%63s", password) != 1)
+                    {
+                        printf("Error reading input\n");
+                        continue;
+                    }
+                }
+                else
+                {
+                    printf("Open network, skipping password input.\n");
+                }
+
+                if (gsw_wifi_sta_connect(scan_list[choice - 1].ssid, auth, password) != 0)
+                {
+                    printf("Failed to connect to SSID %s\n", scan_list[choice - 1].ssid);
+                }
+                else
+                {
+                    printf("Attempting to connect to SSID %s\n", scan_list[choice - 1].ssid);
+                    // 等待连接成功
+                    sleep(5);
+
+                    // 获取连接的 SSID
+                    char connected_ssid[33];
+                    if (gsw_wifi_get_sta_ssid(connected_ssid) == 0)
+                    {
+                        printf("Connected to SSID: %s\n", connected_ssid);
+                    }
+                    else
+                    {
+                        printf("Failed to connect\n");
+                    }
+                }
+            }
+            else
+            {
+                printf("Failed to scan for hotspots\n");
+            }
+        }
+        else if (strcmp(input, "4") == 0)
+        {
+            // 获取AP相关信息并格式化输出
+            printf("\nAP Configuration:\n");
+            printf("-----------------\n");
+
+            char ssid[33];
+            if (gsw_wifi_ap_ssid_get(ssid) == 0)
+            {
+                printf("SSID: %-20s\n", ssid);
+            }
+            else
+            {
+                printf("SSID: Failed to get\n");
+            }
+
+            int frequency;
+            if (gsw_wifi_ap_frequency_get(&frequency) == 0)
+            {
+                printf("Frequency: %-15s\n", frequency == 1 ? "2.4GHz" : "5GHz");
+            }
+            else
+            {
+                printf("Frequency: Failed to get\n");
+            }
+
+            gsw_wifi_bandwidth_type_e bandwidth;
+            if (gsw_wifi_ap_bandwidth_get(&bandwidth) == 0)
+            {
+                const char *bw_str[] = {"10MHz", "20MHz", "40MHz", "80MHz"};
+                printf("Bandwidth: %-15s\n", bandwidth >= 0 && bandwidth <= 3 ? bw_str[bandwidth] : "Unknown");
+            }
+            else
+            {
+                printf("Bandwidth: Failed to get\n");
+            }
+
+            int channel;
+            if (gsw_wifi_ap_channel_get(&channel) == 0)
+            {
+                printf("Channel: %-18d\n", channel);
+            }
+            else
+            {
+                printf("Channel: Failed to get\n");
+            }
+
+            gsw_wifi_auth_e auth;
+            if (gsw_wifi_ap_auth_get(&auth) == 0)
+            {
+                printf("Authentication: %-10s\n", auth_type_to_string(auth));
+            }
+            else
+            {
+                printf("Authentication: Failed to get\n");
+            }
+
+            char password[65];
+            if (gsw_wifi_ap_password_get(password) == 0)
+            {
+                printf("Password: %-18s\n", password);
+            }
+            else
+            {
+                printf("Password: Failed to get\n");
+            }
+
+            printf("-----------------\n");
+        }
+        else
+        {
+            printf("Invalid command\n");
+        }
+    }
+
+    // 停止 AP 和 STA 模式,卸载 Wi-Fi 驱动
+    gsw_wifi_ap_stop();
+    gsw_wifi_sta_stop();
+    gsw_wifi_disable();
+
+    printf("Wi-Fi driver unloaded and AP/STA modes stopped.\n");
+
+    return 0;
+}
\ No newline at end of file
diff --git a/package/kernel/aic-wl/aic-driver/Makefile b/package/kernel/aic-wl/aic-driver/Makefile
index 14ab31d..abd7cd3 100644
--- a/package/kernel/aic-wl/aic-driver/Makefile
+++ b/package/kernel/aic-wl/aic-driver/Makefile
@@ -12,6 +12,7 @@
 PKG_VERSION:=2024
 PKG_RELEASE:=1
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+WIFI_KERNEL_PATH := $(BUILD_DIR)/../../marvell/linux/drivers/net/wireless/aic8800/
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -49,6 +50,18 @@
   AUTOLOAD+=$(call AutoLoad,44,mac80211)
 #  AUTOLOAD:=$(call AutoLoad,44,mac80211 aic8800_bsp aic8800_fdrv)
 endif
+ifeq ($(CONFIG_AIC_KERNEL_SDIO_WIFI),y)
+  ifneq ($(wildcard $(WIFI_KERNEL_PATH)/aic8800_bsp/aic8800_bsp.ko),)
+    FILES+=$(WIFI_KERNEL_PATH)/aic8800_bsp/aic8800_bsp.ko
+  endif
+  ifneq ($(wildcard $(WIFI_KERNEL_PATH)/aic8800_fdrv/aic8800_fdrv.ko),)
+    FILES+=$(WIFI_KERNEL_PATH)/aic8800_fdrv/aic8800_fdrv.ko
+  endif
+  ifneq ($(strip $(FILES)),)
+    AUTOLOAD+=$(call AutoLoad,44,mac80211)
+  endif
+endif
+
 endef
 
 define KernelPackage/aic-driver/description
@@ -85,6 +98,11 @@
 		default n
 		help
 		  Select sdio wifi AIC8800DW/AIC8800D80
+	menuconfig AIC_KERNEL_SDIO_WIFI
+		bool "AIC SDIO WiFi path:marvell/linux/drivers/net/wireless/aic8800/"
+		default n
+		help
+		  Select sdio wifi AIC8800DW/AIC8800D80
 	if AIC_SDIO_WIFI
 	config AIC_SDIO_AIC8800DW
 		bool "AIC8800DW"
diff --git a/package/network/services/lte-telephony/files/telinit b/package/network/services/lte-telephony/files/telinit
index 0448df6..9483d76 100755
--- a/package/network/services/lte-telephony/files/telinit
+++ b/package/network/services/lte-telephony/files/telinit
@@ -126,4 +126,3 @@
 		/usr/bin/audio_if &
 		}
 fi
-/etc/mbtk_wifi.sh ap start
\ No newline at end of file