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 11 */ 12 13 #ifndef __HAWKBIT_PRIV_H__ 14 #define __HAWKBIT_PRIV_H__ 15 16 #include <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_CLOSE, 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 enum hawkbit_dev_acid_t { 46 HAWKBIT_ACTION_ID_CURRENT = 0, 47 HAWKBIT_ACTION_ID_UPDATE, 48 }; 49 50 struct hawkbit_href { 51 const char *href; 52 }; 53 54 struct hawkbit_status_result { 55 const char *finished; 56 }; 57 58 struct hawkbit_status { 59 struct hawkbit_status_result result; 60 const char *execution; 61 }; 62 63 struct hawkbit_ctl_res_sleep { 64 const char *sleep; 65 }; 66 67 struct hawkbit_ctl_res_polling { 68 struct hawkbit_ctl_res_sleep polling; 69 }; 70 71 struct hawkbit_ctl_res_links { 72 struct hawkbit_href deploymentBase; 73 struct hawkbit_href configData; 74 struct hawkbit_href cancelAction; 75 }; 76 77 struct hawkbit_ctl_res { 78 struct hawkbit_ctl_res_polling config; 79 struct hawkbit_ctl_res_links _links; 80 }; 81 82 struct hawkbit_cfg_data { 83 const char *VIN; 84 const char *hwRevision; 85 }; 86 87 struct hawkbit_cfg { 88 const char *mode; 89 struct hawkbit_cfg_data data; 90 const char *id; 91 const char *time; 92 struct hawkbit_status status; 93 }; 94 95 struct hawkbit_close { 96 char *id; 97 const char *time; 98 struct hawkbit_status status; 99 }; 100 101 /* Maximum number of chunks we support */ 102 #define HAWKBIT_DEP_MAX_CHUNKS 1 103 /* Maximum number of artifacts per chunk. */ 104 #define HAWKBIT_DEP_MAX_CHUNK_ARTS 1 105 106 struct hawkbit_dep_res_hashes { 107 const char *sha1; 108 const char *md5; 109 const char *sha256; 110 }; 111 112 struct hawkbit_dep_res_links { 113 struct hawkbit_href download_http; 114 struct hawkbit_href md5sum_http; 115 }; 116 117 struct hawkbit_dep_res_arts { 118 const char *filename; 119 struct hawkbit_dep_res_hashes hashes; 120 struct hawkbit_dep_res_links _links; 121 int size; 122 }; 123 124 struct hawkbit_dep_res_chunk { 125 const char *part; 126 const char *name; 127 const char *version; 128 struct hawkbit_dep_res_arts artifacts[HAWKBIT_DEP_MAX_CHUNK_ARTS]; 129 size_t num_artifacts; 130 }; 131 132 struct hawkbit_dep_res_deploy { 133 const char *download; 134 const char *update; 135 struct hawkbit_dep_res_chunk chunks[HAWKBIT_DEP_MAX_CHUNKS]; 136 size_t num_chunks; 137 }; 138 139 struct hawkbit_dep_res { 140 const char *id; 141 struct hawkbit_dep_res_deploy deployment; 142 }; 143 144 struct hawkbit_dep_fbk { 145 const char *id; 146 struct hawkbit_status status; 147 }; 148 149 struct hawkbit_cancel { 150 struct hawkbit_href cancelBase; 151 }; 152 153 struct entry { 154 char *http_req_str; 155 int n; 156 }; 157 158 struct entry http_request[] = { 159 {"HAWKBIT_PROBE", 0}, 160 {"HAWKBIT_CONFIG_DEVICE", 1}, 161 {"HAWKBIT_CLOSE", 2}, 162 {"HAWKBIT_PROBE_DEPLOYMENT_BASE", 3}, 163 {"HAWKBIT_REPORT", 4}, 164 {"HAWKBIT_DOWNLOAD", 5}, 165 }; 166 167 #endif /* __HAWKBIT_PRIV_H__ */ 168