# ironwolf437/esp32-hid-keyboard architecture

> Architecture diagram of the GitHub repository ironwolf437/esp32-hid-keyboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ironwolf437/esp32-hid-keyboard
- Repository: https://github.com/ironwolf437/esp32-hid-keyboard

## Overview

ESP32 BLE Keyboard is an Arduino library that lets a sketch emulate a Bluetooth HID keyboard. The main workflow is: a sketch starts the service, checks for a connection, then sends text or key actions; the library maintains keyboard or media-key reports and transmits them through BLE HID to a paired host. The README also documents modifiers, multimedia keys, and press/release controls. Internal details are based on partial source excerpts, so uncertain callback and report wiring is omitted.

Main entry points: [`src/BleKeyboard.cpp`](https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp) (Keyboard runtime), [`src/BleKeyboard.h`](https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.h) (Keyboard API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Sketch API"]
  node_keyboard_api["Keyboard API<br/>[BleKeyboard.h]"]
  node_keyboard_runtime["Keyboard runtime<br/>[BleKeyboard.cpp]"]
end

subgraph group_reports["HID Reports"]
  node_key_reports["Key reports<br/>[BleKeyboard.cpp]"]
end

subgraph group_transport["BLE HID"]
  node_hid_service["HID service<br/>[BleKeyboard.cpp]"]
  node_ble_stack["ESP32 BLE stack"]
end

node_sketch(("Arduino sketch"))
node_paired_host(("Paired host"))

node_sketch -->|"calls API"| node_keyboard_api
node_keyboard_api -->|"invokes"| node_keyboard_runtime
node_keyboard_runtime -->|"updates reports"| node_key_reports
node_keyboard_runtime -->|"starts service"| node_hid_service
node_keyboard_runtime -->|"sends reports"| node_hid_service
node_hid_service -->|"uses BLE"| node_ble_stack
node_ble_stack -->|"advertises HID"| node_paired_host

click node_keyboard_api "https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.h"
click node_keyboard_runtime "https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp"
click node_key_reports "https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp"
click node_hid_service "https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp"

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_keyboard_api,node_keyboard_runtime toneBlue
class node_key_reports toneAmber
class node_hid_service,node_ble_stack toneMint
class node_sketch,node_paired_host toneIndigo
```

## Components

### Sketch API

- [Keyboard API](https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.h): `src/BleKeyboard.h`
- [Keyboard runtime](https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp): `src/BleKeyboard.cpp`

### HID Reports

- [Key reports](https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp): `src/BleKeyboard.cpp`

### BLE HID

- [HID service](https://github.com/ironwolf437/esp32-hid-keyboard/blob/main/src/BleKeyboard.cpp): `src/BleKeyboard.cpp`
- **ESP32 BLE stack**

### Other components

- **Arduino sketch**
- **Paired host**

## Connections

- Arduino sketch → Keyboard API: calls API
- Keyboard API → Keyboard runtime: invokes
- Keyboard runtime → Key reports: updates reports
- Keyboard runtime → HID service: starts service
- Keyboard runtime → HID service: sends reports
- HID service → ESP32 BLE stack: uses BLE
- ESP32 BLE stack → Paired host: advertises HID
