# Bluetooth LE Audio (Auracast) Transmitter **Phase:** Proof of Concept (PoC) — Simulation --- ## Overview This is a **Proof of Concept (PoC)** simulation of a **Bluetooth Low Energy (LE) Audio Transmitter** supporting the **Auracast** standard. The system runs on an **ESP32** acting as both a BLE GATT server and passive BLE scanner, with a **Node.js** backend bridging serial communication to a browser-based monitoring dashboard. No physical NXH3675 hardware is required in this PoC phase. --- ## System Architecture ```text ESP32 (BLE Server + Scanner) │ UART Serial (115200 baud, COM8) ▼ Node.js Backend (Express + WebSocket + SerialPort) │ WebSocket (ws://localhost:8080) ▼ Browser Dashboard (index.html) ``` **ESP32** (`src/main/main.ino`): - Acts as a BLE GATT server advertising service UUID `4fafc201-1fb5-459e-8fcc-c5c9c331914b` - Scans for nearby BLE devices and collects RSSI, TX power, and name - Emits newline-delimited JSON events over Serial on connect/disconnect - Accepts `DISCONNECT ` commands via Serial input to force-disconnect clients **Node.js Backend** (`src/web_side/read_serial.js`): - Express server on port 8080 serves the frontend - WebSocket server relays ESP32 serial data to connected browsers in real time - Translates browser commands (`OPEN_SERIAL`, `CLOSE_SERIAL`, `DISCONNECT`) to serial writes **Browser Dashboard** (`src/web_side/index.html`): - Displays connected BLE device cards (MAC, connection ID, interval, latency, timeout) - Shows a live connection log panel - Allows force-disconnect of individual clients --- ## Requirements - **ESP32** board (tested with ESP32-S3) - **ESP-IDF v5.5.1** (or Arduino IDE with ESP32 BLE libraries) - **Node.js v18+** - **Python 3** with `pyserial` and `numpy` (for LC3 codec simulation only) - Serial-to-USB cable connecting ESP32 to PC --- ## Setup & Running ### 1. Flash the ESP32 Using ESP-IDF (VS Code extension configured for `c:\Dev\esp\v5.5.1\esp-idf`): ```bash idf.py set-target esp32s3 idf.py -p COM8 flash monitor ``` Or open `src/main/main.ino` in Arduino IDE with the ESP32 BLE libraries installed. ### 2. Start the Node.js Backend ```bash npm install npm start ``` The web server starts at `http://localhost:8080`. ### 3. Open the Dashboard Open `http://localhost:8080` in your browser (or open `src/web_side/index.html` directly). Click **Open Port** to connect to the ESP32 via serial. BLE device cards will appear when clients connect to the ESP32. --- ## Serial Port Configuration The serial port is hardcoded as **`COM8`** in two files — update both when using a different port: | File | Location | | --------------------------------- | --------------------------------- | | `src/web_side/read_serial.js` | `path: "COM8"` (line 29) | | `src/LC3_Codec_Python/testlc3.py` | `serial.Serial("COM8", 115200)` | The VS Code monitor port is set in `.vscode/settings.json`. --- ## LC3 Codec Simulation (Optional) Sends dummy LC3-encoded audio frames to the ESP32 over serial: ```bash cd src/LC3_Codec_Python pip install pyserial numpy python testlc3.py ``` Requires `audio.wav` (mono, 16-bit PCM) in the same directory. --- ## JSON Event Protocol ESP32 emits JSON over serial; Node.js forwards it to the browser via WebSocket. | `Status` value | Description | | --------------------- | -------------------------------------------------------- | | `NEW_CONNECT` | BLE client connected — includes `Devices` array | | `DEVICE_DISCONNECTED` | A client disconnected — includes updated `Devices` array | | `NO_CONNECTED` | All clients disconnected | Each device entry contains: `connectedID`, `mac`, `connInterval`, `latency`, `timeout`. --- ## Project Structure ``` / ├── src/ │ ├── main/main.ino # ESP32 BLE firmware (Arduino) │ ├── main.cpp # ESP32 entry point (ESP-IDF / PlatformIO) │ ├── web_side/ │ │ ├── read_serial.js # Node.js serial-to-WebSocket bridge │ │ └── index.html # Browser dashboard │ └── LC3_Codec_Python/ │ └── testlc3.py # Dummy LC3 audio frame sender ├── test/ │ ├── NimBLE_Beacon/ # Non-connectable beacon example │ ├── NimBLE_Connection/ # BLE connection + LED example │ ├── NimBLE_Conn_Disconn/ # Connect/disconnect lifecycle │ ├── NimBLE_GATT_Server/ # GATT server with heart rate mock │ └── get_RSSI_Device_Name/ # Arduino scan + RSSI printer ├── docs/ # Project documentation ├── CMakeLists.txt # ESP-IDF top-level build file ├── platformio.ini # PlatformIO config (target: esp32s3usbotg) └── package.json # Node.js dependencies ``` --- ## Test Examples Each project under `test/` is a standalone ESP-IDF application. Build and flash from within its directory: ```bash cd test/NimBLE_GATT_Server idf.py set-target esp32 idf.py -p flash monitor ``` Use [nRF Connect for Mobile](https://www.nordicsemi.com/Products/Development-tools/nRF-Connect-for-mobile) to interact with the running examples from a phone.