Google Cloud IoT device SDK for embedded C  1.0.2
iotc.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_H__
18 #define __IOTC_H__
19 
20 #include <stdint.h>
21 #include <stdlib.h>
22 
23 #include <iotc_connection_data.h>
24 #include <iotc_mqtt.h>
25 #include <iotc_time.h>
26 #include <iotc_types.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
134 /* -----------------------------------------------------------------------
135  * MAIN LIBRARY FUNCTIONS
136  * ----------------------------------------------------------------------- */
137 
146 
152 extern iotc_state_t iotc_shutdown();
153 
161 
173 
184 extern uint8_t iotc_is_context_connected(iotc_context_handle_t context_handle);
185 
202 extern void iotc_events_process_blocking();
203 
216 
220 extern void iotc_events_stop();
221 
247  const char* username, const char* password,
248  const char* client_id,
249  uint16_t connection_timeout,
250  uint16_t keepalive_timeout,
251  iotc_user_callback_t* client_callback);
252 
278  const char* host, uint16_t port,
279  const char* username, const char* password,
280  const char* client_id,
281  uint16_t connection_timeout,
282  uint16_t keepalive_timeout,
283  iotc_user_callback_t* client_callback);
284 
301  const char* topic, const char* msg,
302  const iotc_mqtt_qos_t qos,
303  iotc_user_callback_t* callback,
304  void* user_data);
305 
324  const char* topic, const uint8_t* data,
325  size_t data_len,
326  const iotc_mqtt_qos_t qos,
327  iotc_user_callback_t* callback,
328  void* user_data);
329 
343  const char* topic, const iotc_mqtt_qos_t qos,
345  void* user_data);
346 
357 
379  const iotc_time_t seconds_from_now, const uint8_t repeats_forever,
380  void* data);
381 
388 void iotc_cancel_timed_task(iotc_timed_task_handle_t timed_task_handle);
389 
390 /*-----------------------------------------------------------------------
391  * HELPER FUNCTIONS
392  * ---------------------------------------------------------------------- */
393 
406 extern void iotc_set_network_timeout(uint32_t timeout);
407 
412 extern uint32_t iotc_get_network_timeout(void);
413 
423 iotc_state_t iotc_set_maximum_heap_usage(const size_t max_bytes);
424 
433 iotc_state_t iotc_get_heap_usage(size_t* const heap_usage);
434 
438 extern const uint16_t iotc_major;
439 
443 extern const uint16_t iotc_minor;
444 
448 extern const uint16_t iotc_revision;
449 
453 extern const char iotc_cilent_version_str[];
454 
455 #ifdef IOTC_EXPOSE_FS
456 #include "iotc_fs_api.h"
457 
463 iotc_state_t iotc_set_fs_functions(const iotc_fs_functions_t fs_functions);
464 
465 #endif /* IOTC_EXPOSE_FS */
466 
467 #ifdef __cplusplus
468 }
469 #endif
470 
471 #endif /* __IOTC_H__ */
iotc_state_t iotc_events_process_tick()
iotc_state_t iotc_initialize()
iotc_state_t iotc_shutdown()
The MQTT header flags.
iotc_timed_task_handle_t iotc_schedule_timed_task(iotc_context_handle_t iotc_h, iotc_user_task_callback_t *callback, const iotc_time_t seconds_from_now, const uint8_t repeats_forever, void *data)
Returns a unique ID for the scheduled task and invokes a callback after an interval.
iotc_state_t iotc_get_heap_usage(size_t *const heap_usage)
const uint16_t iotc_revision
The SDK revision number.
uint8_t iotc_is_context_connected(iotc_context_handle_t context_handle)
Checks if a context is connected to Cloud IoT Core.
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
const uint16_t iotc_major
The SDK major version number.
Defines connection states.
iotc_state_t iotc_publish(iotc_context_handle_t iotc_h, const char *topic, const char *msg, const iotc_mqtt_qos_t qos, iotc_user_callback_t *callback, void *user_data)
Publishes a message to an MQTT topic.
const char iotc_cilent_version_str[]
The SDK "{@link ::iotc_major major}.{@link ::iotc_minor minor}.{@link ::iotc_revision revision}" vers...
void iotc_set_network_timeout(uint32_t timeout)
Sets the connection timeout.
void iotc_events_process_blocking()
iotc_context_handle_t iotc_create_context()
iotc_state_t
The state of the client application.
Definition: iotc_error.h:32
iotc_state_t iotc_connect_to(iotc_context_handle_t iotc_h, const char *host, uint16_t port, const char *username, const char *password, const char *client_id, uint16_t connection_timeout, uint16_t keepalive_timeout, iotc_user_callback_t *client_callback)
Connects to a custom MQTT broker endpoint.
void iotc_events_stop()
Shuts down the event engine.
const uint16_t iotc_minor
The SDK minor version number.
int32_t iotc_context_handle_t
An internal context handle.
Definition: iotc_types.h:44
int64_t iotc_time_t
Definition: iotc_time.h:34
Defines the time storage type.
Defines custom data formats.
iotc_state_t iotc_connect(iotc_context_handle_t iotc_h, const char *username, const char *password, const char *client_id, uint16_t connection_timeout, uint16_t keepalive_timeout, iotc_user_callback_t *client_callback)
Connects to Cloud IoT Core.
iotc_state_t iotc_publish_data(iotc_context_handle_t iotc_h, const char *topic, const uint8_t *data, size_t data_len, const iotc_mqtt_qos_t qos, iotc_user_callback_t *callback, void *user_data)
Publishes binary data to an MQTT topic.
iotc_state_t iotc_delete_context(iotc_context_handle_t context_handle)
Frees the provided context.
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
iotc_state_t iotc_shutdown_connection(iotc_context_handle_t iotc_h)
Disconnects asynchronously from an MQTT broker.
iotc_state_t iotc_subscribe(iotc_context_handle_t iotc_h, const char *topic, const iotc_mqtt_qos_t qos, iotc_user_subscription_callback_t *callback, void *user_data)
Subscribes to an MQTT topic.
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
uint32_t iotc_get_network_timeout(void)
Gets the connection timeout.
iotc_state_t iotc_set_fs_functions(const iotc_fs_functions_t fs_functions)
Sets the file operations to the custom file management functions in the BSP.
iotc_state_t iotc_set_maximum_heap_usage(const size_t max_bytes)
void iotc_cancel_timed_task(iotc_timed_task_handle_t timed_task_handle)
Removes a scheduled task from the internal event system.