# codexpawan/st17h66_ble_adv architecture

> Architecture diagram of the GitHub repository codexpawan/st17h66_ble_adv, 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/codexpawan/st17h66_ble_adv
- Repository: https://github.com/codexpawan/st17h66_ble_adv

## Overview

This is embedded firmware for a BLE peripheral, with an application that handles BLE profile events and also includes ADC measurement and UART command processing. The visible startup path initializes the platform, enters OSAL, and registers the BLE application task. The OTA-named profile provides GATT attributes and queues application work on writes. Source excerpts do not establish the complete OTA transfer path or all application-to-profile wiring, so those relationships are not inferred.

Main entry points: [`source/OSAL_SimpleBLEPeripheral.c`](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/OSAL_SimpleBLEPeripheral.c) (Task registry), [`source/SimpleBLEPeripheral_Main.c`](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/SimpleBLEPeripheral_Main.c) (OSAL task setup), [`source/sbpProfile_ota.c`](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/sbpProfile_ota.c) (GATT profile), [`main.c`](https://github.com/codexpawan/st17h66_ble_adv/blob/main/main.c) (Firmware entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and OSAL"]
  node_firmware_entry["Firmware entry<br/>[main.c]"]
  node_osal_runner["OSAL task setup"]
  node_task_registry["Task registry"]
end

subgraph group_ble["BLE application"]
  node_ble_stack["BLE stack tasks"]
  node_peripheral_app["Peripheral app"]
  node_app_events["Application events"]
  node_gatt_profile["GATT profile<br/>[sbpProfile_ota.c]"]
  node_profile_api["Profile definitions<br/>[sbpProfile_ota.h]"]
end

subgraph group_io["Device I/O"]
  node_peripheral_io["Peripheral I/O<br/>[halPeripheral.c]"]
  node_io_api["I/O events<br/>[halPeripheral.h]"]
end

node_ble_central(("BLE central"))
node_device_hardware{{"Device hardware"}}

node_firmware_entry -->|"calls app_main"| node_osal_runner
node_osal_runner -->|"starts OSAL"| node_task_registry
node_task_registry -->|"initializes tasks"| node_ble_stack
node_task_registry -->|"registers task"| node_peripheral_app
node_gatt_profile -->|"queues write event"| node_app_events
node_ble_central -.->|"reads and writes"| node_gatt_profile
node_peripheral_io -.->|"handles I/O"| node_device_hardware

click node_firmware_entry "https://github.com/codexpawan/st17h66_ble_adv/blob/main/main.c"
click node_osal_runner "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/SimpleBLEPeripheral_Main.c"
click node_task_registry "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/OSAL_SimpleBLEPeripheral.c"
click node_peripheral_app "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/simpleBLEPeripheral.c"
click node_app_events "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/simpleBLEPeripheral.h"
click node_gatt_profile "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/sbpProfile_ota.c"
click node_profile_api "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/sbpProfile_ota.h"
click node_peripheral_io "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/halPeripheral.c"
click node_io_api "https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/halPeripheral.h"

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_firmware_entry,node_osal_runner,node_task_registry toneBlue
class node_ble_stack,node_peripheral_app,node_app_events,node_gatt_profile,node_profile_api toneAmber
class node_peripheral_io,node_io_api toneMint
class node_ble_central,node_device_hardware toneIndigo
```

## Components

### Startup and OSAL

- [Firmware entry](https://github.com/codexpawan/st17h66_ble_adv/blob/main/main.c): `main.c`
- [OSAL task setup](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/SimpleBLEPeripheral_Main.c): `source/SimpleBLEPeripheral_Main.c`
- [Task registry](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/OSAL_SimpleBLEPeripheral.c): `source/OSAL_SimpleBLEPeripheral.c`

### BLE application

- **BLE stack tasks**
- [Peripheral app](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/simpleBLEPeripheral.c): `source/simpleBLEPeripheral.c`
- [Application events](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/simpleBLEPeripheral.h): `source/simpleBLEPeripheral.h`
- [GATT profile](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/sbpProfile_ota.c): `source/sbpProfile_ota.c`
- [Profile definitions](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/sbpProfile_ota.h): `source/sbpProfile_ota.h`

### Device I/O

- [Peripheral I/O](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/halPeripheral.c): `source/halPeripheral.c`
- [I/O events](https://github.com/codexpawan/st17h66_ble_adv/blob/main/source/halPeripheral.h): `source/halPeripheral.h`

### Other components

- **BLE central**
- **Device hardware**

## Connections

- Firmware entry → OSAL task setup: calls app_main (evidence: `main.c`)
- OSAL task setup → Task registry: starts OSAL (evidence: `source/SimpleBLEPeripheral_Main.c`)
- Task registry → BLE stack tasks: initializes tasks (evidence: `source/OSAL_SimpleBLEPeripheral.c`)
- Task registry → Peripheral app: registers task (evidence: `source/OSAL_SimpleBLEPeripheral.c`)
- GATT profile → Application events: queues write event (evidence: `source/sbpProfile_ota.c`)
- BLE central → GATT profile: reads and writes (evidence: `source/sbpProfile_ota.c`)
- Peripheral I/O → Device hardware: handles I/O
