Build the Sample Application

Build the sample telemetry application as a user mode (RTP) or kernel mode (DKM) application.

  1. Create a DKM or RTP application project based on your VSB project.
  2. Add the example telemetry code to your project.
    • Add vsbDir/3pp/HDC_DEVICE_CLOUD_LIB/device_cloud_lib_repo/share/apps/telemetry/telemetry.c.

    • Remove the default C application file from your project.

    • If you do so directly in the file system (outside of Workbench), be sure to refresh your project so that the file changes are registered.

  3. Please note the key elements of the source code that are required for all Device Cloud C applications.
    • They must include iot.h.

    • The iot_initilize() call gets the agent library handle to use for future agent API calls. The "telemetry-app" string is the application ID, which the agent library will combine with the device ID to create the unique thing key for the application at runtime.

      iot_lib = iot_initialize( "telemetry-app", NULL, 0 );
      
    • The iot_connect() call connects the application with the Device Cloud.

      status = iot_connect( iot_lib, 0u );

    For more information, see the Device Cloud Device Programmer's Guide: Application Initialization.

  4. For an RTP application, you must configure your build for linkage with the required libraries.
    1. In the Project Explorer, select your project name and then select Properties from the context menu.
    2. In the Properties dialog, select Build Properties > Tools.
    3. From the Build tool drop-down list, select Linker.
    4. Select the Libraries tab.
    5. Click Add, select Add fully qualified library file, enter the following library options: -liot -losal -lnet -larchive -lHASH -lOPENSSL -lmosquitto -ljson -lzlib -lcurl -lunix.
    6. Click OK.
    7. Click Apply and OK.
    Note:

    Remember that when you develop your own Device Cloud RTP applications, you must link with the required libraries (-liot -losal -lnet -larchive -lHASH -lOPENSSL -lmosquitto -ljson -lzlib -lcurl -lunix).

  5. Build your project.