From c8b0a9dbd954f46da201dfaf66dbe5e977943c1d Mon Sep 17 00:00:00 2001 From: Evlers <1425295900@qq.com> Date: Sat, 4 Jan 2025 22:05:33 +0800 Subject: [PATCH] [wlan] add ap_get_info api for more ap information --- components/drivers/wlan/dev_wlan.c | 29 +++++++++++++++++++++++++ components/drivers/wlan/dev_wlan.h | 6 ++++- components/drivers/wlan/dev_wlan_mgnt.c | 6 +++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/components/drivers/wlan/dev_wlan.c b/components/drivers/wlan/dev_wlan.c index ff5b0fb3916..a3ed0347a95 100644 --- a/components/drivers/wlan/dev_wlan.c +++ b/components/drivers/wlan/dev_wlan.c @@ -7,6 +7,7 @@ * Date Author Notes * 2018-08-03 tyx the first version * 2024-12-25 Evlers add get_info api for more new sta information + * 2025-01-04 Evlers add ap_get_info api for more ap information */ #include @@ -269,6 +270,25 @@ rt_err_t rt_wlan_dev_get_info(struct rt_wlan_device *device, struct rt_wlan_info return result; } +rt_err_t rt_wlan_dev_ap_get_info(struct rt_wlan_device *device, struct rt_wlan_info *info) +{ + rt_err_t result = RT_EOK; + + if (device == RT_NULL) + { + return -RT_EIO; + } + + result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_AP_GET_INFO, info); + if (result != RT_EOK) + { + rt_set_errno(result); + return 0; + } + + return result; +} + rt_err_t rt_wlan_dev_get_mac(struct rt_wlan_device *device, rt_uint8_t mac[6]) { rt_err_t result = RT_EOK; @@ -815,6 +835,15 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args) err = -RT_ERROR; break; } + case RT_WLAN_CMD_AP_GET_INFO: + { + struct rt_wlan_info *info = args; + + LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_AP_GET_INFO, "RT_WLAN_CMD_AP_GET_INFO"); + if (wlan->ops->wlan_ap_get_info) + err = wlan->ops->wlan_ap_get_info(wlan, info); + break; + } case RT_WLAN_CMD_SET_POWERSAVE: { int level = *((int *)args); diff --git a/components/drivers/wlan/dev_wlan.h b/components/drivers/wlan/dev_wlan.h index 7b188d684a3..20e5671152f 100644 --- a/components/drivers/wlan/dev_wlan.h +++ b/components/drivers/wlan/dev_wlan.h @@ -7,6 +7,7 @@ * Date Author Notes * 2018-08-03 tyx the first version * 2024-12-25 Evlers add get_info api for more new sta information + * 2025-01-04 Evlers add ap_get_info api for more ap information */ #ifndef __DEV_WLAN_DEVICE_H__ @@ -16,7 +17,7 @@ extern "C" { #endif -#define RT_WLAN_DEV_VERSION 0x10000 /* 1.0.0 */ +#define RT_WLAN_DEV_VERSION 0x10001 /* 1.0.1 */ typedef enum { @@ -38,6 +39,7 @@ typedef enum RT_WLAN_CMD_SCAN_STOP, RT_WLAN_CMD_GET_RSSI, /* get sensitivity (dBm) */ RT_WLAN_CMD_GET_INFO, /* get information (rssi, channel, datarate.) */ + RT_WLAN_CMD_AP_GET_INFO, /* get ap information (bssid, security, channel.) */ RT_WLAN_CMD_SET_POWERSAVE, RT_WLAN_CMD_GET_POWERSAVE, RT_WLAN_CMD_CFG_PROMISC, /* start/stop minitor */ @@ -502,6 +504,7 @@ struct rt_wlan_dev_ops rt_err_t (*wlan_scan_stop)(struct rt_wlan_device *wlan); int (*wlan_get_rssi)(struct rt_wlan_device *wlan); int (*wlan_get_info)(struct rt_wlan_device *wlan, struct rt_wlan_info *info); + int (*wlan_ap_get_info)(struct rt_wlan_device *wlan, struct rt_wlan_info *info); rt_err_t (*wlan_set_powersave)(struct rt_wlan_device *wlan, int level); int (*wlan_get_powersave)(struct rt_wlan_device *wlan); rt_err_t (*wlan_cfg_promisc)(struct rt_wlan_device *wlan, rt_bool_t start); @@ -540,6 +543,7 @@ rt_err_t rt_wlan_dev_get_info(struct rt_wlan_device *device, struct rt_wlan_info rt_err_t rt_wlan_dev_ap_start(struct rt_wlan_device *device, struct rt_wlan_info *info, const char *password, int password_len); rt_err_t rt_wlan_dev_ap_stop(struct rt_wlan_device *device); rt_err_t rt_wlan_dev_ap_deauth(struct rt_wlan_device *device, rt_uint8_t mac[6]); +rt_err_t rt_wlan_dev_ap_get_info(struct rt_wlan_device *device, struct rt_wlan_info *info); /* * wlan device scan interface diff --git a/components/drivers/wlan/dev_wlan_mgnt.c b/components/drivers/wlan/dev_wlan_mgnt.c index bc43980357f..5d338ba7a56 100644 --- a/components/drivers/wlan/dev_wlan_mgnt.c +++ b/components/drivers/wlan/dev_wlan_mgnt.c @@ -8,6 +8,7 @@ * 2018-08-06 tyx the first version * 2023-12-12 Evlers add the wlan join scan function * 2024-12-25 Evlers add get_info api for more new sta information + * 2025-01-04 Evlers add ap_get_info api for more ap information */ #include @@ -1408,6 +1409,11 @@ rt_err_t rt_wlan_ap_get_info(struct rt_wlan_info *info) if (rt_wlan_ap_is_active() == RT_TRUE) { *info = _ap_mgnt.info; + if (rt_wlan_dev_ap_get_info(AP_DEVICE(), info) != RT_EOK) + { + RT_WLAN_LOG_E("get ap info failed!"); + return -RT_ERROR; + } return RT_EOK; } return -RT_ERROR;