hostap: Support getting Wi-Fi connection parameters recently used
Support saving and getting Wi-Fi connection parameters recently used. Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
This commit is contained in:
parent
744f67c587
commit
1a547dd40e
5 changed files with 69 additions and 0 deletions
|
|
@ -88,6 +88,8 @@ enum net_request_wifi_cmd {
|
|||
NET_REQUEST_WIFI_CMD_AP_STA_DISCONNECT,
|
||||
/** Get Wi-Fi driver and Firmware versions */
|
||||
NET_REQUEST_WIFI_CMD_VERSION,
|
||||
/** Get Wi-Fi latest connection parameters */
|
||||
NET_REQUEST_WIFI_CMD_CONN_PARAMS,
|
||||
/** Set RTS threshold */
|
||||
NET_REQUEST_WIFI_CMD_RTS_THRESHOLD,
|
||||
/** Configure AP parameter */
|
||||
|
|
@ -193,6 +195,12 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT);
|
|||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION);
|
||||
|
||||
/** Request a Wi-Fi connection parameters */
|
||||
#define NET_REQUEST_WIFI_CONN_PARAMS \
|
||||
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONN_PARAMS)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_CONN_PARAMS);
|
||||
|
||||
/** Request a Wi-Fi RTS threshold */
|
||||
#define NET_REQUEST_WIFI_RTS_THRESHOLD \
|
||||
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD)
|
||||
|
|
@ -1144,6 +1152,14 @@ struct wifi_mgmt_ops {
|
|||
* @return 0 if ok, < 0 if error
|
||||
*/
|
||||
int (*get_version)(const struct device *dev, struct wifi_version *params);
|
||||
/** Get Wi-Fi connection parameters recently used
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param params the Wi-Fi connection parameters recently used
|
||||
*
|
||||
* @return 0 if ok, < 0 if error
|
||||
*/
|
||||
int (*get_conn_params)(const struct device *dev, struct wifi_connect_req_params *params);
|
||||
/** Set RTS threshold value
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
extern struct k_sem wpa_supplicant_ready_sem;
|
||||
extern struct wpa_global *global;
|
||||
|
||||
/* save the last wifi connection parameters */
|
||||
static struct wifi_connect_req_params last_wifi_conn_params;
|
||||
|
||||
enum requested_ops {
|
||||
CONNECT = 0,
|
||||
DISCONNECT
|
||||
|
|
@ -531,6 +534,8 @@ static int wpas_add_and_config_network(struct wpa_supplicant *wpa_s,
|
|||
goto out;
|
||||
}
|
||||
|
||||
memset(&last_wifi_conn_params, 0, sizeof(struct wifi_connect_req_params));
|
||||
memcpy((void *)&last_wifi_conn_params, params, sizeof(struct wifi_connect_req_params));
|
||||
return 0;
|
||||
|
||||
rem_net:
|
||||
|
|
@ -957,6 +962,27 @@ out:
|
|||
}
|
||||
#endif
|
||||
|
||||
int supplicant_get_wifi_conn_params(const struct device *dev,
|
||||
struct wifi_connect_req_params *params)
|
||||
{
|
||||
struct wpa_supplicant *wpa_s;
|
||||
int ret = 0;
|
||||
|
||||
k_mutex_lock(&wpa_supplicant_mutex, K_FOREVER);
|
||||
|
||||
wpa_s = get_wpa_s_handle(dev);
|
||||
if (!wpa_s) {
|
||||
ret = -1;
|
||||
wpa_printf(MSG_ERROR, "Device %s not found", dev->name);
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(params, &last_wifi_conn_params, sizeof(struct wifi_connect_req_params));
|
||||
out:
|
||||
k_mutex_unlock(&wpa_supplicant_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_AP
|
||||
int supplicant_ap_enable(const struct device *dev,
|
||||
struct wifi_connect_req_params *params)
|
||||
|
|
|
|||
|
|
@ -159,6 +159,16 @@ int supplicant_channel(const struct device *dev, struct wifi_channel_info *chann
|
|||
int supplicant_btm_query(const struct device *dev, uint8_t reason);
|
||||
#endif
|
||||
|
||||
/** Get Wi-Fi connection parameters recently used
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance
|
||||
* @param params the Wi-Fi connection parameters recently used
|
||||
*
|
||||
* @return 0 if ok, < 0 if error
|
||||
*/
|
||||
int supplicant_get_wifi_conn_params(const struct device *dev,
|
||||
struct wifi_connect_req_params *params);
|
||||
|
||||
#ifdef CONFIG_AP
|
||||
/**
|
||||
* @brief Set Wi-Fi AP configuration
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ static const struct wifi_mgmt_ops mgmt_ops = {
|
|||
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM
|
||||
.btm_query = supplicant_btm_query,
|
||||
#endif
|
||||
.get_conn_params = supplicant_get_wifi_conn_params,
|
||||
#ifdef CONFIG_AP
|
||||
.ap_enable = supplicant_ap_enable,
|
||||
.ap_disable = supplicant_ap_disable,
|
||||
|
|
|
|||
|
|
@ -797,6 +797,22 @@ static int wifi_btm_query(uint32_t mgmt_request, struct net_if *iface, void *dat
|
|||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_BTM_QUERY, wifi_btm_query);
|
||||
#endif
|
||||
|
||||
static int wifi_get_connection_params(uint32_t mgmt_request, struct net_if *iface,
|
||||
void *data, size_t len)
|
||||
{
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
|
||||
struct wifi_connect_req_params *conn_params = data;
|
||||
|
||||
if (wifi_mgmt_api == NULL || wifi_mgmt_api->get_conn_params == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return wifi_mgmt_api->get_conn_params(dev, conn_params);
|
||||
}
|
||||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_CONN_PARAMS, wifi_get_connection_params);
|
||||
|
||||
static int wifi_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface,
|
||||
void *data, size_t len)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue