# pvvx/atc_mithermometer architecture

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

- Interactive diagram: https://gitdiagram.com/pvvx/atc_mithermometer
- Repository: https://github.com/pvvx/atc_mithermometer

## Overview

This repository provides custom BLE thermometer and hygrometer firmware for Telink devices, alongside Python tooling for advertising/configuration and firmware flashing. The device workflow is to acquire sensor readings, expose them over BLE in configurable beacon formats, and present them on supported displays; users can configure devices and perform OTA updates. The README also documents measurement history, security, extended BLE modes, and Zigbee-related OTA support. Some subsystem links below are documented capabilities or inferred from module names; unsampled implementation details are not asserted as inspected.

Main entry points: [`src/app.c`](https://github.com/pvvx/atc_mithermometer/blob/master/src/app.c) (Device Application), [`src/main.c`](https://github.com/pvvx/atc_mithermometer/blob/master/src/main.c) (Firmware Startup), [`python-interface/atc_mi_interface/atc_mi_config.py`](https://github.com/pvvx/atc_mithermometer/blob/master/python-interface/atc_mi_interface/atc_mi_config.py) (Python Config Tools), [`src/sensors.c`](https://github.com/pvvx/atc_mithermometer/blob/master/src/sensors.c) (Sensor Acquisition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Device Firmware"]
  node_main["Firmware Startup<br/>[main.c]"]
  node_app["Device Application<br/>[app.c]"]
  node_sensors["Sensor Acquisition<br/>[sensors.c]"]
  node_sensor_drivers["Sensor Drivers<br/>[bme280.c]"]
  node_display["LCD and E-paper<br/>[lcd.c]"]
  node_history[("Measurement History<br/>[logger.c]")]
end

subgraph group_connectivity["BLE and OTA"]
  node_beacons["Beacon Formats<br/>[mi_beacon.c]"]
  node_ble["BLE Services<br/>[ble.c]"]
  node_ble_stack["Telink BLE Stack<br/>[ble.h]"]
  node_ota["Extended OTA<br/>[ext_ota.h]"]
end

subgraph group_interfaces["User Interfaces"]
  node_commands["Device Commands<br/>[cmd_parser.c]"]
  node_python_config["Python Config Tools<br/>[atc_mi_config.py]"]
  node_python_advertising["Advertising Tools"]
  node_flasher(("Browser Flasher"))
end

subgraph group_platform["Runtime Platform"]
  node_drivers["Telink Drivers<br/>[driver_8258.h]"]
  node_freertos["FreeRTOS Kernel<br/>[tasks.c]"]
end

node_owner(("Device User"))

node_owner -.->|"runs firmware"| node_main
node_main -.->|"starts application"| node_app
node_app -->|"uses measurements"| node_sensors
node_sensors -.->|"reads sensors"| node_sensor_drivers
node_app -.->|"updates display"| node_display
node_app -.->|"records measurements"| node_history
node_app -.->|"publishes formats"| node_beacons
node_beacons -.->|"advertises data"| node_ble
node_ble -->|"uses BLE stack"| node_ble_stack
node_app -->|"handles configuration"| node_commands
node_owner -.->|"configures device"| node_python_config
node_python_config -->|"formats advertisements"| node_python_advertising
node_python_config -.->|"sets device options"| node_commands
node_flasher -.->|"performs OTA"| node_ota
node_main -->|"initializes hardware"| node_drivers
node_main -.->|"uses runtime"| node_freertos

click node_main "https://github.com/pvvx/atc_mithermometer/blob/master/src/main.c"
click node_app "https://github.com/pvvx/atc_mithermometer/blob/master/src/app.c"
click node_sensors "https://github.com/pvvx/atc_mithermometer/blob/master/src/sensors.c"
click node_sensor_drivers "https://github.com/pvvx/atc_mithermometer/blob/master/src/bme280.c"
click node_display "https://github.com/pvvx/atc_mithermometer/blob/master/src/lcd.c"
click node_history "https://github.com/pvvx/atc_mithermometer/blob/master/src/logger.c"
click node_beacons "https://github.com/pvvx/atc_mithermometer/blob/master/src/mi_beacon.c"
click node_ble "https://github.com/pvvx/atc_mithermometer/blob/master/src/ble.c"
click node_ble_stack "https://github.com/pvvx/atc_mithermometer/blob/master/SDK/components/stack/ble/ble.h"
click node_ota "https://github.com/pvvx/atc_mithermometer/blob/master/src/ext_ota.h"
click node_commands "https://github.com/pvvx/atc_mithermometer/blob/master/src/cmd_parser.c"
click node_python_config "https://github.com/pvvx/atc_mithermometer/blob/master/python-interface/atc_mi_interface/atc_mi_config.py"
click node_python_advertising "https://github.com/pvvx/atc_mithermometer/blob/master/python-interface/atc_mi_interface/atc_mi_advertising.py"
click node_drivers "https://github.com/pvvx/atc_mithermometer/blob/master/SDK/components/drivers/8258/driver_8258.h"
click node_freertos "https://github.com/pvvx/atc_mithermometer/blob/master/SDK/components/freertos/tasks.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_main,node_app,node_sensors,node_sensor_drivers,node_display,node_history,node_owner toneBlue
class node_beacons,node_ble,node_ble_stack,node_ota toneAmber
class node_commands,node_python_config,node_python_advertising,node_flasher toneMint
class node_drivers,node_freertos toneRose
```

## Components

### Device Firmware

- [Firmware Startup](https://github.com/pvvx/atc_mithermometer/blob/master/src/main.c): `src/main.c`
- [Device Application](https://github.com/pvvx/atc_mithermometer/blob/master/src/app.c): `src/app.c`
- [Sensor Acquisition](https://github.com/pvvx/atc_mithermometer/blob/master/src/sensors.c): `src/sensors.c`
- [Sensor Drivers](https://github.com/pvvx/atc_mithermometer/blob/master/src/bme280.c): `src/bme280.c`
- [LCD and E-paper](https://github.com/pvvx/atc_mithermometer/blob/master/src/lcd.c): `src/lcd.c`
- [Measurement History](https://github.com/pvvx/atc_mithermometer/blob/master/src/logger.c): `src/logger.c`

### BLE and OTA

- [Beacon Formats](https://github.com/pvvx/atc_mithermometer/blob/master/src/mi_beacon.c): `src/mi_beacon.c`
- [BLE Services](https://github.com/pvvx/atc_mithermometer/blob/master/src/ble.c): `src/ble.c`
- [Telink BLE Stack](https://github.com/pvvx/atc_mithermometer/blob/master/SDK/components/stack/ble/ble.h): `SDK/components/stack/ble/ble.h`
- [Extended OTA](https://github.com/pvvx/atc_mithermometer/blob/master/src/ext_ota.h): `src/ext_ota.h`

### User Interfaces

- [Device Commands](https://github.com/pvvx/atc_mithermometer/blob/master/src/cmd_parser.c): `src/cmd_parser.c`
- [Python Config Tools](https://github.com/pvvx/atc_mithermometer/blob/master/python-interface/atc_mi_interface/atc_mi_config.py): `python-interface/atc_mi_interface/atc_mi_config.py`
- [Advertising Tools](https://github.com/pvvx/atc_mithermometer/blob/master/python-interface/atc_mi_interface/atc_mi_advertising.py): `python-interface/atc_mi_interface/atc_mi_advertising.py`
- **Browser Flasher**

### Runtime Platform

- [Telink Drivers](https://github.com/pvvx/atc_mithermometer/blob/master/SDK/components/drivers/8258/driver_8258.h): `SDK/components/drivers/8258/driver_8258.h`
- [FreeRTOS Kernel](https://github.com/pvvx/atc_mithermometer/blob/master/SDK/components/freertos/tasks.c): `SDK/components/freertos/tasks.c`

### Other components

- **Device User**

## Connections

- Device User → Firmware Startup: runs firmware
- Firmware Startup → Device Application: starts application
- Device Application → Sensor Acquisition: uses measurements (evidence: `src/app.c`)
- Sensor Acquisition → Sensor Drivers: reads sensors
- Device Application → LCD and E-paper: updates display
- Device Application → Measurement History: records measurements
- Device Application → Beacon Formats: publishes formats
- Beacon Formats → BLE Services: advertises data
- BLE Services → Telink BLE Stack: uses BLE stack
- Device Application → Device Commands: handles configuration (evidence: `src/app.c`)
- Device User → Python Config Tools: configures device
- Python Config Tools → Advertising Tools: formats advertisements (evidence: `python-interface/atc_mi_interface/atc_mi_advertising.py`)
- Python Config Tools → Device Commands: sets device options
- Browser Flasher → Extended OTA: performs OTA
- Firmware Startup → Telink Drivers: initializes hardware (evidence: `src/main.c`)
- Firmware Startup → FreeRTOS Kernel: uses runtime
