Google Cloud IoT device SDK for embedded C  1.0.2
iotc_types.h
Go to the documentation of this file.
1 /* Copyright 2018-2020 Google LLC
2  *
3  * This is part of the Google Cloud IoT Device SDK for Embedded C.
4  * It is licensed under the BSD 3-Clause license; you may not use this file
5  * except in compliance with the License.
6  *
7  * You may obtain a copy of the License at:
8  * https://opensource.org/licenses/BSD-3-Clause
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __IOTC_TYPES_H__
18 #define __IOTC_TYPES_H__
19 #include <stddef.h>
20 #include <stdint.h>
21 
22 #include <iotc_error.h>
23 #include <iotc_mqtt.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
35 #define IOTC_INVALID_CONTEXT_HANDLE -1
36 
38 #define IOTC_INVALID_TIMED_TASK_HANDLE -1
39 
44 typedef int32_t iotc_context_handle_t;
45 
50 typedef int32_t iotc_timed_task_handle_t;
51 
64  const iotc_context_handle_t context_handle,
65  const iotc_timed_task_handle_t timed_task_handle, void* user_data);
66 
78 typedef void(iotc_user_callback_t)(iotc_context_handle_t in_context_handle,
79  void* data, iotc_state_t state);
80 
95 
106 typedef union iotc_sub_call_params_u {
111  struct {
119  const char* topic;
125  } suback;
126 
131  struct {
132  const char* topic;
138  const uint8_t* temporary_payload_data;
159  } message;
161 
164 #define IOTC_EMPTY_SUB_CALL_PARAMS \
165  (iotc_sub_call_params_t) { \
166  .message = { \
167  NULL, \
168  NULL, \
169  0, \
170  IOTC_MQTT_RETAIN_FALSE, \
171  IOTC_MQTT_QOS_AT_MOST_ONCE, \
172  IOTC_MQTT_DUP_FALSE \
173  } \
174  }
175 
188  iotc_context_handle_t in_context_handle, iotc_sub_call_type_t call_type,
189  const iotc_sub_call_params_t* const params, iotc_state_t state,
190  void* user_data);
191 
211 
220 typedef union iotc_crypto_key_union_u {
222  struct {
224  char* key;
225  } key_pem;
226 
228  struct {
230  uint8_t slot_id;
231  } key_slot;
232 
234  struct {
236  void* data;
238  size_t data_size;
239  } key_custom;
241 
253 
260 typedef struct {
270 
271 #ifdef __cplusplus
272 }
273 #endif
274 
275 #endif /* __IOTC_TYPES_H__ */
Defines state messages and their numeric codes.
struct iotc_crypto_key_union_u::@4 key_custom
enum iotc_mqtt_retain_e iotc_mqtt_retain_t
The MQTT retain flag.
The MQTT header flags.
The parameters with which to create JWTs.
Definition: iotc_types.h:260
iotc_crypto_key_union_type_t crypto_key_union_type
The internal code that represents the data type of the public or private key.
Definition: iotc_types.h:263
const char * topic
The MQTT topic.
Definition: iotc_types.h:119
union iotc_sub_call_params_u iotc_sub_call_params_t
The operational data for the user-defined subscription callback.
The operational data for the user-defined subscription callback.
Definition: iotc_types.h:106
enum iotc_mqtt_qos_e iotc_mqtt_qos_t
The MQTT Quality of Service levels.
void() iotc_user_task_callback_t(const iotc_context_handle_t context_handle, const iotc_timed_task_handle_t timed_task_handle, void *user_data)
A custom callback for timed tasks.
Definition: iotc_types.h:63
iotc_mqtt_dup_t dup_flag
The MQTT DUP flag.
Definition: iotc_types.h:158
enum iotc_crypto_key_signature_algorithm_e iotc_crypto_key_signature_algorithm_t
The ES256 algorithm with which to sign JWTs.
iotc_mqtt_retain_t retain
The MQTT retain flag.
Definition: iotc_types.h:148
iotc_crypto_key_union_t crypto_key_union
The public or private key data.
Definition: iotc_types.h:265
enum iotc_mqtt_suback_status_e iotc_mqtt_suback_status_t
The MQTT SUBACK payload.
enum iotc_mqtt_dup_e iotc_mqtt_dup_t
The MQTT DUP flag.
The signature algorithm is an ECDSA with P-256 and SHA-256.
Definition: iotc_types.h:251
union iotc_crypto_key_union_u iotc_crypto_key_union_t
The public or private key data.
The signature algorithm is invalid.
Definition: iotc_types.h:249
enum iotc_subscription_data_type_e iotc_sub_call_type_t
The data type of the user-defined subscription callback.
const uint8_t * temporary_payload_data
Definition: iotc_types.h:138
The public or private key data.
Definition: iotc_types.h:220
iotc_crypto_key_signature_algorithm_e
Definition: iotc_types.h:247
uint8_t slot_id
A slot ID.
Definition: iotc_types.h:230
iotc_state_t
The state of the client application.
Definition: iotc_error.h:32
struct iotc_sub_call_params_u::@0 suback
The MQTT SUBACK packet.
int32_t iotc_context_handle_t
An internal context handle.
Definition: iotc_types.h:44
The callback is a MESSAGE notification.
Definition: iotc_types.h:93
iotc_crypto_key_signature_algorithm_t crypto_key_signature_algorithm
The ES256 algorithm with which to sign JWTs.
Definition: iotc_types.h:268
struct iotc_crypto_key_union_u::@2 key_pem
A PEM-formatted public or private key.
enum iotc_crypto_key_union_type_e iotc_crypto_key_union_type_t
The internal code that represents the data type of the public or private key.
The public or private key data is a null-terminated PEM string.
Definition: iotc_types.h:202
The callback is a SUBACK notification.
Definition: iotc_types.h:91
size_t data_size
The size, in bytes, of the untyped data.
Definition: iotc_types.h:238
void() iotc_user_subscription_callback_t(iotc_context_handle_t in_context_handle, iotc_sub_call_type_t call_type, const iotc_sub_call_params_t *const params, iotc_state_t state, void *user_data)
The subscription callback.
Definition: iotc_types.h:187
struct iotc_sub_call_params_u::@1 message
The MQTT PUBLISH packet.
iotc_mqtt_qos_t qos
The MQTT Quality of Service levels.
Definition: iotc_types.h:153
iotc_crypto_key_union_type_e
Definition: iotc_types.h:199
iotc_mqtt_suback_status_t suback_status
The MQTT SUBACK payload.
Definition: iotc_types.h:124
void() iotc_user_callback_t(iotc_context_handle_t in_context_handle, void *data, iotc_state_t state)
Definition: iotc_types.h:78
int32_t iotc_timed_task_handle_t
The handle to identify timed tasks.
Definition: iotc_types.h:50
size_t temporary_payload_data_length
The length, in bytes, of the MQTT PUBLISH payload.
Definition: iotc_types.h:143
void * data
The data in the format that the BSP determined.
Definition: iotc_types.h:236
iotc_subscription_data_type_e
Definition: iotc_types.h:87
struct iotc_crypto_key_union_u::@3 key_slot
The slot IDs of secure elements.
char * key
The text of the public or private key.
Definition: iotc_types.h:224