Clea Framework IoT Services Architecture
This document describes the architecture of the Clea integration as implemented in the Yocto layer meta-seco-clea-os, focusing on the components in recipes-iot.
Overview
The Clea Cloud stack for IoT devices is composed of several Rust-based applications and supporting services, each packaged and managed by Yocto recipes. These components enable secure device management, telemetry, OTA updates, and cloud connectivity via Data Orchestrator and Device Manager.
Main Components
-
Edgehog Device Runtime
- Middleware for device management, monitoring, OTA, and container orchestration.
- Communicates with the cloud via Astarte Device SDK or Astarte Message Hub.
- See:
edgehog-device-runtime
-
Astarte Message Hub
- D-Bus service that multiplexes messages between device services and the Data Orchestrator backend.
- Allows multiple applications to share a single Data Orchestrator connection.
- See:
astarte-message-hub
-
Device Manager Data Orchestrator Interfaces
- Defines the Data Orchestrator interfaces used for device-cloud communication.
- See:
edgehog-astarte-interfaces
-
Service Wrappers
For more details, see Service Wrappers.
How Recipes and Services Work Together
-
Yocto Recipes
Each application or service is described by a Yocto recipe (.bbfile). The recipe:- Fetches source code or binaries.
- Builds the application (often using Rust and Cargo).
- Installs binaries, configuration files, and systemd unit files to the target rootfs.
How .bb files are generated for Rust projects:
For Rust-based components, we usecargo-bitbake, a tool that generates BitBake recipes directly from a Cargo project.
Run the following command inside the Rust project directory to generate a starting.bbfile:cargo bitbakeThis produces a BitBake recipe tailored for the Rust crate, which can then be customized as needed for integration into the Yocto build.
-
Technical Details: Building Rust Applications with BitBake and Cargo
The Rust-based components (such as Edgehog Device Runtime and Astarte Message Hub) are built using thebitbakebuild system, which is part of Yocto.- The recipes leverage the
cargoclass provided by Yocto to build Rust projects. - During the build, BitBake executes the
cargocommand inside the source repository, ensuring all dependencies are fetched and the binaries are compiled for the target architecture. - This approach allows seamless integration of Rust projects into the Yocto build pipeline, producing reproducible and cross-compiled binaries suitable for embedded devices.
- The recipes leverage the
-
Systemd Service Recipes
For each main application, a corresponding service recipe provides:- A systemd unit file (e.g.,
edgehog-device-runtime.service). - A wrapper script if needed.
- Ensures the service is enabled and started at boot.
- A systemd unit file (e.g.,
-
Integration Example
- The runtime and message hub are both installed and managed as systemd services.
- The runtime can communicate directly with Data Orchestrator or via the message hub, depending on configuration.
- All services are started and monitored by systemd, as defined in the service recipes.
Architecture Diagram
Legend:
- Client services on the device communicate with the Message Hub via D-Bus.
- The Message Hub manages a single connection to the Data Orchestrator backend (MQTT/WebSocket).
- Client services do not need to implement Astarte SDK logic; they use D-Bus calls/signals.
File and Recipe Structure
-
recipes-iot/astarte-message-hub/:astarte-message-hub_0.5.4.bb: Builds and installs the message hub daemon.files/: Contains systemd unit files and scripts.
-
recipes-iot/edgehog-device-runtime/:edgehog-device-runtime_0.8.1.bb: Builds and installs the device runtime.edgehog-astarte-interfaces_0.8.0.bb: Installs Data Orchestrator interface definitions.
-
recipes-iot/service-edgehog-device-runtime/:service-edgehog-device-runtime.bb: Installs and enables the runtime as a systemd service.service-astarte-message-hub.bb: Installs and enables the message hub as a systemd service.
Summary Table
| Component | Recipe/Service Name | Role |
|---|---|---|
| Edgehog Device Runtime | edgehog-device-runtime | Device management middleware |
| Astarte Message Hub | astarte-message-hub | D-Bus to Data Orchestrator bridge |
| Device Manager Data Orchestrator Interfaces | edgehog-astarte-interfaces | Data Orchestrator interface definitions |
| Runtime Service Wrapper | service-edgehog-device-runtime | Systemd service for runtime |
| Message Hub Service Wrapper | service-astarte-message-hub | Systemd service for message hub |
References
- Edgehog Device Runtime
- Astarte Message Hub
- Device Manager Data Orchestrator Interfaces
- Service Wrappers