summaryrefslogtreecommitdiff
path: root/components/drivers/wlan/wlan_dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/wlan/wlan_dev.c')
-rw-r--r--components/drivers/wlan/wlan_dev.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c
index 82fa4e73e7..e0f9eff279 100644
--- a/components/drivers/wlan/wlan_dev.c
+++ b/components/drivers/wlan/wlan_dev.c
@@ -21,6 +21,8 @@
#endif /* RT_WLAN_DEV_DEBUG */
#include <rtdbg.h>
+#if defined(RT_USING_WIFI) || defined(RT_USING_WLAN)
+
#ifndef RT_DEVICE
#define RT_DEVICE(__device) ((rt_device_t)__device)
#endif
@@ -56,6 +58,17 @@ rt_err_t rt_wlan_dev_init(struct rt_wlan_device *device, rt_wlan_mode_t mode)
return -RT_ERROR;
}
+ if (mode == RT_WLAN_AP && device->flags & RT_WLAN_FLAG_STA_ONLY)
+ {
+ LOG_E("F:%s L:%d This wlan device can only be set to sta mode!", __FUNCTION__, __LINE__);
+ return -RT_ERROR;
+ }
+ else if (mode == RT_WLAN_STATION && device->flags & RT_WLAN_FLAG_AP_ONLY)
+ {
+ LOG_E("F:%s L:%d This wlan device can only be set to ap mode!", __FUNCTION__, __LINE__);
+ return -RT_ERROR;
+ }
+
result = rt_device_init(RT_DEVICE(device));
if (result != RT_EOK)
{
@@ -545,7 +558,11 @@ rt_err_t rt_wlan_dev_scan_stop(struct rt_wlan_device *device)
rt_err_t rt_wlan_dev_report_data(struct rt_wlan_device *device, void *buff, int len)
{
+#ifdef RT_WLAN_PROT_ENABLE
return rt_wlan_dev_transfer_prot(device, buff, len);
+#else
+ return -RT_ERROR;
+#endif
}
static rt_err_t _rt_wlan_dev_init(rt_device_t dev)
@@ -768,14 +785,15 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
{
rt_err_t err = RT_EOK;
- if ((wlan == RT_NULL) || (name == RT_NULL) || (ops == RT_NULL))
+ if ((wlan == RT_NULL) || (name == RT_NULL) || (ops == RT_NULL) ||
+ (flag & RT_WLAN_FLAG_STA_ONLY && flag & RT_WLAN_FLAG_AP_ONLY))
{
LOG_E("F:%s L:%d parameter Wrongful", __FUNCTION__, __LINE__);
return RT_NULL;
}
rt_memset(wlan, 0, sizeof(struct rt_wlan_device));
-
+
#ifdef RT_USING_DEVICE_OPS
wlan->device.ops = &wlan_ops;
#else
@@ -801,3 +819,5 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
return err;
}
+
+#endif