Line data Source code
1 1 : /*
2 : * Copyright (c) 2024 Vogl Electronic GmbH
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief hawkBit autohandler header file
10 : */
11 :
12 : /**
13 : * @brief hawkBit autohandler API.
14 : * @defgroup hawkbit_autohandler hawkBit autohandler API
15 : * @ingroup hawkbit
16 : * @{
17 : */
18 :
19 : #ifndef ZEPHYR_INCLUDE_MGMT_HAWKBIT_AUTOHANDLER_H_
20 : #define ZEPHYR_INCLUDE_MGMT_HAWKBIT_AUTOHANDLER_H_
21 :
22 : #include <zephyr/mgmt/hawkbit/hawkbit.h>
23 :
24 : /**
25 : * @brief Runs hawkBit probe and hawkBit update automatically
26 : *
27 : * @details The hawkbit_autohandler handles the whole process
28 : * in pre-determined time intervals.
29 : *
30 : * @param auto_reschedule If true, the handler will reschedule itself
31 : */
32 1 : void hawkbit_autohandler(bool auto_reschedule);
33 :
34 : /**
35 : * @brief Wait for the autohandler to finish.
36 : *
37 : * @param events Set of desired events on which to wait. Set to ::UINT32_MAX to wait for the
38 : * autohandler to finish one run, or BIT() together with a value from
39 : * ::hawkbit_response to wait for a specific event.
40 : * @param timeout Waiting period for the desired set of events or one of the
41 : * special values ::K_NO_WAIT and ::K_FOREVER.
42 : *
43 : * @return A value from ::hawkbit_response.
44 : */
45 1 : enum hawkbit_response hawkbit_autohandler_wait(uint32_t events, k_timeout_t timeout);
46 :
47 : /**
48 : * @brief Cancel the run of the hawkBit autohandler.
49 : *
50 : * @return a value from k_work_cancel_delayable().
51 : */
52 1 : int hawkbit_autohandler_cancel(void);
53 :
54 : /**
55 : * @brief Set the delay for the next run of the autohandler.
56 : *
57 : * @details This function will only delay the next run of the autohandler. The delay will not
58 : * persist after the autohandler runs.
59 : *
60 : * @param timeout The delay to set.
61 : * @param if_bigger If true, the delay will be set only if the new delay is bigger than the current
62 : * one.
63 : *
64 : * @retval 0 if @a if_bigger was true and the current delay was bigger than the new one.
65 : * @retval otherwise, a value from k_work_reschedule().
66 : */
67 1 : int hawkbit_autohandler_set_delay(k_timeout_t timeout, bool if_bigger);
68 :
69 : /**
70 : * @}
71 : */
72 :
73 : #endif /* ZEPHYR_INCLUDE_MGMT_HAWKBIT_AUTOHANDLER_H_ */
|