1 /*
2  * Copyright (c) 2020 Linumiz
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @brief hawkBit Firmware Over-the-Air for Zephyr Project.
9  * @defgroup hawkbit hawkBit Firmware Over-the-Air
10  * @ingroup third_party
11  * @{
12  */
13 #ifndef ZEPHYR_INCLUDE_MGMT_HAWKBIT_H_
14 #define ZEPHYR_INCLUDE_MGMT_HAWKBIT_H_
15 
16 #define HAWKBIT_JSON_URL "/default/controller/v1"
17 
18 /**
19  * @brief Response message from hawkBit.
20  *
21  * @details These messages are used to inform the server and the
22  * user about the process status of the hawkBit and also
23  * used to standardize the errors that may occur.
24  *
25  */
26 enum hawkbit_response {
27 	HAWKBIT_NETWORKING_ERROR,
28 	HAWKBIT_UNCONFIRMED_IMAGE,
29 	HAWKBIT_METADATA_ERROR,
30 	HAWKBIT_DOWNLOAD_ERROR,
31 	HAWKBIT_OK,
32 	HAWKBIT_UPDATE_INSTALLED,
33 	HAWKBIT_NO_UPDATE,
34 	HAWKBIT_CANCEL_UPDATE,
35 	HAWKBIT_PROBE_IN_PROGRESS,
36 };
37 
38 /**
39  * @brief Init the flash partition
40  *
41  * @return 0 on success, negative on error.
42  */
43 int hawkbit_init(void);
44 
45 /**
46  * @brief Runs hawkBit probe and hawkBit update automatically
47  *
48  * @details The hawkbit_autohandler handles the whole process
49  * in pre-determined time intervals.
50  */
51 void hawkbit_autohandler(void);
52 
53 /**
54  * @brief The hawkBit probe verify if there is some update to be performed.
55  *
56  * @return HAWKBIT_UPDATE_INSTALLED has an update available.
57  * @return HAWKBIT_NO_UPDATE no update available.
58  * @return HAWKBIT_NETWORKING_ERROR fail to connect to the hawkBit server.
59  * @return HAWKBIT_METADATA_ERROR fail to parse or to encode the metadata.
60  * @return HAWKBIT_OK if success.
61  * @return HAWKBIT_DOWNLOAD_ERROR fail while downloading the update package.
62  */
63 enum hawkbit_response hawkbit_probe(void);
64 
65 /**
66  * @}
67  */
68 
69 #endif /* _HAWKBIT_H_ */
70