Commit e3f18254 authored by Fin Maaß's avatar Fin Maaß Committed by Carles Cufi
Browse files

mgmt: hawkbit: Add support for reboot after update



Add support for automatic reboot after successful update completion

Signed-off-by: default avatarFin Maaß <f.maass@vogl-electronic.com>
parent ef42f9d7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ void hawkbit_autohandler(void);
 */
enum hawkbit_response hawkbit_probe(void);

/**
 * @brief Request system to reboot.
 */
void hawkbit_reboot(void);

/**
 * @}
 */
+9 −3
Original line number Diff line number Diff line
@@ -952,6 +952,12 @@ static bool send_request(enum http_method method, enum hawkbit_http_request type
	return true;
}

void hawkbit_reboot(void)
{
	LOG_PANIC();
	sys_reboot(SYS_REBOOT_WARM);
}

enum hawkbit_response hawkbit_probe(void)
{
	int ret;
@@ -1186,8 +1192,7 @@ static void autohandler(struct k_work *work)
		LOG_ERR("Rebooting to previous confirmed image");
		LOG_ERR("If this image is flashed using a hardware tool");
		LOG_ERR("Make sure that it is a confirmed image");
		k_sleep(K_SECONDS(1));
		sys_reboot(SYS_REBOOT_WARM);
		hawkbit_reboot();
		break;

	case HAWKBIT_NO_UPDATE:
@@ -1203,7 +1208,8 @@ static void autohandler(struct k_work *work)
		break;

	case HAWKBIT_UPDATE_INSTALLED:
		LOG_INF("Update installed, please reboot");
		LOG_INF("Update installed");
		hawkbit_reboot();
		break;

	case HAWKBIT_DOWNLOAD_ERROR:
+2 −2
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
#include <zephyr/drivers/flash.h>
#include <zephyr/dfu/mcuboot.h>
#include <zephyr/dfu/flash_img.h>
#include <zephyr/sys/reboot.h>
#include <zephyr/mgmt/hawkbit.h>
#include "hawkbit_firmware.h"
#include "hawkbit_device.h"
@@ -25,7 +24,7 @@ static void cmd_run(const struct shell *sh, size_t argc, char **argv)
			sh, SHELL_ERROR,
			"Image is unconfirmed."
			"Rebooting to revert back to previous confirmed image\n");
		sys_reboot(SYS_REBOOT_WARM);
		hawkbit_reboot();
		break;

	case HAWKBIT_CANCEL_UPDATE:
@@ -43,6 +42,7 @@ static void cmd_run(const struct shell *sh, size_t argc, char **argv)

	case HAWKBIT_UPDATE_INSTALLED:
		shell_fprintf(sh, SHELL_INFO, "Update Installed\n");
		hawkbit_reboot();
		break;

	case HAWKBIT_DOWNLOAD_ERROR: