net: wifi_mgmt: Setting RTS threshold
Support to set RTS threshold. Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
This commit is contained in:
parent
1f9bec7f08
commit
4d4b304e03
|
@ -82,6 +82,8 @@ enum net_request_wifi_cmd {
|
|||
NET_REQUEST_WIFI_CMD_AP_STA_DISCONNECT,
|
||||
/** Get Wi-Fi driver and Firmware versions */
|
||||
NET_REQUEST_WIFI_CMD_VERSION,
|
||||
/** Set RTS threshold */
|
||||
NET_REQUEST_WIFI_CMD_RTS_THRESHOLD,
|
||||
NET_REQUEST_WIFI_CMD_MAX
|
||||
};
|
||||
|
||||
|
@ -159,6 +161,10 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT);
|
|||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION);
|
||||
|
||||
#define NET_REQUEST_WIFI_RTS_THRESHOLD \
|
||||
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD)
|
||||
|
||||
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD);
|
||||
/** Wi-Fi management events */
|
||||
enum net_event_wifi_cmd {
|
||||
/** Scan results available */
|
||||
|
@ -852,6 +858,15 @@ struct wifi_mgmt_ops {
|
|||
* @return 0 if ok, < 0 if error
|
||||
*/
|
||||
int (*get_version)(const struct device *dev, struct wifi_version *params);
|
||||
/** Set RTS threshold value
|
||||
*
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param RTS threshold value
|
||||
*
|
||||
* @return 0 if ok, < 0 if error
|
||||
*/
|
||||
int (*set_rts_threshold)(const struct device *dev, unsigned int rts_threshold);
|
||||
|
||||
};
|
||||
|
||||
/** Wi-Fi management offload API */
|
||||
|
|
|
@ -719,6 +719,26 @@ static int wifi_get_version(uint32_t mgmt_request, struct net_if *iface,
|
|||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION, wifi_get_version);
|
||||
|
||||
static int wifi_set_rts_threshold(uint32_t mgmt_request, struct net_if *iface,
|
||||
void *data, size_t len)
|
||||
{
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
|
||||
unsigned int *rts_threshold = data;
|
||||
|
||||
if (wifi_mgmt_api == NULL || wifi_mgmt_api->set_rts_threshold == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (!data || len != sizeof(*rts_threshold)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return wifi_mgmt_api->set_rts_threshold(dev, *rts_threshold);
|
||||
}
|
||||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD, wifi_set_rts_threshold);
|
||||
|
||||
#ifdef CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS
|
||||
void wifi_mgmt_raise_raw_scan_result_event(struct net_if *iface,
|
||||
struct wifi_raw_scan_result *raw_scan_result)
|
||||
|
|
|
@ -1476,6 +1476,40 @@ static int cmd_wifi_ps_wakeup_mode(const struct shell *sh, size_t argc, char *ar
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_wifi_set_rts_threshold(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
struct net_if *iface = net_if_get_first_wifi();
|
||||
unsigned int rts_threshold = -1; /* Default value if user supplies "off" argument */
|
||||
int err = 0;
|
||||
|
||||
context.sh = sh;
|
||||
|
||||
if (strcmp(argv[1], "off") != 0) {
|
||||
long rts_val = shell_strtol(argv[1], 10, &err);
|
||||
|
||||
if (err) {
|
||||
shell_error(sh, "Unable to parse input (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
rts_threshold = (unsigned int)rts_val;
|
||||
}
|
||||
|
||||
if (net_mgmt(NET_REQUEST_WIFI_RTS_THRESHOLD, iface,
|
||||
&rts_threshold, sizeof(rts_threshold))) {
|
||||
shell_fprintf(sh, SHELL_WARNING,
|
||||
"Setting RTS threshold failed.\n");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
if ((int)rts_threshold >= 0)
|
||||
shell_fprintf(sh, SHELL_NORMAL, "RTS threshold: %d\n", rts_threshold);
|
||||
else
|
||||
shell_fprintf(sh, SHELL_NORMAL, "RTS threshold is off\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void parse_mode_args_to_params(const struct shell *sh, int argc,
|
||||
char *argv[], struct wifi_mode_info *mode,
|
||||
bool *do_mode_oper)
|
||||
|
@ -1976,6 +2010,12 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands,
|
|||
cmd_wifi_ps_wakeup_mode,
|
||||
2,
|
||||
0),
|
||||
SHELL_CMD_ARG(rts_threshold,
|
||||
NULL,
|
||||
"<rts_threshold: rts threshold/off>.\n",
|
||||
cmd_wifi_set_rts_threshold,
|
||||
2,
|
||||
0),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue