Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[nrf noup] wpa_supplicant: Remove non-output status
Browse files Browse the repository at this point in the history
fixup! [nrf noup] zephyr: Add support for WPA CLI zephyr

There is "OK/FAIL" status multipal times during
wifi commands. Make new interactive api for wap_cli
commands which prints "OK/FAIL". It will avoid prints
for wifi commands.

Signed-off-by: Kapil Bhatt <[email protected]>
  • Loading branch information
kapbh committed Dec 20, 2023
1 parent bd3f174 commit a7ea05c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/common/wpa_ctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ char * wpa_ctrl_get_remote_ifname(struct wpa_ctrl *ctrl);
#endif /* CONFIG_CTRL_IFACE_UDP */

int wpa_ctrl_command(struct wpa_ctrl *ctrl, const char *cmd);
int wpa_ctrl_command_interactive(struct wpa_ctrl *ctrl, const char *cmd);
int wpa_request(struct wpa_ctrl *ctrl, int argc, char *argv[]);

#ifdef __cplusplus
Expand Down
17 changes: 16 additions & 1 deletion wpa_supplicant/wpa_cli_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ static int wpa_cli_cmd(struct wpa_ctrl *ctrl, const char *cmd, int min_args,
{
char * buf = NULL;
int ret = 0;
bool interactive = 0;

for (int i = 0; i < argc; i++) {
if (strcmp(argv[i], "interactive") == 0) {
interactive = 1;
argv[i] = NULL;
argc--;
break;
}
}

if (argc < min_args) {
wpa_printf(MSG_INFO, "Invalid %s command - at least %d argument%s "
"required.\n", cmd, min_args,
Expand All @@ -58,7 +69,11 @@ static int wpa_cli_cmd(struct wpa_ctrl *ctrl, const char *cmd, int min_args,
ret = -1;
goto out;
}
ret = wpa_ctrl_command(ctrl, buf);

if (interactive)
ret = wpa_ctrl_command_interactive(ctrl, buf);
else
ret = wpa_ctrl_command(ctrl, buf);

out:
if (buf)
Expand Down
11 changes: 11 additions & 0 deletions wpa_supplicant/wpa_cli_zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct wpa_ctrl *mon_conn;
struct wpa_ctrl *global_ctrl_conn;
char *ifname_prefix = NULL;
extern struct wpa_global *global;
static bool print_ok = false;

static void wpa_cli_msg_cb(char *msg, size_t len)
{
Expand Down Expand Up @@ -78,6 +79,11 @@ static int _wpa_ctrl_command(struct wpa_ctrl *ctrl, const char *cmd, int print,
buf[len] = '\0';
if (buf[0] != '\0')
printf("%s", buf);
}else if(!print_ok){
buf[len] = '\0';
if (buf[0] != '\0')
printf("%s", buf);
print_ok = true;
}
return 0;
}
Expand Down Expand Up @@ -325,6 +331,11 @@ char supp_make_argv(size_t *argc, const char **argv, char *cmd,
}

int wpa_ctrl_command(struct wpa_ctrl *ctrl, const char *cmd)
{
return _wpa_ctrl_command(ctrl, cmd, 0, NULL);
}

int wpa_ctrl_command_interactive(struct wpa_ctrl *ctrl, const char *cmd)
{
return _wpa_ctrl_command(ctrl, cmd, 1, NULL);
}
Expand Down

0 comments on commit a7ea05c

Please sign in to comment.