Ameba IoT Hub Plug and Play Examples

Ameba IoT Hub Plug and Play example shows the capability of Ameba to interact with Azure IoT Service. We provide two examples with SAS or X509 authentication where their capabilities are described in the Realtek Ameba series model file. We will elaborate on the features that Ameba supports and the usage of Azure IoT Explorer to send and receive data to and from the Ameba device.

Ameba IoT Hub Plug and Play Examples

Ameba IoT Hub Plug and Play examples are the application responsible for communication between Ameba SDK components and Azure IoT service. Basically there are two examples in our SDK, example_azure_iot_rtk_pnp_x509 and example_azure_iot_rtk_pnp_sas, which do exactly the same things except for the authentication type of connection to DPS and IoT Hub.

After Wi-Fi is connected, the example will proceed. At the beginning of the example, it will connect to your DPS and register the device to the IoT Hub. If successful, you should see your device shown on Azure IoT Explorer or provisioned on your Azure IoT Central. Next, the example will connect to the provisioned device on IoT Hub and start the plug and play process for Ameba device:

  1. Subscribe via MQTT for commands, device twin desired properties and responses.

  2. Initialize all components. If there are some initial values or read-only properties that you would like to initialize, you can do so at this stage.

  3. Update reported properties for all components for the first time and then send a twin document request to check the device status on IoT Hub.

  4. Start the telemetry thread. This thread is responsible for all component telemetry.

  5. Start receiving the messages subscribed to from IoT Hub. Ameba device will then react to the incoming message, complete the proper operations on the corresponding component and respond to IoT Hub.

X509 and SAS example should be configured as follows:

X509:

Ameba IoT Hub Plug and Play example with X509 certificate to provision device by DPS and start plug and play process.

  • Select the Ameba IoT Hub Plug and Play X509 example in

    example_azure_iot_entry.h

Uncomment EXAMPLE_AZURE_IOT_RTK_PNP_X509 to select the example.

  • Change the parameters in example_azure_iot_rtk_pnp_x509.c

Modify ID_SCOPE to your own DPS id scope.

Modify REGISTRATION_ID to your own DPS registration id.

Modify X509CERTIFICATE to your own x509 certificate.

Modify X509PRIVATEKEY to your own x509 private key.

Make sure the certificate has the x509 v3 extension. If you are going to connect to Azure IoT Central for device provisioning, you also have to make sure the issuer and subject CN are set to the device ID in your x509 certificate.

Plug and Play Models

Realtek plug and play model files are placed on Realtek folder of Microsoft Public Repository which are defined with Digital Twins Definition Language (DTDL). The model files are divided into several components. Each component represents a feature of the device and details its telemetry, property and command to interact with Azure IoT service.

After Ameba IoT Hub PnP examples are successfully executed, you can check your registered device on Azure IoT Explorer where its “IoT Plug and Play device” column shows dtmi:realtek:rtk_ameba_series;1.

image_pnp_device

Next, you can check all components on Azure IoT Explorer and interact with Ameba.

There are four types of interfaces you can check on each component. Click on any component on the “IoT Plug and Play components” page, you will see the component details and the tabs shown as below.

component_tab

  • [Property] The read-only property. You can check the properties in the “Properties (read-only)” tab.

  • [Writable Property] The writable property. You can modify writable properties in the “Properties (writable)” tab.

  • [Telemetry] The telemetry. You can see the telemetry messages received in the “Telemetry” tab.

  • [Command] The commands. You can send commands in the “Commands” tab.

Ameba Series

Ameba Series is the Ameba device model file entry. It is the default component containing all the components of the device. Our plug and play examples register the model id of this model file while connecting to DPS and IoT Hub. You will see this component page once you click on your IoT Plug and Play components page on your registered device on Azure IoT Explorer.

ameba_series

Audio:

Audio Component defines the audio feature of the device. It only contains a support property and can be extended in the future.

  • [Property] audio_support: Audio support for device.