Search code examples
ckaa

KAA Failed to create kaa_configuration_manager_set_root_receiver


I want to control GPIO of endpoint (Raspberry pi 3).

I try to merge two KAA demo applications to one. ("Cassandra data analytics" and "Data collection")

Since there is only one demo for Raspberry Pi, I choose "Cassandra data analytics".

And I have used "Data collection demo" to control endpoint from kaa server.

Now, I want to implement control GPIO of endpoint from kaa server on "Cassandra data analytics".

Here is my procedure:

  1. Choose Application -> "Cassandra data analytics" on WEB UI.
  2. Add new schema (Configuration schemas) follow "Data collection demo" and I modify temperature to GPIO_PIN_4 (integer type).
  3. Generate SDK.
  4. Copy *tar.gz to "libs" folder
  5. Modify kaa_demo.c,

    1. add header file

      #include "extensions/configuration/kaa_configuration_manager.h"
      #include "extensions/configuration/kaa_configuration_manager.c"
      
    2. Configure notification manager in main()

      kaa_configuration_root_receiver_t receiver = {
          .context = NULL,
          .on_configuration_updated = on_configuration_updated
      };
      
      error_code = kaa_configuration_manager_set_root_receiver(
          kaa_client_get_context(kaa_client)->configuration_manager,
          &receiver);
      

Here, I got error_code = -4

Is anyone can tell me how to solve this error? Thanks


Solution

  • Error codes are defined in the src/kaa/kaa_error.h file. The particular error -4 is defined as KAA_ERR_BADPARAM, which means one of the parameters is wrong.

    If you check source code for kaa_configuration_manager_set_root_receiver function, it becomes obvious that one of the parameters is NULL. &receiver is guaranteed to be non-null, so the wrong parameter must be kaa_client_get_context(kaa_client)->configuration_manager.

    This is likely due to configuration extension been disabled. -DWITH_EXTENSION_CONFIGURATION=ON must be passed to the C SDK cmake command. Check your CMake file and change WITH_EXTENSION_CONFIGURATION value to ON.