How to receive a device update via azure-iot-sdk-c

1.2k Views Asked by At

I'm currently developing an update strategy for IoT devices running embedded Linux. With Azure Device Update for IoT Hub.
I have read a lot of MS documentation regarding this topic. But I am missing the part of how to connect all services together, so they do what I want.

What I know:

What I want:

  • Send Telemetry data for the device
  • Invoke Methods on the device
  • Deploy an Update Image to my IoT Devices from a central Point (IoT Hub).
  • Automatically start the download when a new Patch is viable.
  • Have one Client App that does all of this.

What I have:

  • The Client Side of the update is implemented with rauc. I just need a way to deliver the update file to the device.
  • I can send Telemetry, edit device Twins and invoke Methods using the iot-sdk-c.
  • I created an IotHub with Device Update and connected my devices with the Device Update Agent
  • I created an Update-Artifact and imported it, and created a new deployment for my target group.
  • I was the able to simulate a successful download with the AducIotAgent.

My Problem:

I don't know how to connect all these parts together so that, when I deploy a new artifact, all compatible devices start the download by themselves, or if I am even on the right path. My next step would be to simply invoke a method which downloads the update file and passes it to my rauc updater, but that would defeat the purpose of Device Update and Update Agent, at least with my current understanding of them. I have an additional problem with the Device Agent which I explained on github, but I don't think that this is related.

Furthermore, I read that the Device Update uses PnP interfaces and in this guide they are using iot-dps to register new devices, but before I read further into these topics I would like to know if is suited for my case.

This Question on MS.

2

There are 2 best solutions below

4
On

Thank you for your questions, please see some responses below.

  1. From your feedback it looks like you have successfully completed an OTA update to your IoT device. Congrats!
  2. We support OTA updates using installers such as: swUpdate for Image (A/B) updates and apt for Package Based updates. So you don’t need to use the RAUC updater if either of these meet your needs. If not, we are interested in hearing your use case and feedback on how we can improve the platform in the future. a. Here are the various update tutorials for reference: i. Image Update: Getting Started with Raspberry Pi 3 B+ Reference Yocto Image
    ii. Package Update: Getting Started using Ubuntu Server 18.04 x64 Package agent iii.Device Update for Azure IoT Hub tutorial for Azure-Real-Time-Operating-System
  3. We don’t yet support the ability for dynamic deployments where compatible devices just start downloading the update without someone manually starting a new deployment from the Portal (or API’s). We will consider this capability for future releases.
  4. Devices don’t need to be PnP-enabled to use Device Update for IoT Hub. However, they do need the Device Update Agent installed, which communicates with the Device Update service via IoT Hub, using PnP device twin properties to orchestrate the update.
  5. Device registration: A device can be registered with IoT Hub using DPS (in production scenarios) or manually with a connection string (for testing). Depending on your use case you can register the device using DPS with the preferred authentication (SAS, TPM, X509 certificate). Next you have to provide the Device Update agent access to your device using the IoT Identity Service or using a config file for testing. Details for how to provision Device Update agent can be found here.
2
On

At this point we do not have a general guideline on how to integrate your existing app/client/module with the update agent, which is something we're working to add very soon. For now I can refer you to some of the relevant pointer in our documentation, which will help you to get started:

Update agent PnP interface: https://learn.microsoft.com/en-us/azure/iot-hub-device-update/device-update-plug-and-play

Update agent workflow: https://learn.microsoft.com/en-us/azure/iot-hub-device-update/understand-device-update#device-update-agent

Workflow code reference: https://github.com/Azure/iot-hub-device-update/blob/main/src/agent/adu_core_interface/src/agent_workflow.c

Note that for installation specific implementations we have the concept of a "handler" which is maps to a specific "updateType". Here is the relevant pointer: https://learn.microsoft.com/en-us/azure/iot-hub-device-update/device-update-agent-overview#update-handlers

An example of such handler is APT or SWUpdate, which resides here: https://github.com/Azure/iot-hub-device-update/tree/main/src/content_handlers/swupdate_handler