diff options
| author | tangyuxin <[email protected]> | 2019-07-15 18:17:53 +0800 |
|---|---|---|
| committer | tangyuxin <[email protected]> | 2019-07-16 18:26:31 +0800 |
| commit | 46498d5d1eebed56732a852f5a73ce6a0eb5ad61 (patch) | |
| tree | 39f34313b1c929937b7cf97dfea658f47135f133 /components/drivers/wlan/wlan_dev.c | |
| parent | 3d022a6816a00c4f9b3040aa49e2864091d5fa5f (diff) | |
[components][drivers][wlan] 功能可裁剪
- WLAN 连接信息保存功能可裁剪
- WIFI MSH 命令功能可裁剪
- WLAN 管理功能可裁剪
- WLAN 自动连接功能可裁剪
- WLAN 自动连接时使用最新热点信息
- WLAN 用户事件回调由独立线程调用
- WLAN 独立线程可裁剪
- WLAN 协议管理功能可裁剪
- LWIP 协议层可裁剪
- SCAN 结果支持过滤
- WIFI 阻塞式连接支持多次扫描
- WLAN 新增网卡对象指针
- WLAN 获取信息时更新信号强度
- 其他优化性质改动
Diffstat (limited to 'components/drivers/wlan/wlan_dev.c')
| -rw-r--r-- | components/drivers/wlan/wlan_dev.c | 24 |
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 |
