| 49 | #endif |
| 50 | |
| 51 | rt_err_t rt_wlan_dev_init(struct rt_wlan_device *device, rt_wlan_mode_t mode) |
| 52 | { |
| 53 | rt_err_t result = RT_EOK; |
| 54 | |
| 55 | /* init wlan device */ |
| 56 | LOG_D("F:%s L:%d is run device:0x%08x mode:%d", __FUNCTION__, __LINE__, device, mode); |
| 57 | if ((device == RT_NULL) || (mode >= RT_WLAN_MODE_MAX)) |
| 58 | { |
| 59 | LOG_E("F:%s L:%d Parameter Wrongful device:0x%08x mode:%d", __FUNCTION__, __LINE__, device, mode); |
| 60 | return -RT_ERROR; |
| 61 | } |
| 62 | |
| 63 | if (mode == RT_WLAN_AP && device->flags & RT_WLAN_FLAG_STA_ONLY) |
| 64 | { |
| 65 | LOG_E("F:%s L:%d This wlan device can only be set to sta mode!", __FUNCTION__, __LINE__); |
| 66 | return -RT_ERROR; |
| 67 | } |
| 68 | else if (mode == RT_WLAN_STATION && device->flags & RT_WLAN_FLAG_AP_ONLY) |
| 69 | { |
| 70 | LOG_E("F:%s L:%d This wlan device can only be set to ap mode!", __FUNCTION__, __LINE__); |
| 71 | return -RT_ERROR; |
| 72 | } |
| 73 | |
| 74 | result = rt_device_init(RT_DEVICE(device)); |
| 75 | if (result != RT_EOK) |
| 76 | { |
| 77 | LOG_E("L:%d wlan init failed", __LINE__); |
| 78 | return -RT_ERROR; |
| 79 | } |
| 80 | result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_MODE, (void *)&mode); |
| 81 | if (result != RT_EOK) |
| 82 | { |
| 83 | LOG_E("L:%d wlan config mode failed", __LINE__); |
| 84 | return -RT_ERROR; |
| 85 | } |
| 86 | device->mode = mode; |
| 87 | return result; |
| 88 | } |
| 89 | |
| 90 | rt_err_t rt_wlan_dev_connect(struct rt_wlan_device *device, struct rt_wlan_info *info, const char *password, int password_len) |
| 91 | { |
no test coverage detected