コード例 #1
0
ファイル: test_kaa_profile.c プロジェクト: BillTheBest/kaa
int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger,
                                       KAA_MAX_LOG_MESSAGE_LENGTH,
                                       KAA_MAX_LOG_LEVEL,
                                       NULL);
    if (error || !logger) {
        return error;
    }

    kaa_context.logger = logger;

    error = kaa_status_create(&status);
    if (error || !status) {
        return error;
    }

    error = kaa_channel_manager_create(&channel_manager, &kaa_context);
    if (error || !channel_manager) {
        return error;
    }

    /* Add channel will fail due to absent access point, but it is expected */
    kaa_channel_manager_add_transport_channel(channel_manager, &channel, NULL);

    error = kaa_profile_manager_create(&profile_manager,
                                       status, channel_manager, logger);
    if (error || !profile_manager) {
        return error;
    }

    return 0;
}
コード例 #2
0
ファイル: test_kaa_user.c プロジェクト: Acarus/kaa
int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger) {
        return error;
    }

    kaa_context.logger = logger;

    error = kaa_status_create(&status);
    if (error || !status) {
        return error;
    }

    error = kaa_channel_manager_create(&channel_manager, &kaa_context);
    if (error || !channel_manager) {
        return error;
    }

    error = kaa_user_manager_create(&user_manager, status, channel_manager, logger);
    if (error || !user_manager) {
        return error;
    }

    kaa_attachment_status_listeners_t listeners = { NULL, &on_attached, &on_detached, &on_attach_success, &on_attach_failed };
    error = kaa_user_manager_set_attachment_listeners(user_manager, &listeners);
    if (error) {
        return error;
    }

    return 0;
}
コード例 #3
0
int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger) {
        return error;
    }

    kaa_context.logger = logger;

    error = kaa_channel_manager_create(&channel_manager, &kaa_context);
    if (error || !channel_manager) {
        return error;
    }
    kaa_context.channel_manager = channel_manager;

    error = kaa_bootstrap_manager_create(&bootstrap_manager, channel_manager, logger);
    if (error || !bootstrap_manager) {
        return error;
    }
    kaa_context.bootstrap_manager = bootstrap_manager;

    error = ext_log_upload_strategy_create(&kaa_context, &strategy, KAA_LOG_UPLOAD_VOLUME_STRATEGY);
    if(error)
        return error;

    return 0;
}
コード例 #4
0
int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger)
        return error;


    return 0;
}
コード例 #5
0
ファイル: test_kaa_list.c プロジェクト: nthevu/kaa
int test_init()
{
    srand(time(NULL));

    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger)
        return error;

    return 0;
}
コード例 #6
0
ファイル: kaa.c プロジェクト: radrajith/kaabot
kaa_error_t kaa_init(kaa_context_t **kaa_context_p)
{
    KAA_RETURN_IF_NIL(kaa_context_p, KAA_ERR_BADPARAM);

    // Initialize logger
    kaa_logger_t *logger = NULL;

    FILE *logfile = fopen("run.log", "w");

    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, logfile); // TODO: make log destination configurable
    if (error)
        return error;

    KAA_LOG_INFO(logger, KAA_ERR_NONE, "Kaa SDK version %s, commit hash %s", BUILD_VERSION, BUILD_COMMIT_HASH);

    // Initialize general Kaa context
    error = kaa_context_create(kaa_context_p, logger);
    if (error) {
        KAA_LOG_FATAL(logger, error, "Failed to create Kaa context");
        kaa_log_destroy(logger);
        *kaa_context_p = NULL;
        return error;
    }

    // Initialize endpoint identity
    char *pub_key_buffer = NULL;
    size_t pub_key_buffer_size = 0;
    bool need_deallocation = false;

    ext_get_endpoint_public_key(&pub_key_buffer, &pub_key_buffer_size, &need_deallocation);
    kaa_digest pub_key_hash;
    error = ext_calculate_sha_hash(pub_key_buffer, pub_key_buffer_size, pub_key_hash);

    if (need_deallocation && pub_key_buffer_size > 0) {
        KAA_FREE(pub_key_buffer);
    }

    if (error) {
        KAA_LOG_FATAL(logger, error, "Failed to calculate EP ID");
        kaa_context_destroy(*kaa_context_p);
        *kaa_context_p = NULL;
        kaa_log_destroy(logger);
        return error;
    }

    error = ext_copy_sha_hash((*kaa_context_p)->status->status_instance->endpoint_public_key_hash, pub_key_hash);
    if (error) {
        KAA_LOG_FATAL(logger, error, "Failed to set Endpoint public key");
        kaa_context_destroy(*kaa_context_p);
        *kaa_context_p = NULL;
        kaa_log_destroy(logger);
        return error;
    }
    return KAA_ERR_NONE;
}
コード例 #7
0
ファイル: test_kaa_configuration.c プロジェクト: Acarus/kaa
int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger)
        return error;


#ifndef KAA_DISABLE_FEATURE_CONFIGURATION
    error = kaa_status_create(&status);
    if (error || !status)
        return error;

    error = kaa_configuration_manager_create(&config_manager, NULL, status, logger);
    if (error || config_manager)
        return error;
#endif
    return 0;
}
コード例 #8
0
ファイル: test_kaa_log.c プロジェクト: Oleh-Kravchenko/kaa
int test_init(void)
{
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    if (error || !logger) {
        return error;
    }

    kaa_context.logger = logger;

    error = kaa_status_create(&status);
    if (error || !status) {
        return error;
    }

    error = kaa_channel_manager_create(&channel_manager, &kaa_context);
    if (error || !channel_manager) {
        return error;
    }
    return 0;
}
コード例 #9
0
ファイル: kaa.c プロジェクト: kaaproject/kaa
kaa_error_t kaa_init(kaa_context_t **kaa_context_p)
{
    KAA_RETURN_IF_NIL(kaa_context_p, KAA_ERR_BADPARAM);

    // Initialize logger
    kaa_logger_t *logger = NULL;
    kaa_error_t error = kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL); // TODO: make log destination configurable
    if (error) {
        return error;
    }

    KAA_LOG_INFO(logger, KAA_ERR_NONE, "Kaa SDK version %s, commit hash %s", KAA_BUILD_VERSION, KAA_BUILD_COMMIT_HASH);

    // Initialize general Kaa context
    error = kaa_context_create(kaa_context_p, logger);
    if (error) {
        KAA_LOG_FATAL(logger, error, "Failed to create Kaa context");
        *kaa_context_p = NULL;
        return error;
    }

    // Initialize endpoint identity
    uint8_t *sha1 = NULL;
    size_t sha1_size = 0;

    error = kaa_init_keys();
    if (error) {
        KAA_LOG_ERROR(logger, error, "Failed to initialize keys");
        return error;
    }

    ext_get_sha1_public(&sha1, &sha1_size);
    ext_copy_sha_hash((*kaa_context_p)->status->status_instance->endpoint_public_key_hash, sha1);

    return kaa_status_set_updated((*kaa_context_p)->status->status_instance, true);
}
コード例 #10
0
int test_init(void)
{
    kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    return 0;
}
コード例 #11
0
ファイル: test_kaa_status.c プロジェクト: nthevu/kaa
int status_test_init(void)
{
    kaa_log_create(&logger, KAA_MAX_LOG_MESSAGE_LENGTH, KAA_MAX_LOG_LEVEL, NULL);
    remove(KAA_STATUS_STORAGE);
    return 0;
}