Skip to content

Latest commit

 

History

History
166 lines (109 loc) · 6.28 KB

File metadata and controls

166 lines (109 loc) · 6.28 KB

How To Build the Device Update Agent

Take a look at dependencies before you get started. You can build the Device Update agent as a standlone solution or integrate it in your existing application or solution.

Take a look at dependancies before you get started. You can build the Device Update agent as a standlone solution or integrate it in your existing application or solution.

Dependencies of Device Update Agent

Required Dependencies

  • Azure IoT C SDK
  • Delivery Optimization SDK

Azure IoT C SDK

Use the Azure IoT C SDK to connect to IoT Hub and call Azure IoT Plug and Play APIs.

Delivery Optimization

The Delivery Optimization SDK SDK provides a robust way for the client to download an update.

Building the Device Update Agent for Linux

Installing Dependencies

Use the scripts/install-deps.sh Linux shell script for a convenient way to install the dependencies of the Device Update for IoT Hub agent for most use cases.

Note: You may be prompted for sudo password or GitHub username and password when running install-deps.sh. If your GitHub account has two factor auth enabled, use a personal access token (PAT) as the password.

To install all dependencies run:

./scripts/install-deps.sh -a

Note:: --use-ssh can be used to clone dependencies from the Git repo using SSH instead of https.

To install only the dependencies necessary for the agent:

./scripts/install-deps.sh --install-aduc-deps --install-packages

If you want to install dependencies for a different distro other than Ubuntu 18.04 (the default option), use option -d, for example --deps-distro ubuntu2004. (Installing DO dependencies using bootstrap script in do-client)

install-deps.sh also provides several options for installing individual dependencies. To see the usage info:

./scripts/install-deps.sh -h

As a standalone solution

Device Update Linux Build System

The Device Update for IoT Hub reference agent code utilizes CMake for building. An example build script is provided at scripts/build.sh.

Build Using build.sh

To build the reference agent integrated with Delivery Optimization for downloads but still mocks the Install and Apply actions:

./scripts/build.sh -c -p linux

To see additional build options with build.sh:

build.sh -h

Build the agent using CMake

Alternatively, you can build using CMake directly. Set the required product values for ADUC_DEVICEINFO_MANUFACTURER and ADUC_DEVICEINFO_MODEL in the top-level CMakeLists.txt before building. Optional CMake values can be found there as well.

mkdir -p build && pushd build
cmake ..
cmake --build .
popd > /dev/null

or using Ninja

mkdir -p build && pushd build
cmake -G Ninja ..
ninja
popd > /dev/null

Install the Device Update Agent

To install the Device Update Agent after building:

sudo cmake --build out --target install

or using Ninja

pushd out > /dev/null
sudo ninja install
popd > /dev/null

Note If the Device Update Agent was built as a daemon, the install targets will install and register the Device Update Agent as a daemon.

Run Device Update Agent

Run Device Update Agent by following these instructions

Integrate the Device Update agent in your existing application or solution

Pre-concepts

Before integrating the Device Update agent in your existing application or solution review the below concepts.

Steps

  1. Create an IoT Hub C-SDK Plug and Play client: Your application needs to support IoT Hub Plug and Play as shown in this example to be used by Device Update for over-the-air updating.
  2. Once you have a IoT Hub Plug and Play enabled device, implement the 'ADU Core' interfaces for your application, see reference code here.
  3. Review the below Device Update agent implementation and source code so that you can modify your application to replicate the same behaviors:
  • Agent Architecture Agent Architecture

  • Workflow phases and source code

Download phase: Download phase

Install phase: Install phase

Apply phase: Apply phase

4.The result reported from your application should be in this format so that the Device Update service can work with your application. Learn more about plug and play format, and Device Update agent workflow.