Ryan Malloy 6398a5223a ESP32 Bluetooth test harness MCP server
UART-controlled ESP32 peripheral for automated E2E Bluetooth testing.
Dual-mode (Classic BT + BLE) via Bluedroid on original ESP32.

Firmware (ESP-IDF v5.x, 2511 lines C):
- NDJSON protocol over UART1 (115200 baud)
- System commands: ping, reset, get_info, get_status
- Classic BT: GAP, SPP, all 4 SSP pairing modes
- BLE: GATTS, advertising, GATT service/characteristic management
- 6 device personas: headset, speaker, keyboard, sensor, phone, bare
- Event reporter: thread-safe async event queue to host

Python MCP server (FastMCP, 1626 lines):
- Async serial client with command/response correlation
- Event queue with wait_for pattern matching
- Tools: connection, configure, classic, ble, persona, events
- MCP resources: esp32://status, esp32://events, esp32://personas

Tests: 74 unit tests passing, 5 integration test stubs (skip without hardware)
2026-02-02 15:12:28 -07:00

68 lines
2.2 KiB
C

#pragma once
#include "driver/uart.h"
/* UART configuration */
#define PROTO_UART_NUM UART_NUM_1
#define PROTO_BAUD_RATE 115200
#define PROTO_TX_BUF_SIZE 4096
#define PROTO_RX_BUF_SIZE 4096
#define PROTO_MAX_LINE 2048
/* Message types */
#define MSG_TYPE_CMD "cmd"
#define MSG_TYPE_RESP "resp"
#define MSG_TYPE_EVENT "event"
/* Response status */
#define STATUS_OK "ok"
#define STATUS_ERROR "error"
/* System commands */
#define CMD_PING "ping"
#define CMD_RESET "reset"
#define CMD_GET_INFO "get_info"
#define CMD_GET_STATUS "get_status"
/* Configuration commands */
#define CMD_CONFIGURE "configure"
#define CMD_LOAD_PERSONA "load_persona"
#define CMD_LIST_PERSONAS "list_personas"
#define CMD_CLASSIC_SET_SSP_MODE "classic_set_ssp_mode"
/* Classic BT commands */
#define CMD_CLASSIC_ENABLE "classic_enable"
#define CMD_CLASSIC_DISABLE "classic_disable"
#define CMD_CLASSIC_SET_DISCOVERABLE "classic_set_discoverable"
#define CMD_CLASSIC_PAIR_RESPOND "classic_pair_respond"
/* BLE commands */
#define CMD_BLE_ENABLE "ble_enable"
#define CMD_BLE_DISABLE "ble_disable"
#define CMD_BLE_ADVERTISE "ble_advertise"
#define CMD_BLE_SET_ADV_DATA "ble_set_adv_data"
/* GATT commands */
#define CMD_GATT_ADD_SERVICE "gatt_add_service"
#define CMD_GATT_ADD_CHARACTERISTIC "gatt_add_characteristic"
#define CMD_GATT_SET_VALUE "gatt_set_value"
#define CMD_GATT_NOTIFY "gatt_notify"
#define CMD_GATT_CLEAR "gatt_clear"
/* Events */
#define EVT_BOOT "boot"
#define EVT_PAIR_REQUEST "pair_request"
#define EVT_PAIR_COMPLETE "pair_complete"
#define EVT_CONNECT "connect"
#define EVT_DISCONNECT "disconnect"
#define EVT_GATT_READ "gatt_read"
#define EVT_GATT_WRITE "gatt_write"
#define EVT_GATT_SUBSCRIBE "gatt_subscribe"
/* SSP IO capabilities */
#define IO_CAP_DISPLAY_ONLY "display_only"
#define IO_CAP_DISPLAY_YESNO "display_yesno"
#define IO_CAP_KEYBOARD_ONLY "keyboard_only"
#define IO_CAP_NO_IO "no_io"
#define IO_CAP_KEYBOARD_DISPLAY "keyboard_display"