Skip to content

Commit a5d3264

Browse files
kapbhrlubos
authored andcommitted
[nrf fromlist] net: wifi: Add P2P power save shell command support
Add shell command support for P2P power save. Upstream PR #: 97183 Signed-off-by: Kapil Bhatt <[email protected]>
1 parent e71109a commit a5d3264

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,40 @@ static int cmd_wifi_p2p_invite(const struct shell *sh, size_t argc, char *argv[]
40764076
PR("P2P invite initiated\n");
40774077
return 0;
40784078
}
4079+
4080+
static int cmd_wifi_p2p_power_save(const struct shell *sh, size_t argc, char *argv[])
4081+
{
4082+
struct net_if *iface = get_iface(IFACE_TYPE_STA, argc, argv);
4083+
struct wifi_p2p_params params = {0};
4084+
bool power_save_enable = false;
4085+
4086+
context.sh = sh;
4087+
4088+
if (argc < 2) {
4089+
PR_ERROR("Usage: wifi p2p power_save <on|off>\n");
4090+
return -EINVAL;
4091+
}
4092+
4093+
if (strcmp(argv[1], "on") == 0) {
4094+
power_save_enable = true;
4095+
} else if (strcmp(argv[1], "off") == 0) {
4096+
power_save_enable = false;
4097+
} else {
4098+
PR_ERROR("Invalid argument. Use 'on' or 'off'\n");
4099+
return -EINVAL;
4100+
}
4101+
4102+
params.oper = WIFI_P2P_POWER_SAVE;
4103+
params.power_save = power_save_enable;
4104+
4105+
if (net_mgmt(NET_REQUEST_WIFI_P2P_OPER, iface, &params, sizeof(params))) {
4106+
PR_WARNING("P2P power save request failed\n");
4107+
return -ENOEXEC;
4108+
}
4109+
4110+
PR("P2P power save %s\n", power_save_enable ? "enabled" : "disabled");
4111+
return 0;
4112+
}
40794113
#endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P */
40804114

40814115
static int cmd_wifi_pmksa_flush(const struct shell *sh, size_t argc, char *argv[])
@@ -4851,6 +4885,13 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
48514885
"[-d, --go-dev-addr=<MAC>]: GO device address (for group type)\n"
48524886
"[-i, --iface=<interface index>]: Interface index\n",
48534887
cmd_wifi_p2p_invite, 2, 8),
4888+
SHELL_CMD_ARG(power_save, NULL,
4889+
"Set P2P power save mode\n"
4890+
"Usage: power_save <on|off>\n"
4891+
"<on>: Enable P2P power save\n"
4892+
"<off>: Disable P2P power save\n"
4893+
"[-i, --iface=<interface index>]: Interface index\n",
4894+
cmd_wifi_p2p_power_save, 2, 3),
48544895
SHELL_SUBCMD_SET_END
48554896
);
48564897

0 commit comments

Comments
 (0)