Onboarding Thing

To allow a mobile application to manipulate a thing, you need to bind the application to the thing. This binding process is called onboarding.

See Thing Onboarding in the Function Guide to learn the basics of the onboarding (e.g., flows and steps).

Onboard thing

Here, we will present a sample code for onboarding a thing using a tio_handler_t method. If you want to onboard with a tio_updater_t instance, use the tio_updater_onboard method instead.

/* Define the thing credentials and onboarding options. */
#define VENDOR_THING_ID "nbvadgjhcbn"
#define THING_PASSWORD "123456"
#define THING_TYPE "gas-tank"
#define FIRMWARE_VERSION "1"
#define LAYOUT_POSITION "STANDALONE"
#define THING_PROPERTIES "{}"

/* Onboard the thing. */
tio_code_t result = tio_handler_onboard(
        &handler,
        VENDOR_THING_ID,
        THING_PASSWORD,
        THING_TYPE,
        FIRMWARE_VERSION,
        LAYOUT_POSITION,
        THING_PROPERTIES);
if (result != TIO_ERR_OK) {
  /* Handle the error. */
}

We are setting the following values in the sample code:

  • &handler: A pointer to the initialized tio_handler_t instance.
  • VENDOR_THING_ID: The ID of the thing defined by the vendor (developer). See here for more details.
  • THING_PASSWORD: The password of the thing. Put the unique password for each thing to secure the region allocated for the thing on Thing Interaction Framework.
  • THING_TYPE: The type of the thing. Please set the thing type that you've registered in Registering Thing Capability.
  • FIRMWARE_VERSION: The firmware version. Please set the firmware version that you've registered in Registering Thing Capability.
  • LAYOUT_POSITION: The layout position of the thing (STANDALONE, GATEWAY, or ENDNODE). See Gateway and End Nodes for the details.
  • THING_PROPERTIES: The thing properties in the JSON format. These properties are used when you leverage Kii Cloud SDK features. In the above sample code, we are setting an empty JSON. You can also set a NULL here.

Get registration information

Once a thing is onboard, you can get its registration information kii_author_t. This registration information can be shared between two tio instances.

const kii_author_t* author = tio_handler_get_author(&handler);
const kii_author_t* author = tio_updater_get_author(&updater);

The registration information is used when Updating and Browsing State and Executing Commands.