mgmt: hawkbit: add option for autohandler

add option for autohandler to only run once.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2024-04-22 08:47:48 +02:00 committed by Fabio Baltieri
parent 35d05b7198
commit cf5f6aad23
4 changed files with 15 additions and 6 deletions

View file

@ -92,8 +92,10 @@ int hawkbit_init(void);
*
* @details The hawkbit_autohandler handles the whole process
* in pre-determined time intervals.
*
* @param auto_reschedule If true, the handler will reschedule itself
*/
void hawkbit_autohandler(void);
void hawkbit_autohandler(bool auto_reschedule);
/**
* @brief The hawkBit probe verify if there is some update to be performed.

View file

@ -47,7 +47,6 @@ CONFIG_DNS_SERVER2="192.168.1.1"
CONFIG_SHELL=y
CONFIG_HAWKBIT_SHELL=y
CONFIG_KERNEL_SHELL=y
CONFIG_SHELL_STACK_SIZE=4096
#hawkBit polling mode
CONFIG_HAWKBIT_POLLING=y

View file

@ -83,7 +83,7 @@ int main(void)
#if defined(CONFIG_HAWKBIT_POLLING)
LOG_INF("Starting hawkBit polling mode");
hawkbit_autohandler();
hawkbit_autohandler(true);
#endif
#if defined(CONFIG_HAWKBIT_MANUAL)

View file

@ -148,6 +148,7 @@ static hawkbit_config_device_data_cb_handler_t hawkbit_config_device_data_cb_han
static void autohandler(struct k_work *work);
static K_WORK_DELAYABLE_DEFINE(hawkbit_work_handle, autohandler);
static K_WORK_DELAYABLE_DEFINE(hawkbit_work_handle_once, autohandler);
K_SEM_DEFINE(probe_sem, 1, 1);
@ -1526,10 +1527,17 @@ static void autohandler(struct k_work *work)
break;
}
k_work_reschedule(&hawkbit_work_handle, K_SECONDS(poll_sleep));
if (k_work_delayable_from_work(work) == &hawkbit_work_handle) {
k_work_reschedule(&hawkbit_work_handle, K_SECONDS(poll_sleep));
}
}
}
void hawkbit_autohandler(void)
void hawkbit_autohandler(bool auto_reschedule)
{
k_work_reschedule(&hawkbit_work_handle, K_NO_WAIT);
if (auto_reschedule) {
k_work_reschedule(&hawkbit_work_handle, K_NO_WAIT);
} else {
k_work_reschedule(&hawkbit_work_handle_once, K_NO_WAIT);
}
}