Ryan Malloy 61da375a0c Add SPP (Serial Port Profile) support for bidirectional data transfer
Firmware:
- Add spp_connect, spp_disconnect, spp_data events
- Add spp_send, spp_disconnect, spp_status commands
- Track remote address for connected SPP peer
- Report received data as hex + optional text decode

Python MCP:
- esp32_spp_send(data/data_hex) - send text or binary
- esp32_spp_disconnect() - close SPP connection
- esp32_spp_status() - query connection state

Tested: Linux rfcomm connect → ESP32, bidirectional data transfer works
2026-02-03 13:39:17 -07:00

78 lines
2.5 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"
/* 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"
/* 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"