tvcmiclient
TeamViewer C SDK for IOT Agent API

Introduction

This document provides information about how the SDK can be used to create client applications and interact with the TeamViewer IOT agent API.
For more information about Teamviewer IOT Agent API see the following document: https://download.teamviewer-iot.com/docs/agentapi/index.html

About the C SDK

The C SDK for the TeamViewer IOT Agent API is a reference implementation of the API client as a library. It is designed to minimize the effort for integrating your devices into TeamViewer IOT.
The SDK contains static (libtvcmiclient.a) and shared (libtvcmiclient.so.x.y.z) libraries and the tvcmi_client.h header file.
Third party libraries that the SDK depends on are: c-ares, json-c, mosquitto, openssl.
To build your client application you have to include the tvcmi_client.h file in your project and link it to the static or shared library. Third party static libraries are also provided in the package.

Package structure

The package has the following structure:

  • "docs" - contains doxygen-generated HTML documents.
  • "examples" - contains C-SDK examples.
  • "include" - contains the tvcmi_client.h SDK interface file.
  • "libs" - contains static and shared client libraries.
  • "3rdpartylibs" - contains third party static libraries (c-ares, json-c, mosquitto, openssl).
  • "copyright.txt" - contains licensing information.
  • "3rdpartylicenses.txt" - contains licensing information of third party libraries.
  • "readme.txt" - contains general information about the SDK package structure.
  • "version.txt" - contains the version number of the SDK.

How to use

The TVCMI_LibInit() function must be called before any other API function. This function must be called only once in the beginning.
Call the TVCMI_LibCleanup() function to free resources associated with the library.
The TVCMI_NewClient() function creates a client object. You will need to provide a configuration file that contains the necessary information to connect to the IOT Agent API. Call the TVCMI_DeleteClient() function to delete the client object.
The TVCMI_ProvisionClient() will provision the client if it is not provisioned yet.
After the client is created and provisioned, a folder is created that will contain the private key and certificate files. If these files already exist, the client does not try to provision again and uses the existing private key and certificate to connect to the API instead. In that case you can use the TVCMI_ListSensors() and TVCMI_DescribeMetric() functions to get information about created sensors and metrics.
Certificates will be renewed automatically 30 days before expiration.
Each client creates a thread to process network packets. Callback functions may be called from that thread or immediately from the calling thread.
After the client is created and provisioned you have to call the TVCMI_Connect() function to connect to the API. This is a non-blocking function. You have to register a callback function to get events about the connection and errors.
Setting any of the callback functions replaces the old one, if any.
You can create new sensors and new metrics with the TVCMI_CreateSensor() and TVCMI_CreateMetrics() functions.
You can push metric values by calling the TVCMI_PushMetricValues() function.
There are other cleanup and helper functions. All functions are described in the tvcmi_client.h header file.
Note: For Windows, call TVCMI_Disconnect() before TVCMI_DeleteClient().

Examples

There are three examples included in the SDK package to help you get started on how to use the SDK.
The SendMetricValues example creates a client, creates a sensor and creates three metrics. Then pushes metric values periodically
The ShowSensorsMetrics example will show you the created sensor and metrics of the provisioned client. You can use the certificates from the SendMetricValues example to show the sensors and metrics created in that example.
The DeleteSensor example will connect to the API and delete the sensor passed as the first parameter to the program. As before you can use the certificates from the SendMetricValues example to delete the sensor created there.