Skip to content

Commit cf5f6aa

Browse files
maass-hamburgfabiobaltieri
authored andcommitted
mgmt: hawkbit: add option for autohandler
add option for autohandler to only run once. Signed-off-by: Fin Maaß <[email protected]>
1 parent 35d05b7 commit cf5f6aa

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

include/zephyr/mgmt/hawkbit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ int hawkbit_init(void);
9292
*
9393
* @details The hawkbit_autohandler handles the whole process
9494
* in pre-determined time intervals.
95+
*
96+
* @param auto_reschedule If true, the handler will reschedule itself
9597
*/
96-
void hawkbit_autohandler(void);
98+
void hawkbit_autohandler(bool auto_reschedule);
9799

98100
/**
99101
* @brief The hawkBit probe verify if there is some update to be performed.

samples/subsys/mgmt/hawkbit/prj.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ CONFIG_DNS_SERVER2="192.168.1.1"
4747
CONFIG_SHELL=y
4848
CONFIG_HAWKBIT_SHELL=y
4949
CONFIG_KERNEL_SHELL=y
50-
CONFIG_SHELL_STACK_SIZE=4096
5150

5251
#hawkBit polling mode
5352
CONFIG_HAWKBIT_POLLING=y

samples/subsys/mgmt/hawkbit/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int main(void)
8383

8484
#if defined(CONFIG_HAWKBIT_POLLING)
8585
LOG_INF("Starting hawkBit polling mode");
86-
hawkbit_autohandler();
86+
hawkbit_autohandler(true);
8787
#endif
8888

8989
#if defined(CONFIG_HAWKBIT_MANUAL)

subsys/mgmt/hawkbit/hawkbit.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static hawkbit_config_device_data_cb_handler_t hawkbit_config_device_data_cb_han
148148
static void autohandler(struct k_work *work);
149149

150150
static K_WORK_DELAYABLE_DEFINE(hawkbit_work_handle, autohandler);
151+
static K_WORK_DELAYABLE_DEFINE(hawkbit_work_handle_once, autohandler);
151152

152153
K_SEM_DEFINE(probe_sem, 1, 1);
153154

@@ -1526,10 +1527,17 @@ static void autohandler(struct k_work *work)
15261527
break;
15271528
}
15281529

1529-
k_work_reschedule(&hawkbit_work_handle, K_SECONDS(poll_sleep));
1530+
if (k_work_delayable_from_work(work) == &hawkbit_work_handle) {
1531+
k_work_reschedule(&hawkbit_work_handle, K_SECONDS(poll_sleep));
1532+
}
1533+
}
15301534
}
15311535

1532-
void hawkbit_autohandler(void)
1536+
void hawkbit_autohandler(bool auto_reschedule)
15331537
{
1534-
k_work_reschedule(&hawkbit_work_handle, K_NO_WAIT);
1538+
if (auto_reschedule) {
1539+
k_work_reschedule(&hawkbit_work_handle, K_NO_WAIT);
1540+
} else {
1541+
k_work_reschedule(&hawkbit_work_handle_once, K_NO_WAIT);
1542+
}
15351543
}

0 commit comments

Comments
 (0)