# infineon/mtb-example-psoc-edge-btstack-gatt-caching-client architecture

> Architecture diagram of the GitHub repository infineon/mtb-example-psoc-edge-btstack-gatt-caching-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client
- Repository: https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client

## Overview

This is a three-core PSOC Edge Bluetooth LE GATT caching client example. Its user-facing workflow is to connect to a GATT server, validate cached database state, discover or rediscover services when needed, and read service characteristics; button actions also reset cached and bonding state. The non-secure CM33 contains the client application, persistence, and board interaction, while secure CM33 and CM55 provide the documented boot chain. The excerpts establish key module responsibilities, but do not show all callback wiring, so uncertain internal connections are omitted.

Main entry points: [`proj_cm33_ns/source/main.c`](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/main.c) (Non-secure app), [`proj_cm33_ns/source/app_bt/app_bt_gatt_handler.c`](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_gatt_handler.c) (GATT caching client), [`proj_cm33_ns/source/app_bt/app_bt_event_handler.c`](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_event_handler.c) (BT event handling), [`proj_cm33_ns/source/app_bt/app_bt_bonding.c`](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_bonding.c) (Bonding and peer state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Boot and cores"]
  node_extended_boot["Extended Boot"]
  node_secure["Secure CM33<br/>[main.c]"]
  node_app_main["Non-secure app<br/>[main.c]"]
  node_cm55["CM55 app<br/>[main.c]"]
end

subgraph group_client["Bluetooth client"]
  node_bt_events["BT event handling"]
  node_gatt["GATT caching client"]
  node_bt_utils["Bluetooth utilities<br/>[app_bt_utils.c]"]
end

subgraph group_state["Bonding and cache"]
  node_bonding["Bonding and peer state<br/>[app_bt_bonding.c]"]
  node_kvstore[("Persistent KV store<br/>[app_bt_bonding.c]")]
end

subgraph group_device["Device interface"]
  node_hardware["Buttons and LEDs<br/>[app_hw_device.c]"]
  node_uart["Debug UART<br/>[retarget_io_init.c]"]
end

node_server(("GATT server"))
node_user(("User"))

node_extended_boot -->|"launches"| node_secure
node_secure -->|"launches"| node_app_main
node_app_main -->|"enables and launches"| node_cm55
node_server -->|"sends BLE events"| node_bt_events
node_user -->|"presses buttons"| node_hardware
node_hardware -->|"requests characteristic read"| node_gatt
node_bt_events -->|"restores peer state"| node_bonding
node_bonding -->|"reads and writes"| node_kvstore
node_gatt -->|"discovers and reads"| node_server
node_gatt -.->|"handles database changes"| node_bt_events
node_user -->|"resets stored state"| node_bonding
node_app_main -->|"initializes"| node_uart

click node_extended_boot "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/configs/boot_with_extended_boot.json"
click node_secure "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_s/main.c"
click node_app_main "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/main.c"
click node_cm55 "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm55/main.c"
click node_bt_events "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_event_handler.c"
click node_gatt "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_gatt_handler.c"
click node_bt_utils "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_utils.c"
click node_bonding "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_bonding.c"
click node_kvstore "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_bonding.c"
click node_hardware "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_hw/app_hw_device.c"
click node_uart "https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_retarget_io/retarget_io_init.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_extended_boot,node_secure,node_app_main,node_cm55,node_user toneBlue
class node_bt_events,node_gatt,node_bt_utils toneAmber
class node_bonding,node_kvstore,node_server toneMint
class node_hardware,node_uart toneRose
```

## Components

### Boot and cores

- [Extended Boot](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/configs/boot_with_extended_boot.json): `configs/boot_with_extended_boot.json`
- [Secure CM33](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_s/main.c): `proj_cm33_s/main.c`
- [Non-secure app](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/main.c): `proj_cm33_ns/source/main.c`
- [CM55 app](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm55/main.c): `proj_cm55/main.c`

### Bluetooth client

- [BT event handling](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_event_handler.c): `proj_cm33_ns/source/app_bt/app_bt_event_handler.c`
- [GATT caching client](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_gatt_handler.c): `proj_cm33_ns/source/app_bt/app_bt_gatt_handler.c`
- [Bluetooth utilities](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_utils.c): `proj_cm33_ns/source/app_bt/app_bt_utils.c`

### Bonding and cache

- [Bonding and peer state](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_bonding.c): `proj_cm33_ns/source/app_bt/app_bt_bonding.c`
- [Persistent KV store](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_bt/app_bt_bonding.c): `proj_cm33_ns/source/app_bt/app_bt_bonding.c`

### Device interface

- [Buttons and LEDs](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_hw/app_hw_device.c): `proj_cm33_ns/source/app_hw/app_hw_device.c`
- [Debug UART](https://github.com/infineon/mtb-example-psoc-edge-btstack-gatt-caching-client/blob/master/proj_cm33_ns/source/app_retarget_io/retarget_io_init.c): `proj_cm33_ns/source/app_retarget_io/retarget_io_init.c`

### Other components

- **GATT server**
- **User**

## Connections

- Extended Boot → Secure CM33: launches (evidence: `README.md`)
- Secure CM33 → Non-secure app: launches (evidence: `README.md`)
- Non-secure app → CM55 app: enables and launches (evidence: `README.md`)
- GATT server → BT event handling: sends BLE events (evidence: `README.md`)
- User → Buttons and LEDs: presses buttons (evidence: `README.md`)
- Buttons and LEDs → GATT caching client: requests characteristic read (evidence: `proj_cm33_ns/source/app_hw/app_hw_device.c`)
- BT event handling → Bonding and peer state: restores peer state (evidence: `proj_cm33_ns/source/app_bt/app_bt_event_handler.c`)
- Bonding and peer state → Persistent KV store: reads and writes (evidence: `proj_cm33_ns/source/app_bt/app_bt_bonding.c`)
- GATT caching client → GATT server: discovers and reads (evidence: `README.md`)
- GATT caching client → BT event handling: handles database changes
- User → Bonding and peer state: resets stored state (evidence: `README.md`)
- Non-secure app → Debug UART: initializes (evidence: `proj_cm33_ns/source/main.c`)
