File tree Expand file tree Collapse file tree 3 files changed +36
-7
lines changed
samples/subsys/mgmt/updatehub/src Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2018-2020 O.S.Systems
2+ * Copyright (c) 2018-2023 O.S.Systems
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
1010#include <zephyr/net/net_event.h>
1111#include <zephyr/net/net_conn_mgr.h>
1212#include <zephyr/net/wifi_mgmt.h>
13- #include <zephyr/dfu/mcuboot.h>
1413
1514#if defined(CONFIG_UPDATEHUB_DTLS )
1615#include <zephyr/net/tls_credentials.h>
@@ -45,7 +44,7 @@ void start_updatehub(void)
4544 switch (updatehub_update ()) {
4645 case UPDATEHUB_OK :
4746 ret = 0 ;
48- sys_reboot ( SYS_REBOOT_WARM );
47+ updatehub_reboot ( );
4948 break ;
5049
5150 default :
@@ -110,7 +109,7 @@ void main(void)
110109
111110 /* The image of application needed be confirmed */
112111 LOG_INF ("Confirming the boot image" );
113- ret = boot_write_img_confirmed ();
112+ ret = updatehub_confirm ();
114113 if (ret < 0 ) {
115114 LOG_ERR ("Error to confirm the image" );
116115 }
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2018 O.S.Systems
2+ * Copyright (c) 2018-2023 O.S.Systems
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -69,6 +69,23 @@ enum updatehub_response updatehub_probe(void);
6969 */
7070enum updatehub_response updatehub_update (void );
7171
72+ /**
73+ * @brief Confirm that image is running as expected.
74+ *
75+ * @details Must be used before the UpdateHub probe. It should be one of first
76+ * actions after reboot.
77+ *
78+ * @return Return 0 if success otherwise a negative @errorno value.
79+ */
80+ int updatehub_confirm (void );
81+
82+ /**
83+ * @brief Request system to reboot.
84+ *
85+ * @return Return 0 if success otherwise a negative @errorno value.
86+ */
87+ int updatehub_reboot (void );
88+
7289/**
7390 * @}
7491 */
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(updatehub, CONFIG_UPDATEHUB_LOG_LEVEL);
1919#include <zephyr/drivers/flash.h>
2020#include <zephyr/sys/reboot.h>
2121#include <zephyr/data/json.h>
22+ #include <zephyr/dfu/mcuboot.h>
2223#include <zephyr/storage/flash_map.h>
2324
2425#include "include/updatehub.h"
@@ -762,6 +763,18 @@ static void probe_cb(char *metadata, size_t metadata_size)
762763 LOG_INF ("Probe metadata received" );
763764}
764765
766+ int updatehub_confirm (void )
767+ {
768+ return boot_write_img_confirmed ();
769+ }
770+
771+ int updatehub_reboot (void )
772+ {
773+ sys_reboot (SYS_REBOOT_WARM );
774+
775+ return 0 ;
776+ }
777+
765778enum updatehub_response updatehub_probe (void )
766779{
767780 struct probe request ;
@@ -985,14 +998,14 @@ static void autohandler(struct k_work *work)
985998 "confirmed image." );
986999
9871000 LOG_PANIC ();
988- sys_reboot ( SYS_REBOOT_WARM );
1001+ updatehub_reboot ( );
9891002 break ;
9901003
9911004 case UPDATEHUB_HAS_UPDATE :
9921005 switch (updatehub_update ()) {
9931006 case UPDATEHUB_OK :
9941007 LOG_PANIC ();
995- sys_reboot ( SYS_REBOOT_WARM );
1008+ updatehub_reboot ( );
9961009 break ;
9971010
9981011 default :
You can’t perform that action at this time.
0 commit comments