Skip to content

Commit c8b0a9d

Browse files
EvlersRbb666
authored andcommitted
[wlan] add ap_get_info api for more ap information
1 parent 6cad23b commit c8b0a9d

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

Diff for: components/drivers/wlan/dev_wlan.c

+29
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2018-08-03 tyx the first version
99
* 2024-12-25 Evlers add get_info api for more new sta information
10+
* 2025-01-04 Evlers add ap_get_info api for more ap information
1011
*/
1112

1213
#include <rthw.h>
@@ -269,6 +270,25 @@ rt_err_t rt_wlan_dev_get_info(struct rt_wlan_device *device, struct rt_wlan_info
269270
return result;
270271
}
271272

273+
rt_err_t rt_wlan_dev_ap_get_info(struct rt_wlan_device *device, struct rt_wlan_info *info)
274+
{
275+
rt_err_t result = RT_EOK;
276+
277+
if (device == RT_NULL)
278+
{
279+
return -RT_EIO;
280+
}
281+
282+
result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_AP_GET_INFO, info);
283+
if (result != RT_EOK)
284+
{
285+
rt_set_errno(result);
286+
return 0;
287+
}
288+
289+
return result;
290+
}
291+
272292
rt_err_t rt_wlan_dev_get_mac(struct rt_wlan_device *device, rt_uint8_t mac[6])
273293
{
274294
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)
815835
err = -RT_ERROR;
816836
break;
817837
}
838+
case RT_WLAN_CMD_AP_GET_INFO:
839+
{
840+
struct rt_wlan_info *info = args;
841+
842+
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_AP_GET_INFO, "RT_WLAN_CMD_AP_GET_INFO");
843+
if (wlan->ops->wlan_ap_get_info)
844+
err = wlan->ops->wlan_ap_get_info(wlan, info);
845+
break;
846+
}
818847
case RT_WLAN_CMD_SET_POWERSAVE:
819848
{
820849
int level = *((int *)args);

Diff for: components/drivers/wlan/dev_wlan.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2018-08-03 tyx the first version
99
* 2024-12-25 Evlers add get_info api for more new sta information
10+
* 2025-01-04 Evlers add ap_get_info api for more ap information
1011
*/
1112

1213
#ifndef __DEV_WLAN_DEVICE_H__
@@ -16,7 +17,7 @@
1617
extern "C" {
1718
#endif
1819

19-
#define RT_WLAN_DEV_VERSION 0x10000 /* 1.0.0 */
20+
#define RT_WLAN_DEV_VERSION 0x10001 /* 1.0.1 */
2021

2122
typedef enum
2223
{
@@ -38,6 +39,7 @@ typedef enum
3839
RT_WLAN_CMD_SCAN_STOP,
3940
RT_WLAN_CMD_GET_RSSI, /* get sensitivity (dBm) */
4041
RT_WLAN_CMD_GET_INFO, /* get information (rssi, channel, datarate.) */
42+
RT_WLAN_CMD_AP_GET_INFO, /* get ap information (bssid, security, channel.) */
4143
RT_WLAN_CMD_SET_POWERSAVE,
4244
RT_WLAN_CMD_GET_POWERSAVE,
4345
RT_WLAN_CMD_CFG_PROMISC, /* start/stop minitor */
@@ -502,6 +504,7 @@ struct rt_wlan_dev_ops
502504
rt_err_t (*wlan_scan_stop)(struct rt_wlan_device *wlan);
503505
int (*wlan_get_rssi)(struct rt_wlan_device *wlan);
504506
int (*wlan_get_info)(struct rt_wlan_device *wlan, struct rt_wlan_info *info);
507+
int (*wlan_ap_get_info)(struct rt_wlan_device *wlan, struct rt_wlan_info *info);
505508
rt_err_t (*wlan_set_powersave)(struct rt_wlan_device *wlan, int level);
506509
int (*wlan_get_powersave)(struct rt_wlan_device *wlan);
507510
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
540543
rt_err_t rt_wlan_dev_ap_start(struct rt_wlan_device *device, struct rt_wlan_info *info, const char *password, int password_len);
541544
rt_err_t rt_wlan_dev_ap_stop(struct rt_wlan_device *device);
542545
rt_err_t rt_wlan_dev_ap_deauth(struct rt_wlan_device *device, rt_uint8_t mac[6]);
546+
rt_err_t rt_wlan_dev_ap_get_info(struct rt_wlan_device *device, struct rt_wlan_info *info);
543547

544548
/*
545549
* wlan device scan interface

Diff for: components/drivers/wlan/dev_wlan_mgnt.c

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* 2018-08-06 tyx the first version
99
* 2023-12-12 Evlers add the wlan join scan function
1010
* 2024-12-25 Evlers add get_info api for more new sta information
11+
* 2025-01-04 Evlers add ap_get_info api for more ap information
1112
*/
1213

1314
#include <rthw.h>
@@ -1408,6 +1409,11 @@ rt_err_t rt_wlan_ap_get_info(struct rt_wlan_info *info)
14081409
if (rt_wlan_ap_is_active() == RT_TRUE)
14091410
{
14101411
*info = _ap_mgnt.info;
1412+
if (rt_wlan_dev_ap_get_info(AP_DEVICE(), info) != RT_EOK)
1413+
{
1414+
RT_WLAN_LOG_E("get ap info failed!");
1415+
return -RT_ERROR;
1416+
}
14111417
return RT_EOK;
14121418
}
14131419
return -RT_ERROR;

0 commit comments

Comments
 (0)