# googlecloudplatform/iot-device-sdk-embedded-c architecture

> Architecture diagram of the GitHub repository googlecloudplatform/iot-device-sdk-embedded-c, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googlecloudplatform/iot-device-sdk-embedded-c
- Repository: https://github.com/googlecloudplatform/iot-device-sdk-embedded-c

## Overview

This is an embedded C device SDK for connecting low-end IoT devices to Google Cloud IoT Core. An application initializes the SDK, configures credentials and connection data, then uses its MQTT API to connect and exchange publish/subscribe traffic over a non-blocking network connection; TLS and platform services make the transport portable. The graph preserves documented control-topic, filesystem, JWT, event-processing, and BSP capabilities. Most implementation files are unsampled, so edges beyond the excerpted references and README descriptions are omitted or marked unverified.

Main entry points: [`src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c`](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c) (MQTT logic), [`include/iotc.h`](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/iotc.h) (SDK API), [`src/libiotc/io/net/iotc_io_net_layer.c`](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/net/iotc_io_net_layer.c) (Network layer), [`src/libiotc/tls/iotc_tls_layer.c`](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/tls/iotc_tls_layer.c) (TLS layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Application API"]
  node_public_api["SDK API<br/>[iotc.h]"]
  node_connection["Connection data"]
end

subgraph group_protocol["Connection and MQTT"]
  node_control["Control topics"]
  node_mqtt_logic["MQTT logic"]
  node_mqtt_codec["MQTT codec"]
  node_net_layer["Network layer"]
end

subgraph group_runtime["Async Runtime"]
  node_event_dispatch["Event dispatcher"]
  node_event_loop["Event loop<br/>[iotc_event_loop.c]"]
  node_resource_manager["Resource manager"]
end

subgraph group_platform["Platform Services"]
  node_fs_api["Filesystem API<br/>[iotc_fs_api.h]"]
  node_bsp_network["Network BSP<br/>[iotc_bsp_io_net.h]"]
  node_bsp_tls["TLS BSP<br/>[iotc_bsp_tls.h]"]
  node_bsp_crypto["Crypto BSP<br/>[iotc_bsp_crypto.h]"]
  node_bsp_platform["Platform BSP<br/>[iotc_bsp_mem.h]"]
end

subgraph group_security["Security"]
  node_jwt["JWT credentials<br/>[iotc_jwt.c]"]
  node_tls_layer["TLS layer<br/>[iotc_tls_layer.c]"]
  node_tls_impl["TLS implementations"]
  node_crypto_impl["Crypto implementations"]
end

node_app(("Device application"))
node_cloud{{"Cloud IoT Core"}}

node_app -->|"calls"| node_public_api
node_public_api -.->|"configures"| node_connection
node_public_api -.->|"starts MQTT"| node_mqtt_logic
node_public_api -->|"processes events"| node_event_loop
node_mqtt_logic -.->|"encodes MQTT"| node_mqtt_codec
node_mqtt_codec -.->|"transfers packets"| node_net_layer
node_net_layer -.->|"secures transport"| node_tls_layer
node_tls_layer -->|"connects securely"| node_cloud
node_mqtt_logic -->|"publishes and subscribes"| node_cloud
node_mqtt_logic -.->|"handles control topics"| node_control
node_mqtt_logic -->|"schedules keepalive"| node_event_dispatch
node_event_loop -.->|"runs events"| node_event_dispatch
node_resource_manager -->|"registers file events"| node_event_dispatch
node_resource_manager -->|"calls filesystem"| node_fs_api
node_fs_api -.->|"uses platform files"| node_bsp_platform
node_net_layer -->|"uses socket BSP"| node_bsp_network
node_tls_layer -->|"uses TLS BSP"| node_bsp_tls
node_bsp_tls -->|"implemented by"| node_tls_impl
node_jwt -.->|"signs credentials"| node_bsp_crypto
node_bsp_crypto -->|"implemented by"| node_crypto_impl
node_connection -.->|"supplies credentials"| node_jwt

click node_public_api "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/iotc.h"
click node_connection "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/iotc_connection_data.c"
click node_jwt "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/iotc_jwt.c"
click node_control "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/control_topic/iotc_control_topic_layer.c"
click node_mqtt_logic "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c"
click node_mqtt_codec "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/mqtt/codec/iotc_mqtt_codec_layer.c"
click node_net_layer "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/net/iotc_io_net_layer.c"
click node_tls_layer "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/tls/iotc_tls_layer.c"
click node_event_dispatch "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/event_dispatcher/iotc_event_dispatcher.c"
click node_event_loop "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/event_loop/iotc_event_loop.c"
click node_resource_manager "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/fs/iotc_resource_manager.c"
click node_fs_api "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/fs/iotc_fs_api.h"
click node_bsp_network "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_io_net.h"
click node_bsp_tls "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_tls.h"
click node_bsp_crypto "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_crypto.h"
click node_bsp_platform "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_mem.h"
click node_tls_impl "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/bsp/tls/mbedtls/iotc_bsp_tls_mbedtls.c"
click node_crypto_impl "https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/bsp/crypto/mbedtls/iotc_bsp_crypto_mbedtls.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_connection toneBlue
class node_control,node_mqtt_logic,node_mqtt_codec,node_net_layer toneAmber
class node_event_dispatch,node_event_loop,node_resource_manager toneMint
class node_fs_api,node_bsp_network,node_bsp_tls,node_bsp_crypto,node_bsp_platform toneRose
class node_jwt,node_tls_layer,node_tls_impl,node_crypto_impl,node_app,node_cloud toneIndigo
```

## Components

### Application API

- [SDK API](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/iotc.h): `include/iotc.h`
- [Connection data](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/iotc_connection_data.c): `src/libiotc/iotc_connection_data.c`

### Connection and MQTT

- [Control topics](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/control_topic/iotc_control_topic_layer.c): `src/libiotc/control_topic/iotc_control_topic_layer.c`
- [MQTT logic](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c): `src/libiotc/mqtt/logic/iotc_mqtt_logic_layer.c`
- [MQTT codec](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/mqtt/codec/iotc_mqtt_codec_layer.c): `src/libiotc/mqtt/codec/iotc_mqtt_codec_layer.c`
- [Network layer](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/net/iotc_io_net_layer.c): `src/libiotc/io/net/iotc_io_net_layer.c`

### Async Runtime

- [Event dispatcher](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/event_dispatcher/iotc_event_dispatcher.c): `src/libiotc/event_dispatcher/iotc_event_dispatcher.c`
- [Event loop](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/event_loop/iotc_event_loop.c): `src/libiotc/event_loop/iotc_event_loop.c`
- [Resource manager](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/fs/iotc_resource_manager.c): `src/libiotc/io/fs/iotc_resource_manager.c`

### Platform Services

- [Filesystem API](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/io/fs/iotc_fs_api.h): `src/libiotc/io/fs/iotc_fs_api.h`
- [Network BSP](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_io_net.h): `include/bsp/iotc_bsp_io_net.h`
- [TLS BSP](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_tls.h): `include/bsp/iotc_bsp_tls.h`
- [Crypto BSP](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_crypto.h): `include/bsp/iotc_bsp_crypto.h`
- [Platform BSP](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/include/bsp/iotc_bsp_mem.h): `include/bsp/iotc_bsp_mem.h`

### Security

- [JWT credentials](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/iotc_jwt.c): `src/libiotc/iotc_jwt.c`
- [TLS layer](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/libiotc/tls/iotc_tls_layer.c): `src/libiotc/tls/iotc_tls_layer.c`
- [TLS implementations](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/bsp/tls/mbedtls/iotc_bsp_tls_mbedtls.c): `src/bsp/tls/mbedtls/iotc_bsp_tls_mbedtls.c`
- [Crypto implementations](https://github.com/googlecloudplatform/iot-device-sdk-embedded-c/blob/master/src/bsp/crypto/mbedtls/iotc_bsp_crypto_mbedtls.c): `src/bsp/crypto/mbedtls/iotc_bsp_crypto_mbedtls.c`

### Other components

- **Device application**
- **Cloud IoT Core**

## Connections

- Device application → SDK API: calls (evidence: `include/iotc.h`)
- SDK API → Connection data: configures
- SDK API → MQTT logic: starts MQTT
- SDK API → Event loop: processes events (evidence: `include/iotc.h`)
- MQTT logic → MQTT codec: encodes MQTT
- MQTT codec → Network layer: transfers packets
- Network layer → TLS layer: secures transport
- TLS layer → Cloud IoT Core: connects securely (evidence: `README.md`)
- MQTT logic → Cloud IoT Core: publishes and subscribes (evidence: `README.md`)
- MQTT logic → Control topics: handles control topics
- MQTT logic → Event dispatcher: schedules keepalive
- Event loop → Event dispatcher: runs events
- Resource manager → Event dispatcher: registers file events (evidence: `src/libiotc/io/fs/iotc_resource_manager.c`)
- Resource manager → Filesystem API: calls filesystem (evidence: `src/libiotc/io/fs/iotc_resource_manager.c`)
- Filesystem API → Platform BSP: uses platform files
- Network layer → Network BSP: uses socket BSP (evidence: `README.md`)
- TLS layer → TLS BSP: uses TLS BSP (evidence: `README.md`)
- TLS BSP → TLS implementations: implemented by (evidence: `README.md`)
- JWT credentials → Crypto BSP: signs credentials
- Crypto BSP → Crypto implementations: implemented by (evidence: `README.md`)
- Connection data → JWT credentials: supplies credentials
