1 /*
2  * Copyright (c) 2020 Linumiz
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /** @file
8  *
9  * @brief This file contains structures representing JSON messages
10  * exchanged with a hawkBit server
11  */
12 
13 #ifndef __HAWKBIT_PRIV_H__
14 #define __HAWKBIT_PRIV_H__
15 
16 #include <zephyr/data/json.h>
17 
18 #define HAWKBIT_SLEEP_LENGTH 8
19 
20 enum hawkbit_http_request {
21 	HAWKBIT_PROBE,
22 	HAWKBIT_CONFIG_DEVICE,
23 	HAWKBIT_CANCEL,
24 	HAWKBIT_PROBE_DEPLOYMENT_BASE,
25 	HAWKBIT_REPORT,
26 	HAWKBIT_DOWNLOAD,
27 };
28 
29 enum hawkbit_status_fini {
30 	HAWKBIT_STATUS_FINISHED_SUCCESS,
31 	HAWKBIT_STATUS_FINISHED_FAILURE,
32 	HAWKBIT_STATUS_FINISHED_NONE,
33 };
34 
35 enum hawkbit_status_exec {
36 	HAWKBIT_STATUS_EXEC_CLOSED = 0,
37 	HAWKBIT_STATUS_EXEC_PROCEEDING,
38 	HAWKBIT_STATUS_EXEC_CANCELED,
39 	HAWKBIT_STATUS_EXEC_SCHEDULED,
40 	HAWKBIT_STATUS_EXEC_REJECTED,
41 	HAWKBIT_STATUS_EXEC_RESUMED,
42 	HAWKBIT_STATUS_EXEC_NONE,
43 };
44 
45 struct hawkbit_href {
46 	const char *href;
47 };
48 
49 struct hawkbit_status_result {
50 	const char *finished;
51 };
52 
53 struct hawkbit_status {
54 	struct hawkbit_status_result result;
55 	const char *execution;
56 };
57 
58 struct hawkbit_ctl_res_sleep {
59 	const char *sleep;
60 };
61 
62 struct hawkbit_ctl_res_polling {
63 	struct hawkbit_ctl_res_sleep polling;
64 };
65 
66 struct hawkbit_ctl_res_links {
67 	struct hawkbit_href deploymentBase;
68 	struct hawkbit_href configData;
69 	struct hawkbit_href cancelAction;
70 };
71 
72 struct hawkbit_ctl_res {
73 	struct hawkbit_ctl_res_polling config;
74 	struct hawkbit_ctl_res_links _links;
75 };
76 
77 struct hawkbit_cfg_data {
78 	const char *VIN;
79 };
80 
81 struct hawkbit_cfg {
82 	const char *mode;
83 	struct hawkbit_cfg_data data;
84 };
85 
86 struct hawkbit_cancel {
87 	struct hawkbit_status status;
88 };
89 
90 /* Maximum number of chunks we support */
91 #define HAWKBIT_DEP_MAX_CHUNKS 1
92 /* Maximum number of artifacts per chunk. */
93 #define HAWKBIT_DEP_MAX_CHUNK_ARTS 1
94 
95 struct hawkbit_dep_res_hashes {
96 	const char *sha1;
97 	const char *md5;
98 	const char *sha256;
99 };
100 
101 struct hawkbit_dep_res_links {
102 	struct hawkbit_href download_http;
103 	struct hawkbit_href md5sum_http;
104 };
105 
106 struct hawkbit_dep_res_arts {
107 	const char *filename;
108 	struct hawkbit_dep_res_hashes hashes;
109 	struct hawkbit_dep_res_links _links;
110 	int size;
111 };
112 
113 struct hawkbit_dep_res_chunk {
114 	const char *part;
115 	const char *name;
116 	const char *version;
117 	struct hawkbit_dep_res_arts artifacts[HAWKBIT_DEP_MAX_CHUNK_ARTS];
118 	size_t num_artifacts;
119 };
120 
121 struct hawkbit_dep_res_deploy {
122 	const char *download;
123 	const char *update;
124 	struct hawkbit_dep_res_chunk chunks[HAWKBIT_DEP_MAX_CHUNKS];
125 	size_t num_chunks;
126 };
127 
128 struct hawkbit_dep_res {
129 	const char *id;
130 	struct hawkbit_dep_res_deploy deployment;
131 };
132 
133 struct hawkbit_dep_fbk {
134 	struct hawkbit_status status;
135 };
136 
137 #endif /* __HAWKBIT_PRIV_H__ */
138