mgmt: hawkbit: use shell macros
use short shell macros for printing. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
parent
283d4133fa
commit
fb3704665a
1 changed files with 25 additions and 29 deletions
|
|
@ -18,52 +18,49 @@ static void cmd_run(const struct shell *sh, size_t argc, char **argv)
|
|||
ARG_UNUSED(argc);
|
||||
ARG_UNUSED(argv);
|
||||
|
||||
shell_fprintf(sh, SHELL_INFO, "Starting hawkBit run...\n");
|
||||
|
||||
shell_info(sh, "Starting hawkBit run...");
|
||||
switch (hawkbit_probe()) {
|
||||
case HAWKBIT_UNCONFIRMED_IMAGE:
|
||||
shell_fprintf(
|
||||
sh, SHELL_ERROR,
|
||||
"Image is unconfirmed."
|
||||
"Rebooting to revert back to previous confirmed image\n");
|
||||
hawkbit_reboot();
|
||||
shell_error(sh, "Image is unconfirmed."
|
||||
"Rebooting to revert back to previous confirmed image");
|
||||
break;
|
||||
|
||||
case HAWKBIT_CANCEL_UPDATE:
|
||||
shell_fprintf(sh, SHELL_INFO,
|
||||
"hawkBit update Cancelled from server\n");
|
||||
shell_info(sh, "hawkBit update cancelled from server");
|
||||
break;
|
||||
|
||||
case HAWKBIT_NO_UPDATE:
|
||||
shell_fprintf(sh, SHELL_INFO, "No update found\n");
|
||||
shell_info(sh, "No update found");
|
||||
break;
|
||||
|
||||
case HAWKBIT_OK:
|
||||
shell_fprintf(sh, SHELL_INFO, "Image Already updated\n");
|
||||
shell_info(sh, "Image already updated");
|
||||
break;
|
||||
|
||||
case HAWKBIT_UPDATE_INSTALLED:
|
||||
shell_fprintf(sh, SHELL_INFO, "Update Installed\n");
|
||||
shell_info(sh, "Update installed");
|
||||
hawkbit_reboot();
|
||||
break;
|
||||
|
||||
case HAWKBIT_DOWNLOAD_ERROR:
|
||||
shell_fprintf(sh, SHELL_INFO, "Download Error\n");
|
||||
shell_error(sh, "Download error");
|
||||
break;
|
||||
|
||||
case HAWKBIT_NETWORKING_ERROR:
|
||||
shell_fprintf(sh, SHELL_INFO, "Networking Error\n");
|
||||
shell_error(sh, "Networking error");
|
||||
break;
|
||||
|
||||
case HAWKBIT_METADATA_ERROR:
|
||||
shell_fprintf(sh, SHELL_INFO, "Metadata Error\n");
|
||||
shell_error(sh, "Metadata error");
|
||||
break;
|
||||
|
||||
case HAWKBIT_NOT_INITIALIZED:
|
||||
shell_fprintf(sh, SHELL_ERROR, "hawkBit not initialized\n");
|
||||
shell_error(sh, "hawkBit not initialized");
|
||||
break;
|
||||
|
||||
default:
|
||||
shell_fprintf(sh, SHELL_ERROR, "Invalid response\n");
|
||||
shell_error(sh, "Invalid response");
|
||||
break;
|
||||
}
|
||||
k_sleep(K_MSEC(1));
|
||||
|
|
@ -81,12 +78,11 @@ static int cmd_info(const struct shell *sh, size_t argc, char *argv)
|
|||
hawkbit_get_device_identity(device_id, DEVICE_ID_HEX_MAX_SIZE);
|
||||
|
||||
shell_print(sh, "Action id: %d", hawkbit_get_action_id());
|
||||
shell_fprintf(sh, SHELL_NORMAL, "Unique device id: %s\n", device_id);
|
||||
shell_fprintf(sh, SHELL_NORMAL, "Firmware Version: %s\n",
|
||||
firmware_version);
|
||||
shell_fprintf(sh, SHELL_NORMAL, "Server address: %s\n", hawkbit_get_server_addr());
|
||||
shell_fprintf(sh, SHELL_NORMAL, "Server port: %d\n", hawkbit_get_server_port());
|
||||
shell_fprintf(sh, SHELL_NORMAL, "DDI security token: %s\n",
|
||||
shell_print(sh, "Unique device id: %s", device_id);
|
||||
shell_print(sh, "Firmware Version: %s", firmware_version);
|
||||
shell_print(sh, "Server address: %s", hawkbit_get_server_addr());
|
||||
shell_print(sh, "Server port: %d", hawkbit_get_server_port());
|
||||
shell_print(sh, "DDI security token: %s",
|
||||
(IS_ENABLED(CONFIG_HAWKBIT_DDI_NO_SECURITY)
|
||||
? "<disabled>"
|
||||
: hawkbit_get_ddi_security_token()));
|
||||
|
|
@ -99,7 +95,7 @@ static int cmd_init(const struct shell *sh, size_t argc, char *argv)
|
|||
ARG_UNUSED(argc);
|
||||
ARG_UNUSED(argv);
|
||||
|
||||
shell_fprintf(sh, SHELL_INFO, "Init hawkBit ...\n");
|
||||
shell_info(sh, "Init hawkBit ...");
|
||||
|
||||
hawkbit_init();
|
||||
|
||||
|
|
@ -123,7 +119,7 @@ static int cmd_reset(const struct shell *sh, size_t argc, char *argv)
|
|||
static int cmd_set_addr(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
shell_fprintf(sh, SHELL_ERROR, "Invalid number of arguments\n");
|
||||
shell_error(sh, "Invalid number of arguments");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +131,7 @@ static int cmd_set_addr(const struct shell *sh, size_t argc, char **argv)
|
|||
static int cmd_set_port(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
shell_fprintf(sh, SHELL_ERROR, "Invalid number of arguments\n");
|
||||
shell_error(sh, "Invalid number of arguments");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +144,7 @@ static int cmd_set_port(const struct shell *sh, size_t argc, char **argv)
|
|||
static int cmd_set_token(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
shell_fprintf(sh, SHELL_ERROR, "Invalid number of arguments\n");
|
||||
shell_error(sh, "Invalid number of arguments");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue