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 IoT Portal.
  • Provides helper functions to interact with IoT Portal

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 IoT Portal. 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 IoT Portal.

Connectivity

To setup the connection to the IoT Portal, 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. 

Communication

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  IoT Portal, 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. 

Response

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 IoT Portal 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 IoT Portal. These helper functions use the TR50 compliant C library and implement the functionality exposed by the IoT Portal API. You can refer to the IoT Portal APIs to explore the request and reply message formats for each of the IoT Portal 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 IoT Portal with the required parameters. The extended APIs are intended to be used when the user wants to provide IoT Portal with more data than the required parameters.