C Library

The following page provides you with assistance in developing an IoT application program using the TR50 compliant library implemented using the C programming language.

Key facts about the TR50 Compliant Library in C

  • Source library available from the Management Portal Developer -> Resources -> TR50_Clients -> C folder.
    You can also use this direct link to download the TR50 client C library.
  • Uses MQTT to communicate with deviceWISE Cloud.
  • Provides helper functions to interact with deviceWISE Cloud

TR50 C Library 

The following section provides the TR50 compliant APIs exposed in the C Library implementation. The APIs described below handle connectivity, authentication and sending/receiving synchronous and asynchronous tr50 messages to and from the deviceWISE Cloud. The common worker basic and extended apis provide the user a full set of basic and extended functions intended to be used to leverage the full capabilities of the deviceWISE Cloud.


To setup the connection to the deviceWISE Cloud, you must request a session handle (tr50) with your appropriate configuration parameters (tr50_create). Prior to starting your connection, you must register the desired callback function using tr50_command_register(). Finally, you can then establish the communication session with the MQTT server by calling tr_start()

Connectivity function definition and example. 


To send a message using the TR50 Compliant API, you first have to create a message container, fill the message container with the data as per the TR50 Message format while providing a cmd_id for that specific message. Once the message processing is complete, you must delete the message (i.e. after receiving a reply from the server and parsing the data). To send the data to  deviceWISE Cloud, you can use the tr50_api_call_sync or tr50_api_call_async functions and await the reply. The reply can be used for error handling as well as retrieving the returned data. The tr50_api_raw_sync/async functions have been provided for situations where only one tr50 message needs to be sent in it's raw format. 

Communication function definition and example. 


There are several APIs implemented to process the reply and help with error handling which are listed below:

 Response function definition and example. 

TR50 Compliant deviceWISE Cloud APIs 

The following section will provide you with an up-to-date list of helper functions intended to be used to leverage the full capabilities of deviceWISE Cloud. These helper functions use the TR50 compliant C library and implement the functionality exposed by the deviceWISE Cloud API. You can refer to the IoT Portal APIs to explore the request and reply message formats for each of the deviceWISE Cloud Interface commands. Two sets of helper functions have been provided, the basic APIs and the extended APIs. The basic APIs provide the user with the ability to call deviceWISE Cloud with the required parameters. The extended APIs are intended to be used when the user wants to provide deviceWISE Cloud with more data than the required parameters.