Пример #1
0
int main(/*int argc, char* argv[] */)
{   

    printf("\r\nConfiguration demo started\n");

    /**
     * Initialize Kaa client.
     */
      
    kaa_error_t error_code = kaa_client_create(&kaa_client, NULL);
    KAA_DEMO_RETURN_IF_ERROR(error_code, "Failed create Kaa client");
    

    kaa_configuration_root_receiver_t receiver = { NULL, &kaa_demo_configuration_receiver };
    error_code = kaa_configuration_manager_set_root_receiver(kaa_client_get_context(kaa_client)->configuration_manager, &receiver);
    KAA_DEMO_RETURN_IF_ERROR(error_code, "Failed to add configuration receiver");

    kaa_demo_print_configuration_message(kaa_configuration_manager_get_configuration(kaa_client_get_context(kaa_client)->configuration_manager));

    /**
     * Start Kaa client main loop.
     */
    error_code = kaa_client_start(kaa_client, NULL, NULL, 0);
    KAA_DEMO_RETURN_IF_ERROR(error_code, "Failed to start Kaa main loop");

    /**
     * Destroy Kaa client.
     */
    kaa_client_destroy(kaa_client);

    printf("Configuration demo stopped\n");
    return error_code;
}
Пример #2
0
kaa_error_t kaa_demo_configuration_receiver(void *context, const kaa_root_configuration_t *configuration)
{
    (void) context;
    KAA_LOG_TRACE(kaa_client_get_context(kaa_client)->logger, KAA_ERR_NONE, "Received configuration data");
    kaa_demo_print_configuration_message(configuration);
    kaa_client_stop(kaa_client);
    return KAA_ERR_NONE;
}
Пример #3
0
kaa_error_t kaa_demo_configuration_receiver(void *context,
                                            const kaa_root_configuration_t *configuration) {
    (void) context;
    demo_printf("Received configuration data\n");
    kaa_demo_print_configuration_message(configuration);
    kaa_client_stop(kaa_client);
    return KAA_ERR_NONE;
}
Пример #4
0
int main(/*int argc, char *argv[]*/) {
    /**
     * Initialise a board
     */
    int ret = target_initialise();
    if (ret < 0) {
        /* If console is failed to initialise, you will not see this message */
        demo_printf("Failed to initialise a target\n");
        return 1;
    }

    demo_printf("Configuration demo started\n");

    /**
     * Initialize Kaa client.
     */
    kaa_error_t error_code = kaa_client_create(&kaa_client, NULL);
    if (error_code) {
        demo_printf("Failed create Kaa client\n");
        return 2;
    }

    kaa_configuration_root_receiver_t receiver = {
            NULL,
            &kaa_demo_configuration_receiver
    };

    error_code = kaa_configuration_manager_set_root_receiver(
            kaa_client_get_context(kaa_client)->configuration_manager,
            &receiver);

    if (error_code) {
        demo_printf("Failed to add configuration receiver\n");
        return 3;
    }

    kaa_demo_print_configuration_message(
            kaa_configuration_manager_get_configuration(
                    kaa_client_get_context(kaa_client)->configuration_manager));

    /**
     * Start Kaa client main loop.
     */
    error_code = kaa_client_start(kaa_client, NULL, NULL, 0);
    if(error_code) {
        demo_printf("Failed to start Kaa main loop\n");
        return 4;
    }

    /**
     * Destroy Kaa client.
     */
    kaa_client_destroy(kaa_client);

    demo_printf("Configuration demo stopped\n");
    return 0;
}
Пример #5
0
kaa_error_t kaa_demo_configuration_receiver(void *context,
                                            const kaa_root_configuration_t *configuration)
{
    (void)context;
    
    const uint8_t *endpoint_key_hash = NULL;
    size_t endpoint_key_hash_length = 0;

    ext_get_sha1_base64_public(&endpoint_key_hash, &endpoint_key_hash_length);

    printf("- - -\n");
    printf("Endpoint ID %.*s\n", (int)endpoint_key_hash_length,
                endpoint_key_hash);

    printf("Configuration was succesfully edited:\n");
    kaa_demo_print_configuration_message(configuration);
    kaa_client_stop(kaa_client);
    return KAA_ERR_NONE;
}
Пример #6
0
int main(/*int argc, char *argv[]*/)
{
#ifdef CC32XX
    BoardInit();
    wlan_configure();
    sl_Start(0, 0, 0);
    wlan_connect("<SSID>", "<PASSWORD>", SL_SEC_TYPE_WPA_WPA2);//Into <SSID> and <PASSWORD> put your access point name and password
#endif
    DEMO_LOG("Configuration demo started");

    /**
     * Initialize Kaa client.
     */
    kaa_error_t error_code = kaa_client_create(&kaa_client, NULL);
    KAA_DEMO_RETURN_IF_ERROR(error_code, "Failed create Kaa client");

    kaa_configuration_root_receiver_t receiver = { NULL, &kaa_demo_configuration_receiver };
    error_code = kaa_configuration_manager_set_root_receiver(kaa_client_get_context(kaa_client)->configuration_manager, &receiver);
    KAA_DEMO_RETURN_IF_ERROR(error_code, "Failed to add configuration receiver");

    kaa_demo_print_configuration_message(kaa_configuration_manager_get_configuration(kaa_client_get_context(kaa_client)->configuration_manager));

    /**
     * Start Kaa client main loop.
     */
    error_code = kaa_client_start(kaa_client, NULL, NULL, 0);
    KAA_DEMO_RETURN_IF_ERROR(error_code, "Failed to start Kaa main loop");

    /**
     * Destroy Kaa client.
     */
    kaa_client_destroy(kaa_client);

    DEMO_LOG("Configuration demo stopped");
    return error_code;
}
Пример #7
0
int main(int argc, char *argv[])
{   
    if (argc != 5) {
        printf("Please, input + or - for audio, video and vibro supporting and directory for key storage. (Need 4 arguments)\n");
        exit(1);
    }
    
    mkdir(argv[4], 0777);
    chdir(argv[4]);

    /**
     * Initialize Kaa client.
     */
    kaa_error_t error_code = kaa_client_create(&kaa_client, NULL);
    if (error_code) {
        printf("Failed create Kaa client, error code %d\n", error_code);
        return EXIT_FAILURE;
    }
    
    kaa_profile_t *profile = kaa_profile_pager_client_profile_create();
    if (!profile) {
        printf("Failed to create profile\n");
        kaa_client_destroy(kaa_client);
        return EXIT_FAILURE;
    }
    
    const uint8_t *endpoint_key_hash = NULL;
    size_t endpoint_key_hash_length = 0;

    ext_get_sha1_base64_public(&endpoint_key_hash, &endpoint_key_hash_length);

    if (access(KAA_CONFIGURATION_STORAGE, F_OK) != -1) {
        printf("Waiting for new configuration for\n");
        printf("Endpoint ID %.*s\n", (int)endpoint_key_hash_length, endpoint_key_hash);
    }

    printf("- - -\n");
    printf("Endpoint ID %.*s\n", (int)endpoint_key_hash_length,
                endpoint_key_hash);


    profile->audio_support = set_client_parameter(argv[1]);
    profile->video_support = set_client_parameter(argv[2]);
    profile->vibro_support = set_client_parameter(argv[3]);

    printf("Profiling body (have audio-, video-, vibro-support):\n");
    printf("%s - %s - %s\n", profile->audio_support ? "true" : "false",
        profile->video_support ? "true" : "false",
        profile->vibro_support ? "true" : "false");

    error_code = kaa_profile_manager_update_profile(kaa_client_get_context(kaa_client)->profile_manager, profile);
    if (error_code) {
        printf("Failed to update profile, error code %d", error_code);
        kaa_client_destroy(kaa_client);
        return EXIT_FAILURE;
    }

    kaa_configuration_root_receiver_t receiver = {
        NULL,
        &kaa_demo_configuration_receiver,
    };

    error_code = kaa_configuration_manager_set_root_receiver(
        kaa_client_get_context(kaa_client)->configuration_manager,
        &receiver);
    if (error_code) {
        printf("Failed to add configuration receiver\n");
        kaa_client_destroy(kaa_client);
        return EXIT_FAILURE;
    }
    printf("Default configuration:\n");
    kaa_demo_print_configuration_message(
        kaa_configuration_manager_get_configuration(
            kaa_client_get_context(kaa_client)->configuration_manager));

    /**
     * Start Kaa client main loop.
     */
    error_code = kaa_client_start(kaa_client, NULL, NULL, 0);
    if (error_code) {
        printf("Failed to start Kaa main loop, error code %d\n", error_code);
        kaa_client_destroy(kaa_client);
        return EXIT_FAILURE;
    }
    
    /**
     * Destroy Kaa client.
     */
    kaa_client_destroy(kaa_client);

    return EXIT_SUCCESS;
}
Пример #8
0
int main(/*int argc, char *argv[]*/) {
    /**
     * Initialise a board
     */
    int ret = target_initialize();
    if (ret < 0) {
        /* If console is failed to initialise, you will not see this message */
        demo_printf("Failed to initialise a target\r\n");
        return EXIT_FAILURE;
    }

    demo_printf("Configuration demo started\r\n");

    /**
     * Initialize Kaa client.
     */
    kaa_error_t error_code = kaa_client_create(&kaa_client, NULL);
    if (error_code) {
        demo_printf("Failed create Kaa client\r\n");
        return EXIT_FAILURE;
    }

    /*
     * Set the handler for configuration updates.
     */
    kaa_configuration_root_receiver_t receiver = {
            NULL,
            &kaa_demo_configuration_receiver
    };

    error_code = kaa_configuration_manager_set_root_receiver(
            kaa_client_get_context(kaa_client)->configuration_manager,
            &receiver);

    if (error_code) {
        demo_printf("Failed to add configuration receiver\r\n");
        return EXIT_FAILURE;
    }

    /*
     * Display default configuration.
     */
    kaa_demo_print_configuration_message(
            kaa_configuration_manager_get_configuration(
                    kaa_client_get_context(kaa_client)->configuration_manager));

    /*
     * Obtain and display endpoint ID (represented by the EP key hash).
     */
    const uint8_t *endpoint_key_hash = NULL;
    size_t endpoint_key_hash_length = 0;

    ext_get_sha1_base64_public(&endpoint_key_hash, &endpoint_key_hash_length);

    printf("Endpoint ID: %.*s\r\n", (int)endpoint_key_hash_length,
            endpoint_key_hash);

    /**
     * Start Kaa client main loop.
     */
    error_code = kaa_client_start(kaa_client, NULL, NULL, 0);
    if(error_code) {
        demo_printf("Failed to start Kaa main loop\r\n");
        return EXIT_FAILURE;
    }

    /**
     * Destroy Kaa client.
     */
    kaa_client_destroy(kaa_client);

    return EXIT_SUCCESS;
}