[components][drivers][wlan] 更正表意错误的返回值类型

This commit is contained in:
tangyuxin 2018-11-30 17:49:44 +08:00
parent bcd591c5f5
commit 353792b626
4 changed files with 48 additions and 24 deletions

View File

@ -145,7 +145,10 @@ rt_err_t rt_wlan_dev_ap_start(struct rt_wlan_device *device, struct rt_wlan_info
rt_memset(&ap_info, 0, sizeof(struct rt_ap_info));
rt_memcpy(&ap_info.ssid, &info->ssid, sizeof(rt_wlan_ssid_t));
rt_memcpy(ap_info.key.val, password, password_len);
if (password != RT_NULL)
{
rt_memcpy(ap_info.key.val, password, password_len);
}
ap_info.key.len = password_len;
ap_info.hidden = info->hidden;
ap_info.channel = info->channel;
@ -184,13 +187,21 @@ rt_err_t rt_wlan_dev_ap_deauth(struct rt_wlan_device *device, rt_uint8_t mac[6])
int rt_wlan_dev_get_rssi(struct rt_wlan_device *device)
{
int rssi = 0;
rt_err_t result = RT_EOK;
if (device == RT_NULL)
{
return -RT_EIO;
rt_set_errno(-RT_EIO);
return 0;
}
result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_RSSI, &rssi);
if (result != RT_EOK)
{
rt_set_errno(result);
return 0;
}
rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_RSSI, &rssi);
return rssi;
}
@ -235,14 +246,20 @@ rt_err_t rt_wlan_dev_set_powersave(struct rt_wlan_device *device, int level)
int rt_wlan_dev_get_powersave(struct rt_wlan_device *device)
{
int level = 0;
int level = -1;
rt_err_t result = RT_EOK;
if (device == RT_NULL)
{
rt_set_errno(-RT_EIO);
return -1;
}
rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_POWERSAVE, &level);
result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_POWERSAVE, &level);
if (result != RT_EOK)
{
rt_set_errno(result);
}
return level;
}
@ -432,19 +449,21 @@ rt_err_t rt_wlan_dev_set_channel(struct rt_wlan_device *device, int channel)
return result;
}
rt_err_t rt_wlan_dev_get_channel(struct rt_wlan_device *device)
int rt_wlan_dev_get_channel(struct rt_wlan_device *device)
{
rt_err_t result = RT_EOK;
int channel;
int channel = -1;
if (device == RT_NULL)
{
return -RT_EIO;
rt_set_errno(-RT_EIO);
return -1;
}
result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_CHANNEL, &channel);
if (result != RT_EOK)
{
rt_set_errno(result);
return -1;
}
@ -466,17 +485,19 @@ rt_err_t rt_wlan_dev_set_country(struct rt_wlan_device *device, rt_country_code_
rt_country_code_t rt_wlan_dev_get_country(struct rt_wlan_device *device)
{
int result = 0;
int result = RT_EOK;
rt_country_code_t country_code = RT_COUNTRY_UNKNOWN;
if (device == RT_NULL)
{
return country_code;
rt_set_errno(-RT_EIO);
return RT_COUNTRY_UNKNOWN;
}
result = rt_device_control(RT_DEVICE(device), RT_WLAN_CMD_GET_COUNTRY, &country_code);
if (result != RT_EOK)
{
rt_set_errno(result);
return RT_COUNTRY_UNKNOWN;
}
@ -641,7 +662,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_POWERSAVE, "RT_WLAN_CMD_SET_POWERSAVE");
if (wlan->ops->wlan_set_powersave)
wlan->ops->wlan_set_powersave(wlan, level);
err = wlan->ops->wlan_set_powersave(wlan, level);
break;
}
case RT_WLAN_CMD_GET_POWERSAVE:
@ -659,7 +680,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_CFG_PROMISC, "RT_WLAN_CMD_CFG_PROMISC");
if (wlan->ops->wlan_cfg_promisc)
wlan->ops->wlan_cfg_promisc(wlan, start);
err = wlan->ops->wlan_cfg_promisc(wlan, start);
break;
}
case RT_WLAN_CMD_CFG_FILTER:
@ -668,7 +689,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_CFG_FILTER, "RT_WLAN_CMD_CFG_FILTER");
if (wlan->ops->wlan_cfg_filter)
wlan->ops->wlan_cfg_filter(wlan, filter);
err = wlan->ops->wlan_cfg_filter(wlan, filter);
break;
}
case RT_WLAN_CMD_SET_CHANNEL:
@ -676,7 +697,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
int channel = *(int *)args;
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_CHANNEL, "RT_WLAN_CMD_SET_CHANNEL");
if (wlan->ops->wlan_set_channel)
wlan->ops->wlan_set_channel(wlan, channel);
err = wlan->ops->wlan_set_channel(wlan, channel);
break;
}
case RT_WLAN_CMD_GET_CHANNEL:
@ -694,7 +715,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_COUNTRY, "RT_WLAN_CMD_SET_COUNTRY");
if (wlan->ops->wlan_set_country)
wlan->ops->wlan_set_country(wlan, country);
err = wlan->ops->wlan_set_country(wlan, country);
break;
}
case RT_WLAN_CMD_GET_COUNTRY:
@ -711,7 +732,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_SET_MAC, "RT_WLAN_CMD_SET_MAC");
if (wlan->ops->wlan_set_mac)
wlan->ops->wlan_set_mac(wlan, mac);
err = wlan->ops->wlan_set_mac(wlan, mac);
break;
}
case RT_WLAN_CMD_GET_MAC:
@ -720,7 +741,7 @@ static rt_err_t _rt_wlan_dev_control(rt_device_t dev, int cmd, void *args)
LOG_D("%s %d cmd[%d]:%s run......", __FUNCTION__, __LINE__, RT_WLAN_CMD_GET_MAC, "RT_WLAN_CMD_GET_MAC");
if (wlan->ops->wlan_get_mac)
wlan->ops->wlan_get_mac(wlan, mac);
err = wlan->ops->wlan_get_mac(wlan, mac);
break;
}
default:

View File

@ -559,7 +559,7 @@ rt_err_t rt_wlan_dev_cfg_filter(struct rt_wlan_device *device, struct rt_wlan_fi
* wlan device channel interface
*/
rt_err_t rt_wlan_dev_set_channel(struct rt_wlan_device *device, int channel);
rt_err_t rt_wlan_dev_get_channel(struct rt_wlan_device *device);
int rt_wlan_dev_get_channel(struct rt_wlan_device *device);
/*
* wlan device country interface

View File

@ -1320,7 +1320,10 @@ rt_err_t rt_wlan_start_ap_adv(struct rt_wlan_info *info, const char *password)
return -RT_EIO;
}
RT_WLAN_LOG_D("%s is run", __FUNCTION__);
password_len = rt_strlen(password);
if (password != RT_NULL)
{
password_len = rt_strlen(password);
}
if (password_len > RT_WLAN_PASSWORD_MAX_LENGTH)
{
RT_WLAN_LOG_E("key is to long! len:%d", password_len);
@ -1358,16 +1361,16 @@ rt_err_t rt_wlan_start_ap_adv(struct rt_wlan_info *info, const char *password)
return err;
}
int rt_wlan_ap_is_active(void)
rt_bool_t rt_wlan_ap_is_active(void)
{
int _active = 0;
rt_bool_t _active = RT_FALSE;
if (_ap_is_null())
{
return 0;
return RT_FALSE;
}
_active = _ap_mgnt.state & RT_WLAN_STATE_ACTIVE ? 1 : 0;
_active = _ap_mgnt.state & RT_WLAN_STATE_ACTIVE ? RT_TRUE : RT_FALSE;
RT_WLAN_LOG_D("%s is run active:%s", __FUNCTION__, _active ? "Active" : "Inactive");
return _active;
}

View File

@ -97,7 +97,7 @@ int rt_wlan_get_rssi(void);
*/
rt_err_t rt_wlan_start_ap(const char *ssid, const char *password);
rt_err_t rt_wlan_start_ap_adv(struct rt_wlan_info *info, const char *password);
int rt_wlan_ap_is_active(void);
rt_bool_t rt_wlan_ap_is_active(void);
rt_err_t rt_wlan_ap_stop(void);
rt_err_t rt_wlan_ap_get_info(struct rt_wlan_info *info);
int rt_wlan_ap_get_sta_num(void);