# cavlihakki/cavliapplication architecture

> Architecture diagram of the GitHub repository cavlihakki/cavliapplication, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cavlihakki/cavliapplication
- Repository: https://github.com/cavlihakki/cavliapplication

## Overview

The CavliApplication repository is a collection of embedded software projects targeting the Cavli Wireless C16QS module – with a focus on STM32‐based implementations (using the NUCLEO-G071RB board) as well as Arduino examples. The repository contains several individual projects (for example, CavliC16QSEVK-MQTT-1, CavliC16QSEVK-TCP-1, CavliC16QSEVK-TCP-2, and CavliC16QSEVK-GPIO7-1) that share common libraries (such as the CavliLib with module-specific functions defined in C16QS.h and Serial communications) and use the STM32CubeIDE folder structure with standard “Core”, “Drivers”, and “CavliLib” directories.

##### Overall Project Scope and Components
- There are basically two hardware platforms:
– STM32-based applications running on the NUCLEO-G071RB.
– Arduino-based applications running on Arduino Uno.
- For each STM32 project (MQTT, TCP, GPIO):
– Identify the MCU (the STM32G0 series on the Nucleo board) as the hardware processing unit.
– Identify that the “Core” folder holds the application logic (main loop, initialization, and system-level routines).
– The “Drivers” folder provides the Hardware Abstraction Layer (HAL) offered by ST, which encapsulates the low-level peripheral drivers (UART, GPIO, DMA, etc.).
– The “CavliLib” directory contains module-specific drivers and abstraction code (for instance, functions to configure MQTT connection parameters, TCP settings, or perform GPIO toggling) which serve as the middleware layer.
- The Arduino projects follow a similar pattern:
– They include basic sketches (in .ino files) that use either hardware serial/SoftwareSerial (note the AT command adjustments) and use logic similar to the STM32 cases.
- External network and peripheral resources:
– MQTT broker and TCP server are external components which the embedded application communicates with. The C16QS.h header file in CavliLib must be configured with the proper network addresses and ports.
– Additional documentation (in Dokumanlar and Documents folders) offers usage notes and configuration instructions.

##### Break Down the Architecture into Layers and Components
- Hardware Layer:
– STM32G0 MCU on the Nucleo board.
– External components such as the Cavli Wireless C16QS module.
– For Arduino, the Arduino Uno board along with its debug UART and any external connections (LEDs, GNSS antenna for GNSS variant).
- Low-Level Firmware / Device Drivers:
– ST Microelectronics’ HAL drivers (contained in Drivers/CMSIS and STM32G0xx_HAL_Driver).
- Middleware / Module-Specific Library:
– CavliLib includes common module-specific code to interface with the C16QS module (e.g., functions for MQTT, TCP, or generic GPIO manipulation).
- Application Layer:
– Each individual project’s Core folder is where the main application logic, initialization routines, interrupt service routines, and the task loop are implemented.
- External Communication:
– For MQTT projects: a connection is established to an external MQTT broker.
– For TCP projects: there is either a “normal” or “transparan” mode which interacts with an external TCP server.
- Development and Build Handling:
– Project configuration files (.cproject, .mxproject, .project, etc.) indicate the use of STM32CubeIDE (for STM32) and potentially Arduino IDE configurations for the Arduino sketches.

– “Core Application” (with main.c, initialization routines),
– “HAL Drivers” (as one component) on one side,
– “CavliLib” as the middleware connecting the core application with the physical module.
– The “Core” to the “HAL Drivers” (for peripheral access).
– The “Core” to “CavliLib” (for module-specific commands such as network or GPIO operations).

##### Architectural Patterns and Technologies
- The projects follow a layered or modular design which is common in embedded applications.
- They use a hardware abstraction paradigm (HAL) and further abstract away module specifics with a dedicated library (CavliLib).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Hardware Layer"
        H1("STM32 MCU"):::hardware
        H2("Cavli Wireless C16QS Module"):::hardware
        H3("Arduino Uno"):::hardware
    end

    subgraph "Firmware/Drivers Layer"
        F1("HAL Drivers"):::software
    end

    subgraph "Middleware Layer"
        M1("CavliLib – Module Interface"):::software
    end

    subgraph "Application Layer"
        A1("Core Application Logic"):::software
        A2("Arduino Implementation"):::software
    end

    Dev("Development Environment: STM32CubeIDE"):::dev
    Doc("Documentation & Manuals"):::external
    E1("MQTT Broker"):::external
    E2("TCP Server"):::external

    %% Connections between layers
    A1 -->|"uses"| F1
    A1 -->|"calls"| M1
    F1 -->|"operates_on"| H1
    A1 -->|"runs_on"| H1
    M1 -->|"controls"| H2
    M1 -->|"communicates"| E1
    M1 -->|"communicates"| E2
    A2 -->|"controls"| H2
    A2 -->|"runs_on"| H3
    Dev -->|"builds"| A1
    Dev -->|"builds"| F1
    Dev -->|"builds"| M1
    Doc -->|"guides"| A1

    %% Click events for component mapping
    click F1 "https://github.com/cavlihakki/cavliapplication/tree/main/CavliC16QSEVK-GPIO7-1/Drivers/STM32G0xx_HAL_Driver"
    click M1 "https://github.com/cavlihakki/cavliapplication/tree/main/CavliC16QSEVK-MQTT-1/CavliLib"
    click A1 "https://github.com/cavlihakki/cavliapplication/tree/main/CavliC16QSEVK-MQTT-1/Core"
    click A2 "https://github.com/cavlihakki/cavliapplication/tree/main/ArduinoC16QS-GNSS"
    click Doc "https://github.com/cavlihakki/cavliapplication/tree/main/CavliC16QSEVK-GPIO7-1/Documents"

    %% Styles
    classDef hardware fill:#FFE6E6,stroke:#000,stroke-width:2px;
    classDef software fill:#E6F7FF,stroke:#000,stroke-width:2px;
    classDef external fill:#E6FFE6,stroke:#000,stroke-width:2px;
    classDef dev fill:#FFFACD,stroke:#000,stroke-width:2px;
```
