drivers: wifi: eswifi: Add debug shell

Add a esWiFi shell for device specific controls.
For now used to send at commands.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
This commit is contained in:
Loic Poulain 2020-07-07 19:15:04 +02:00 committed by Jukka Rissanen
commit e7c4d29c86
5 changed files with 78 additions and 0 deletions

View file

@ -14,5 +14,8 @@ if(CONFIG_WIFI_ESWIFI)
eswifi_offload.c
eswifi_socket.c
)
zephyr_sources_ifdef(CONFIG_WIFI_ESWIFI_SHELL eswifi_shell.c)
zephyr_sources_ifdef(CONFIG_NET_SOCKETS_OFFLOAD eswifi_socket_offload.c)
endif()

View file

@ -24,4 +24,10 @@ config WIFI_ESWIFI_THREAD_PRIO
This option sets the priority of the esWiFi threads.
Do not touch it unless you know what you are doing.
config WIFI_ESWIFI_SHELL
bool "esWiFi shell"
depends on SHELL
help
Enable esWiFi shell
endif

View file

@ -144,4 +144,10 @@ int __eswifi_bind(struct eswifi_dev *eswifi, struct eswifi_off_socket *socket,
int eswifi_socket_offload_init(struct eswifi_dev *leswifi);
#endif
#if defined(CONFIG_WIFI_ESWIFI_SHELL)
void eswifi_shell_register(struct eswifi_dev *dev);
#else
#define eswifi_shell_register(dev)
#endif
#endif

View file

@ -671,6 +671,8 @@ static int eswifi_init(struct device *dev)
k_work_init(&eswifi->request_work, eswifi_request_work);
eswifi_shell_register(eswifi);
return 0;
}

View file

@ -0,0 +1,61 @@
/**
* Copyright (c) 2020 Linaro
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <shell/shell.h>
#include "eswifi.h"
static struct eswifi_dev *eswifi;
void eswifi_shell_register(struct eswifi_dev *dev)
{
/* only one instance supported */
if (eswifi) {
return;
}
eswifi = dev;
}
static int eswifi_shell_atcmd(const struct shell *shell, size_t argc,
char **argv)
{
int i;
if (eswifi == NULL) {
shell_print(shell, "no eswifi device registered");
return -ENOEXEC;
}
if (argc < 2) {
shell_help(shell);
return -ENOEXEC;
}
eswifi_lock(eswifi);
memset(eswifi->buf, 0, sizeof(eswifi->buf));
for (i = 1; i < argc; i++) {
strcat(eswifi->buf, argv[i]);
}
strcat(eswifi->buf, "\r");
shell_print(shell, "> %s", eswifi->buf);
eswifi_at_cmd(eswifi, eswifi->buf);
shell_print(shell, "< %s", eswifi->buf);
eswifi_unlock(eswifi);
return 0;
}
SHELL_STATIC_SUBCMD_SET_CREATE(eswifi_shell,
SHELL_CMD(atcmd, NULL, "<atcmd>", eswifi_shell_atcmd),
SHELL_SUBCMD_SET_END /* Array terminated. */
);
SHELL_CMD_REGISTER(eswifi, &eswifi_shell, "esWiFi debug shell", NULL);