Kolibri library – API Documentation

Header image

Main page


Kolibri library Documentation

Introduction

The Kolibri library can be used to implement a Kolibri Producer in order to exchange data via the Kolibri system.

Dependencies

The Kolibri library depends on the HTTPC client library and the JSON library. The HTTP client library is needed to establish the connection to the Broker. The JSON library is used for the RPC functionality of the library. On Linux the Kolibri library additionally depends on Pthreads and OpenSSL.

Requirements

Tasks that call functions of the Kolibri library must be prepared for exception handling and floating point operations.
Exceptions are only used internally. The functions of the Kolibri library should not throw any exceptions.
On Linux the Kolibri executable must have the right to change the priority of its tasks/threads. This can for example be achieved by granting the CAP_SYS_NICE capability.

Getting Started

Here is the most simple way to get the Kolibri library started:

// Error handling is left as an excercise to the reader.
#include <stdlib.h>
#include <time.h>
// Step 1: Include the library's main header file
#include <kolibri.h>
void clockUpdateCb(KolibriUint32 timestamp)
{
// Set the system clock
stime((long *)&timestamp);
// Tell the library that the clock has now been synchronised
}
void main(void)
{
KolibriUint8 val1 = 0;
KolibriUint32 val2 = 0;
KolibriDataset datasets[] =
{
{ "/point1", &val1, NULL, NULL, KOLIBRI_DATA_TYPE_UINT8 },
{ "/point2", &val2, NULL, NULL, KOLIBRI_DATA_TYPE_UINT32 }
};
KolibriHandle handle;
// Step 2: Initialise OpenSSL and create context - This step is needed
// only on Linux. On RTOS this is done implicitely.
...
// Step 3: Load certificate for TLS connection
...
// Step 4: Generate password hash
r = kolibriGeneratePassHash(passHash, "<PASSWORD>", "<USER>", "<PROJECT>");
// Step 5: Initialise library
r = kolibriInit("<PROJECT>", "<HOST>", "<PRODUCER>", "<USER>", passHash);
// Step 6: Set clock update callback
r = kolibriRegisterClockUpdateCb(clockUpdateCb);
// Step 7: Set OpenSSL context - This step is needed only on Linux. On
// RTOS this is done implicitely.
// Step 8: Start the library
r = kolibriStart();
// Step 9: Register datasets
r = kolibriRegister(&handle, datasets, sizeof(datasets) / sizeof(KolibriDataset));
while(...)
{
++val1;
++val2;
// Step 10: Process datasets
r = kolibriProcess(handle, 0);
// Sleep some milliseconds...
}
}

Index






Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated by Doxygen 1.8.10