client-c  0.9.0
Kaa client C SDK

Table of contents

Quick start

Building Kaa C SDK

To build the Kaa C SDK, do the following:

$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install

Specific build options are described in the README and in the official online documentation.

Link Kaa library to your project

If you use GNU Compiler, add the linker flag -lkaac to link against a dynamic library or -lkaac_s to link against a static library.

Initializing Kaa library

Before building a user application with the Kaa library, the developer must implement the following functions in the user-space code:

Next, the kaa_context_t instance should be created:

#include "kaa.h"
#include "kaa_error.h"
#include "kaa_common.h"
#include "kaa_context.h"
kaa_context_t *kaa_context = NULL;
kaa_error_t error_code = kaa_init(&kaa_context);
if (error_code) {
return error_code;
}
/* Some useful work */
kaa_deinit(kaa_context);

To communicate with Kaa servers, at least one transport channel must be added for both Bootstrap server and Operations server.

You may use the reference implementation (kaa_tcp_channel_create) or provide your own channel (for more details see kaa_transport_channel_interface_t):

#include <platform-impl/kaa_tcp_channel.h>
kaa_extension_id BOOTSTRAP_SERVICE[] = {
};
const size_t BOOTSTRAP_SERVICE_COUNT = sizeof(BOOTSTRAP_SERVICE) / sizeof(kaa_extension_id);
kaa_extension_id OPERATIONS_SERVICES[] = {
};
const size_t OPERATIONS_SERVICES_COUNT = sizeof(OPERATIONS_SERVICES) / sizeof(kaa_extension_id);
error_code = kaa_tcp_channel_create(&operations_channel, kaa_context->logger,
OPERATIONS_SERVICES, OPERATIONS_SERVICES_COUNT);
if (error_code) {
return error_code;
}
error_code = kaa_tcp_channel_create(&bootstrap_channel, kaa_context->logger,
BOOTSTRAP_SERVICE, BOOTSTRAP_SERVICE_COUNT);
if (error_code) {
return error_code;
}
bootstrap_channel, NULL);
if (error_code) {
return error_code;
}
operations_channel, NULL);
if (error_code) {
return error_code;
}
Note
To use the log collection feature, go through additional initialization steps.

To finish the Kaa C SDK initialization, execute the following command:

kaa_error_t error_code = kaa_start(kaa_context);
if (error_code) {
return error_code;
}

Programming guide

For more information about functions supported by the Kaa C SDK, see our Programming guide:

Demo application

To better familiarize yourself with Kaa C SDK, you may look at our demo application.

Find the demo source code in the 'example' directory located in the root of the Kaa project.