client-c  0.8.1
Kaa client C SDK

Copyright 2014-2016 CyberVision, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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 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);
KAA_RETURN_IF_ERR(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_service_t BOOTSTRAP_SERVICE[] = { KAA_SERVICE_BOOTSTRAP };
const size_t BOOTSTRAP_SERVICE_COUNT = sizeof(BOOTSTRAP_SERVICE) / sizeof(kaa_service_t);
kaa_service_t OPERATIONS_SERVICES[] = { KAA_SERVICE_PROFILE
const size_t OPERATIONS_SERVICES_COUNT = sizeof(OPERATIONS_SERVICES) / sizeof(kaa_service_t);
error_code = kaa_tcp_channel_create(&operations_channel
, kaa_context->logger
, OPERATIONS_SERVICES
, OPERATIONS_SERVICES_COUNT);
KAA_RETURN_IF_ERR(error_code);
error_code = kaa_tcp_channel_create(&bootstrap_channel
, kaa_context->logger
, BOOTSTRAP_SERVICE
, BOOTSTRAP_SERVICE_COUNT);
KAA_RETURN_IF_ERR(error_code);
, bootstrap_channel
, NULL);
KAA_RETURN_IF_ERR(error_code);
, operations_channel
, NULL);
KAA_RETURN_IF_ERR(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);
KAA_RETURN_IF_ERR(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.