/ bm_common_structs.h
bm_common_structs.h
1 #pragma once 2 3 #include <stdbool.h> 4 #include <stdint.h> 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 ///////////////////////////// 11 /* CONFIGURATION*/ 12 ///////////////////////////// 13 typedef enum { 14 BM_COMMON_CFG_PARTITION_USER, 15 BM_COMMON_CFG_PARTITION_SYSTEM, 16 BM_COMMON_CFG_PARTITION_HARDWARE, 17 } bm_common_config_partition_e; 18 19 typedef struct { 20 // Node ID of the target node for which the request is being made. 21 uint64_t target_node_id; 22 // Node ID of the source node 23 uint64_t source_node_id; 24 // message payload 25 uint8_t payload[0]; 26 } __attribute__((packed)) bm_common_config_header_t; 27 28 typedef struct { 29 bm_common_config_header_t header; 30 // Partition id 31 bm_common_config_partition_e partition; 32 // String length of the key (without terminator) 33 uint8_t key_length; 34 // Key string 35 char key[0]; 36 } __attribute__((packed)) bm_common_config_get_t; 37 38 typedef struct { 39 bm_common_config_header_t header; 40 // Partition id 41 bm_common_config_partition_e partition; 42 // Length of cbor buffer 43 uint32_t data_length; 44 // cbor buffer 45 uint8_t data[0]; 46 } __attribute__((packed)) bm_common_config_value_t; 47 48 typedef struct { 49 bm_common_config_header_t header; 50 // Partition id 51 bm_common_config_partition_e partition; 52 // String length of the key (without terminator) 53 uint8_t key_length; 54 // Length of cbor encoded data buffer 55 uint32_t data_length; 56 // cbor encoded data 57 uint8_t keyAndData[0]; 58 } __attribute__((packed)) bm_common_config_set_t; 59 60 typedef struct { 61 bm_common_config_header_t header; 62 // Partition id 63 bm_common_config_partition_e partition; 64 } __attribute__((packed)) bm_common_config_commit_t; 65 66 typedef struct { 67 bm_common_config_header_t header; 68 // Partition id 69 bm_common_config_partition_e partition; 70 } __attribute__((packed)) bm_common_config_status_request_t; 71 72 typedef struct { 73 // String length of the key (without terminator) 74 uint8_t key_length; 75 // Key string 76 char key[0]; 77 } __attribute__((packed)) bm_common_config_status_key_data_t; 78 79 typedef struct { 80 bm_common_config_header_t header; 81 // Partition id 82 bm_common_config_partition_e partition; 83 // True if there are changes to be committed, false otherwise. 84 bool committed; 85 // Number of keys 86 uint8_t num_keys; 87 // Key Data 88 uint8_t keyData[0]; 89 } __attribute__((packed)) bm_common_config_status_response_t; 90 91 typedef struct { 92 bm_common_config_header_t header; 93 // Partition id 94 bm_common_config_partition_e partition; 95 // String length of the key (without terminator) 96 uint8_t key_length; 97 // Key string 98 char key[0]; 99 } __attribute__((packed)) bm_common_config_delete_key_request_t; 100 101 typedef struct { 102 bm_common_config_header_t header; 103 // success 104 bool success; 105 // Partition id 106 bm_common_config_partition_e partition; 107 // String length of the key (without terminator) 108 uint8_t key_length; 109 // Key string 110 char key[0]; 111 } __attribute__((packed)) bm_common_config_delete_key_response_t; 112 113 typedef enum { 114 BM_COMMON_WIRELESS_NETWORK_TYPE_CELLULAR_IRI_FALLBACK = (1 << 0), 115 BM_COMMON_WIRELESS_NETWORK_TYPE_CELLULAR_ONLY = (1 << 1), 116 } bm_common_wireless_network_type_e; 117 118 typedef struct { 119 // Wireless network type to send over. 120 bm_common_wireless_network_type_e type; 121 // Data 122 uint8_t data[0]; 123 } __attribute__((packed)) bm_common_wireless_network_data_header_t; 124 125 typedef struct { 126 // Partition id 127 bm_common_config_partition_e partition; 128 // Partion crc 129 uint32_t crc32; 130 } __attribute__((packed)) bm_common_config_crc_t; 131 132 typedef struct { 133 // fw version 134 uint8_t major; 135 uint8_t minor; 136 uint8_t revision; 137 uint32_t gitSHA; 138 } __attribute__((packed)) bm_common_fw_version_t; 139 140 typedef struct { 141 // crc of the this message (excluding itself) 142 uint32_t network_crc32; 143 // Config crc 144 bm_common_config_crc_t config_crc; 145 // fw info 146 bm_common_fw_version_t fw_info; 147 // Number of nodes in the topology 148 uint16_t num_nodes; 149 // Size of the map in bytes 150 uint16_t map_size_bytes; 151 // Node list (node size uint64_t) and cbor config map 152 uint8_t node_list_and_cbor_config_map[0]; 153 } __attribute__((packed)) bm_common_network_info_t; 154 155 typedef enum { 156 BM_COMMON_LOG_LEVEL_NONE = 0, 157 BM_COMMON_LOG_LEVEL_FATAL = 1, 158 BM_COMMON_LOG_LEVEL_ERROR = 2, 159 BM_COMMON_LOG_LEVEL_WARNING = 3, 160 BM_COMMON_LOG_LEVEL_INFO = 4, 161 BM_COMMON_LOG_LEVEL_DEBUG = 5, 162 } bm_common_log_level_e; 163 164 typedef struct { 165 // Log level 166 bm_common_log_level_e level; 167 // String length of the message (without terminator) 168 uint32_t message_length; 169 // print header (true) or not (false) 170 bool print_header; 171 // timestamp UTC 172 uint64_t timestamp_utc_s; 173 // Message string 174 char message[0]; 175 } __attribute__((packed)) bm_common_log_t; 176 177 #ifdef __cplusplus 178 } 179 #endif