# mdrafiislam/ble_nrf52832 architecture

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

- Interactive diagram: https://gitdiagram.com/mdrafiislam/ble_nrf52832
- Repository: https://github.com/mdrafiislam/ble_nrf52832

## Overview

BLE_nRF52832 is nRF52832 firmware bridging a BLE peripheral to an SPI slave, with companion MATLAB tools for receiving and displaying BLE data and a documented wireless-DFU packaging workflow. The firmware path is BLE commands/data into the device, with phone bridge payloads queued for SPI delivery and SPI data forwarded toward BLE. The README also documents building and merging application, SoftDevice, and bootloader images for DFU. Source excerpts are partial, so unsampled MATLAB internals and some firmware dispatch details are not asserted.

Main entry points: [`Merge_and_zip/ble_spis_merge_zip_Generator.bat`](https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/ble_spis_merge_zip_Generator.bat) (DFU image generator), [`main.c`](https://github.com/mdrafiislam/ble_nrf52832/blob/main/main.c) (Firmware app), [`MatlabReceiveCode/connect_V5.m`](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/connect_V5.m) (Receiver runner), [`MatlabReceiveCode/ble_connect.m`](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/ble_connect.m) (BLE connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Device Firmware"]
  node_main["Firmware app<br/>[main.c]"]
  node_ble_cmd["BLE commands<br/>[SS_BleCmd.c]"]
  node_spi_slave["SPI slave bridge<br/>[SS_SpiSlave.c]"]
  node_sdk_config["SDK configuration<br/>[sdk_config.h]"]
end

subgraph group_host["MATLAB Receiver"]
  node_ble_discovery["BLE discovery"]
  node_ble_connect["BLE connection<br/>[ble_connect.m]"]
  node_matlab_run["Receiver runner<br/>[connect_V5.m]"]
  node_matlab_decode["Data decode<br/>[text_file_decode.m]"]
  node_matlab_display["Data display<br/>[display_data.m]"]
end

subgraph group_dfu["DFU Packaging"]
  node_application_hex["Application image"]
  node_softdevice_hex["SoftDevice image"]
  node_bootloader_hex["Bootloader image"]
  node_dfu_generator["DFU image generator"]
  node_dfu_package["DFU package"]
end

node_ble_peer(("BLE peer"))
node_spi_master(("SPI master"))
node_matlab_user(("MATLAB user"))
node_nrfutil["nrfutil"]

node_ble_peer -->|"sends BLE data"| node_main
node_main -->|"initializes commands"| node_ble_cmd
node_main -->|"queues bridge data"| node_spi_slave
node_spi_master -->|"exchanges SPI data"| node_spi_slave
node_main -->|"uses settings"| node_sdk_config
node_matlab_user -->|"runs discovery"| node_ble_discovery
node_ble_discovery -->|"provides device address"| node_ble_connect
node_matlab_user -->|"runs receiver"| node_matlab_run
node_matlab_run -.->|"uses connection"| node_ble_connect
node_ble_peer -.->|"connects over BLE"| node_ble_connect
node_matlab_run -.->|"decodes received data"| node_matlab_decode
node_matlab_decode -.->|"feeds display"| node_matlab_display
node_application_hex -->|"merges image"| node_dfu_generator
node_softdevice_hex -->|"merges image"| node_dfu_generator
node_bootloader_hex -->|"merges image"| node_dfu_generator
node_dfu_generator -->|"uses packaging tool"| node_nrfutil
node_dfu_generator -->|"creates package"| node_dfu_package

click node_main "https://github.com/mdrafiislam/ble_nrf52832/blob/main/main.c"
click node_ble_cmd "https://github.com/mdrafiislam/ble_nrf52832/blob/main/SS_BleCmd.c"
click node_spi_slave "https://github.com/mdrafiislam/ble_nrf52832/blob/main/SS_SpiSlave.c"
click node_sdk_config "https://github.com/mdrafiislam/ble_nrf52832/blob/main/pca10040/s132/config/sdk_config.h"
click node_ble_discovery "https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/checkAvailableBLEDevices.m"
click node_ble_connect "https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/ble_connect.m"
click node_matlab_run "https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/connect_V5.m"
click node_matlab_decode "https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/text_file_decode.m"
click node_matlab_display "https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/display_data.m"
click node_application_hex "https://github.com/mdrafiislam/ble_nrf52832/blob/main/pca10040/s132/ses/ble_app_spis_pca10040_s132.emProject"
click node_softdevice_hex "https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/SD_hex/s132_nrf52_7.2.0_softdevice.hex"
click node_bootloader_hex "https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/BL_hex/secure_bootloader_ble_s132_pca10040.hex"
click node_dfu_generator "https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/ble_spis_merge_zip_Generator.bat"
click node_dfu_package "https://github.com/mdrafiislam/ble_nrf52832/tree/main/Merge_and_zip"

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_ble_cmd,node_spi_slave,node_sdk_config,node_matlab_user toneBlue
class node_ble_discovery,node_ble_connect,node_matlab_run,node_matlab_decode,node_matlab_display toneAmber
class node_application_hex,node_softdevice_hex,node_bootloader_hex,node_dfu_generator,node_dfu_package toneMint
class node_ble_peer,node_spi_master,node_nrfutil toneIndigo
```

## Components

### Device Firmware

- [Firmware app](https://github.com/mdrafiislam/ble_nrf52832/blob/main/main.c): `main.c`
- [BLE commands](https://github.com/mdrafiislam/ble_nrf52832/blob/main/SS_BleCmd.c): `SS_BleCmd.c`
- [SPI slave bridge](https://github.com/mdrafiislam/ble_nrf52832/blob/main/SS_SpiSlave.c): `SS_SpiSlave.c`
- [SDK configuration](https://github.com/mdrafiislam/ble_nrf52832/blob/main/pca10040/s132/config/sdk_config.h): `pca10040/s132/config/sdk_config.h`

### MATLAB Receiver

- [BLE discovery](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/checkAvailableBLEDevices.m): `MatlabReceiveCode/checkAvailableBLEDevices.m`
- [BLE connection](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/ble_connect.m): `MatlabReceiveCode/ble_connect.m`
- [Receiver runner](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/connect_V5.m): `MatlabReceiveCode/connect_V5.m`
- [Data decode](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/text_file_decode.m): `MatlabReceiveCode/text_file_decode.m`
- [Data display](https://github.com/mdrafiislam/ble_nrf52832/blob/main/MatlabReceiveCode/display_data.m): `MatlabReceiveCode/display_data.m`

### DFU Packaging

- [Application image](https://github.com/mdrafiislam/ble_nrf52832/blob/main/pca10040/s132/ses/ble_app_spis_pca10040_s132.emProject): `pca10040/s132/ses/ble_app_spis_pca10040_s132.emProject`
- [SoftDevice image](https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/SD_hex/s132_nrf52_7.2.0_softdevice.hex): `Merge_and_zip/SD_hex/s132_nrf52_7.2.0_softdevice.hex`
- [Bootloader image](https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/BL_hex/secure_bootloader_ble_s132_pca10040.hex): `Merge_and_zip/BL_hex/secure_bootloader_ble_s132_pca10040.hex`
- [DFU image generator](https://github.com/mdrafiislam/ble_nrf52832/blob/main/Merge_and_zip/ble_spis_merge_zip_Generator.bat): `Merge_and_zip/ble_spis_merge_zip_Generator.bat`
- [DFU package](https://github.com/mdrafiislam/ble_nrf52832/tree/main/Merge_and_zip): `Merge_and_zip`

### Other components

- **BLE peer**
- **SPI master**
- **MATLAB user**
- **nrfutil**

## Connections

- BLE peer → Firmware app: sends BLE data (evidence: `README.md`)
- Firmware app → BLE commands: initializes commands (evidence: `main.c`)
- Firmware app → SPI slave bridge: queues bridge data (evidence: `main.c`)
- SPI master → SPI slave bridge: exchanges SPI data (evidence: `README.md`)
- Firmware app → SDK configuration: uses settings (evidence: `main.c`)
- MATLAB user → BLE discovery: runs discovery (evidence: `README.md`)
- BLE discovery → BLE connection: provides device address (evidence: `README.md`)
- MATLAB user → Receiver runner: runs receiver (evidence: `README.md`)
- Receiver runner → BLE connection: uses connection
- BLE peer → BLE connection: connects over BLE
- Receiver runner → Data decode: decodes received data
- Data decode → Data display: feeds display
- Application image → DFU image generator: merges image (evidence: `README.md`)
- SoftDevice image → DFU image generator: merges image (evidence: `README.md`)
- Bootloader image → DFU image generator: merges image (evidence: `README.md`)
- DFU image generator → nrfutil: uses packaging tool (evidence: `README.md`)
- DFU image generator → DFU package: creates package (evidence: `README.md`)
