Ryan Malloy ab699bbca3 Add HFP (Hands-Free Profile) support
Implement HFP client (Hands-Free Unit role) for the ESP32 test harness:

Firmware:
- bt_hfp.c/h: Full HFP client with call control, audio, volume, DTMF,
  voice recognition
- Enable HFP in sdkconfig.defaults with Wide Band Speech support
- Add HFP commands/events to protocol.h and cmd_dispatcher.c

Python MCP tools:
- 15 new tools: enable, connect, audio_connect, answer, reject, dial,
  send_dtmf, volume, voice_recognition_start/stop, query_calls, status
- Full protocol constants in protocol.py

Tested: HFP enable returns role='hands_free_unit', ready for AG pairing
2026-02-03 14:34:13 -07:00

123 lines
4.3 KiB
C

#pragma once
#include "driver/uart.h"
/* UART configuration */
#define PROTO_UART_NUM UART_NUM_0
#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"
/* SPP commands */
#define CMD_SPP_SEND "spp_send"
#define CMD_SPP_DISCONNECT "spp_disconnect"
#define CMD_SPP_STATUS "spp_status"
/* HID commands */
#define CMD_HID_ENABLE "hid_enable"
#define CMD_HID_DISABLE "hid_disable"
#define CMD_HID_CONNECT "hid_connect"
#define CMD_HID_DISCONNECT "hid_disconnect"
#define CMD_HID_SEND_KEYBOARD "hid_send_keyboard"
#define CMD_HID_SEND_MOUSE "hid_send_mouse"
#define CMD_HID_STATUS "hid_status"
/* HFP (Hands-Free Profile) commands */
#define CMD_HFP_ENABLE "hfp_enable"
#define CMD_HFP_DISABLE "hfp_disable"
#define CMD_HFP_CONNECT "hfp_connect"
#define CMD_HFP_DISCONNECT "hfp_disconnect"
#define CMD_HFP_AUDIO_CONNECT "hfp_audio_connect"
#define CMD_HFP_AUDIO_DISCONNECT "hfp_audio_disconnect"
#define CMD_HFP_ANSWER "hfp_answer"
#define CMD_HFP_REJECT "hfp_reject"
#define CMD_HFP_DIAL "hfp_dial"
#define CMD_HFP_SEND_DTMF "hfp_send_dtmf"
#define CMD_HFP_VOLUME "hfp_volume"
#define CMD_HFP_VOICE_RECOGNITION_START "hfp_voice_recognition_start"
#define CMD_HFP_VOICE_RECOGNITION_STOP "hfp_voice_recognition_stop"
#define CMD_HFP_QUERY_CALLS "hfp_query_calls"
#define CMD_HFP_STATUS "hfp_status"
/* 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"
/* SPP events */
#define EVT_SPP_DATA "spp_data"
#define EVT_SPP_CONNECT "spp_connect"
#define EVT_SPP_DISCONNECT "spp_disconnect"
/* HID events */
#define EVT_HID_CONNECT "hid_connect"
#define EVT_HID_DISCONNECT "hid_disconnect"
#define EVT_HID_DATA "hid_data"
/* HFP events */
#define EVT_HFP_CONNECT "hfp_connect"
#define EVT_HFP_DISCONNECT "hfp_disconnect"
#define EVT_HFP_AUDIO_CONNECT "hfp_audio_connect"
#define EVT_HFP_AUDIO_DISCONNECT "hfp_audio_disconnect"
#define EVT_HFP_RING "hfp_ring"
#define EVT_HFP_CALL_STATUS "hfp_call_status"
#define EVT_HFP_CALL_SETUP "hfp_call_setup"
#define EVT_HFP_CLIP "hfp_clip"
#define EVT_HFP_VOLUME "hfp_volume"
#define EVT_HFP_VOLUME_CHANGE "hfp_volume_change"
#define EVT_HFP_CALL_LIST "hfp_call_list"
#define EVT_HFP_VOICE_RECOGNITION "hfp_voice_recognition"
/* 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"