The AWS IoT device SDK for embedded C is a collection of C source files to securely connect to the AWS IoT platform. It includes transport clients MQTT, TLS implementation and supports Thing Shadow:

  • MQTT Connection. The device SDK creates and maintains a mutually authenticated TLS connection over which it runs MQTT. This connection is used for publish and subscriptions operations on MQTT topics.

  • Thing Shadow. The device SDK implements the protocol to retrieve, update and delete Thing Shadows. It automatically subscribes to and unsubscribes from the Shadow reserved topics as needed.

Using the library

To work with AWS IoT, you must:

  1. Include the required AWS IoT header files in your application source code. For example:

    #include <aws_iot_config.h>
    #include <aws_iot_log.h>
    #include <aws_iot_shadow_interface.h>
    #include <aws_iot_version.h>
  2. Link against the AWS IoT device SDK static library. The library provides a pkg-config file, awsiotsdk.pc. To configure the proper compilation flags and linked libraries, add the following lines in your makefile:

    [...]
     
    CFLAGS += $(shell pkg-config --cflags awsiotsdk)
    LDLIBS += $(shell pkg-config --libs --static awsiotsdk)
     
    [...]

Build your AWS IoT application

You can build your own AWS IoT application:

  • Using the pre-compiled toolchain. See Application development.

    To run your application in the device, you must have the mbedTLS shared libraries and the certificates in your device.

    The resources available in the precompiled toolchain are built for the default settings at aws-iot bbclass.

    If you need different values for the "MQTT PubSub" and "Auto Reconnect specific config" settings, you must re-generate the toolchain with your specific configuration from your Digi Embedded Yocto.

  • As part of the Digi Embedded Yocto build. You must create a recipe similar to the awsiotsdk-demo recipe. Make sure that your recipe:

    • Depends on awsiotsdk-c

    • Inherits from the aws-iot bbclass

      SUMMARY = "My AWS IoT device application"
       
      [...]
       
      DEPENDS = "awsiotsdk-c"
       
      [...]
       
      inherit aws-iot
       
      [...]
See Create an AWS IoT image for information on how to build an image with AWS IoT support.