net: wifi_mgmt: Add support for power save timeout configuration
Add support for configuring power save timeout in Wi-Fi chipsets. Changes to configure power save inactivity timer. Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
This commit is contained in:
parent
f05e8e8f27
commit
ba39235275
3 changed files with 70 additions and 0 deletions
|
@ -314,3 +314,24 @@ static int wifi_reg_domain(uint32_t mgmt_request, struct net_if *iface,
|
|||
}
|
||||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_REG_DOMAIN, wifi_reg_domain);
|
||||
|
||||
static int wifi_set_power_save_timeout(uint32_t mgmt_request, struct net_if *iface,
|
||||
void *data, size_t len)
|
||||
{
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
struct net_wifi_mgmt_offload *off_api =
|
||||
(struct net_wifi_mgmt_offload *) dev->api;
|
||||
struct wifi_ps_timeout_params *ps_timeout = data;
|
||||
|
||||
if (off_api == NULL || off_api->set_power_save_timeout == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (!data || len != sizeof(*ps_timeout)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return off_api->set_power_save_timeout(dev, ps_timeout);
|
||||
}
|
||||
|
||||
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_PS_TIMEOUT, wifi_set_power_save_timeout);
|
||||
|
|
|
@ -531,6 +531,40 @@ static int cmd_wifi_ps_mode(const struct shell *sh, size_t argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_wifi_ps_timeout(const struct shell *sh, size_t argc, char *argv[])
|
||||
{
|
||||
struct net_if *iface = net_if_get_default();
|
||||
struct wifi_ps_timeout_params params = { 0 };
|
||||
long timeout_ms = 0;
|
||||
int err = 0;
|
||||
|
||||
context.sh = sh;
|
||||
|
||||
if (argc != 2) {
|
||||
shell_fprintf(sh, SHELL_WARNING, "Invalid number of arguments\n");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
timeout_ms = shell_strtol(argv[1], 10, &err);
|
||||
|
||||
if (err) {
|
||||
shell_error(sh, "Unable to parse input (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
params.timeout_ms = timeout_ms;
|
||||
|
||||
if (net_mgmt(NET_REQUEST_WIFI_PS_TIMEOUT, iface, ¶ms, sizeof(params))) {
|
||||
shell_fprintf(sh, SHELL_WARNING, "Setting power save timeout failed\n");
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
shell_fprintf(sh, SHELL_NORMAL,
|
||||
"Power save timeout %d ms\n", params.timeout_ms);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
|
||||
char *argv[])
|
||||
{
|
||||
|
@ -853,6 +887,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands,
|
|||
"-f: Force to use this regulatory hint over any other regulatory hints\n"
|
||||
"Note: This may cause regulatory compliance issues, use it at your own risk.",
|
||||
cmd_wifi_reg_domain),
|
||||
SHELL_CMD(ps_timeout, NULL,
|
||||
"Configure Wi-Fi power save inactivity timer(in ms)",
|
||||
cmd_wifi_ps_timeout),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue