split between to device to have bluetooth or usb otg function.
This commit is contained in:
parent
64dff2dc05
commit
8b5b549663
120
README.md
120
README.md
|
|
@ -1,6 +1,19 @@
|
|||
# ESP32-S3 Bluetooth SIP Client
|
||||
# ESP32 SIP Client mit Headset-Unterstützung
|
||||
|
||||
Ein SIP-Telefon basierend auf ESP32-S3 mit Bluetooth- und USB-Headset-Unterstützung. Entwickelt für Thin-Client-Umgebungen ohne nativen CTI-Support.
|
||||
Ein SIP-Telefon basierend auf ESP32 mit Headset-Unterstützung. Entwickelt für Thin-Client-Umgebungen ohne nativen CTI-Support.
|
||||
|
||||
## Zwei Hardware-Varianten
|
||||
|
||||
Aufgrund der Hardware-Unterschiede zwischen ESP32-Chips gibt es zwei Versionen:
|
||||
|
||||
| Variante | Chip | Headset-Typ | USB OTG | Bluetooth Classic |
|
||||
|----------|------|-------------|---------|-------------------|
|
||||
| **USB-Version** | ESP32-S3 | USB Headsets | Ja | Nein |
|
||||
| **Bluetooth-Version** | ESP32 (WROOM) | BT Headsets | Nein | Ja (HFP) |
|
||||
|
||||
**Wichtig:**
|
||||
- ESP32-S3 hat **kein** Bluetooth Classic (nur BLE) → nur USB-Headsets
|
||||
- ESP32 WROOM hat **kein** USB OTG → nur Bluetooth-Headsets
|
||||
|
||||
## Features
|
||||
|
||||
|
|
@ -10,18 +23,17 @@ Ein SIP-Telefon basierend auf ESP32-S3 mit Bluetooth- und USB-Headset-Unterstüt
|
|||
- DHCP oder statische IP-Konfiguration
|
||||
- Automatischer Fallback zu Hotspot bei Verbindungsproblemen
|
||||
|
||||
- **Bluetooth Headsets**
|
||||
- **USB Headsets** (nur ESP32-S3)
|
||||
- USB Audio Class Unterstützung
|
||||
- USB-C direkter Anschluss oder USB-A mit Adapter
|
||||
- Automatische Erkennung
|
||||
|
||||
- **Bluetooth Headsets** (nur ESP32 WROOM)
|
||||
- HFP (Hands-Free Profile) Unterstützung
|
||||
- Mehrere Geräte pairen (>5 möglich)
|
||||
- Auto-Connect für bekannte Geräte
|
||||
- Headset-Tasten: Annehmen, Auflegen, Lautstärke
|
||||
|
||||
- **USB Headsets**
|
||||
- USB Audio Class Unterstützung
|
||||
- USB-C direkter Anschluss oder USB-A mit Adapter
|
||||
- **USB hat immer Priorität über Bluetooth**
|
||||
- Automatische Erkennung
|
||||
|
||||
- **SIP/VoIP**
|
||||
- SIP-Registrierung an TK-Anlage
|
||||
- Eingehende und ausgehende Anrufe
|
||||
|
|
@ -32,19 +44,31 @@ Ein SIP-Telefon basierend auf ESP32-S3 mit Bluetooth- und USB-Headset-Unterstüt
|
|||
- Status-Übersicht
|
||||
- WLAN-Konfiguration mit Scan
|
||||
- SIP-Einstellungen
|
||||
- Bluetooth-Geräte-Management
|
||||
- Bluetooth-Geräte-Management (nur WROOM)
|
||||
- System-Einstellungen (Neustart, Werksreset)
|
||||
|
||||
## Hardware
|
||||
|
||||
### Empfohlenes Board
|
||||
- **ESP32-S3-DevKitC-1** (oder ähnlich mit USB OTG)
|
||||
### USB-Version (ESP32-S3)
|
||||
|
||||
**Board:**
|
||||
- ESP32-S3-DevKitC-1 (oder ähnlich mit USB OTG)
|
||||
- Mindestens 4MB Flash
|
||||
- Optional: PSRAM für bessere Audio-Pufferung
|
||||
|
||||
### Anschlüsse
|
||||
- **USB-C (USB OTG)**: Für USB-Headsets
|
||||
- **WLAN**: 2.4GHz WiFi
|
||||
**Anschlüsse:**
|
||||
- USB-C (USB OTG): Für USB-Headsets
|
||||
- WLAN: 2.4GHz WiFi
|
||||
|
||||
### Bluetooth-Version (ESP32 WROOM)
|
||||
|
||||
**Board:**
|
||||
- ESP32-DevKitC oder ESP32-WROOM-32
|
||||
- Mindestens 4MB Flash
|
||||
|
||||
**Anschlüsse:**
|
||||
- WLAN: 2.4GHz WiFi
|
||||
- Bluetooth: Integriert (Classic + BLE)
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
@ -63,9 +87,9 @@ mkdir -p ~/esp
|
|||
cd ~/esp
|
||||
git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git
|
||||
|
||||
# Tools installieren
|
||||
# Tools installieren (für beide Targets)
|
||||
cd ~/esp/esp-idf
|
||||
./install.sh esp32s3
|
||||
./install.sh esp32,esp32s3
|
||||
|
||||
# Umgebung aktivieren (in jeder neuen Shell)
|
||||
. ~/esp/esp-idf/export.sh
|
||||
|
|
@ -80,7 +104,7 @@ sudo pacman -S --needed gcc git make flex bison gperf python cmake ninja ccache
|
|||
# Rest wie oben
|
||||
mkdir -p ~/esp && cd ~/esp
|
||||
git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git
|
||||
cd esp-idf && ./install.sh esp32s3
|
||||
cd esp-idf && ./install.sh esp32,esp32s3
|
||||
. ~/esp/esp-idf/export.sh
|
||||
```
|
||||
|
||||
|
|
@ -102,7 +126,7 @@ brew install cmake ninja dfu-util python3
|
|||
# ESP-IDF klonen und installieren
|
||||
mkdir -p ~/esp && cd ~/esp
|
||||
git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git
|
||||
cd esp-idf && ./install.sh esp32s3
|
||||
cd esp-idf && ./install.sh esp32,esp32s3
|
||||
. ~/esp/esp-idf/export.sh
|
||||
```
|
||||
|
||||
|
|
@ -115,22 +139,34 @@ alias get_idf='. ~/esp/esp-idf/export.sh'
|
|||
|
||||
Dann mit `get_idf` aktivieren.
|
||||
|
||||
### Build & Flash
|
||||
### Build für ESP32-S3 (USB-Version)
|
||||
|
||||
```bash
|
||||
# ESP-IDF Umgebung aktivieren (falls nicht schon aktiv)
|
||||
# ESP-IDF Umgebung aktivieren
|
||||
. ~/esp/esp-idf/export.sh
|
||||
|
||||
# In Projektverzeichnis wechseln
|
||||
cd /pfad/zu/bluetooth-sip-client
|
||||
|
||||
# Target setzen
|
||||
# Target setzen und bauen
|
||||
idf.py set-target esp32s3
|
||||
idf.py build flash monitor
|
||||
```
|
||||
|
||||
# Optional: Konfiguration anpassen
|
||||
idf.py menuconfig
|
||||
### Build für ESP32 WROOM (Bluetooth-Version)
|
||||
|
||||
# Bauen und Flashen
|
||||
```bash
|
||||
# ESP-IDF Umgebung aktivieren
|
||||
. ~/esp/esp-idf/export.sh
|
||||
|
||||
# In Projektverzeichnis wechseln
|
||||
cd /pfad/zu/bluetooth-sip-client
|
||||
|
||||
# sdkconfig.defaults für ESP32 kopieren
|
||||
cp sdkconfig.defaults.esp32 sdkconfig.defaults
|
||||
|
||||
# Target setzen und bauen
|
||||
idf.py set-target esp32
|
||||
idf.py build flash monitor
|
||||
```
|
||||
|
||||
|
|
@ -143,9 +179,8 @@ idf.py build flash monitor
|
|||
Bei Problemen oder nach Änderungen an Dependencies:
|
||||
|
||||
```bash
|
||||
rm -rf build managed_components dependencies.lock
|
||||
idf.py set-target esp32s3
|
||||
idf.py build
|
||||
rm -rf build managed_components dependencies.lock sdkconfig
|
||||
# Dann nochmal set-target und build
|
||||
```
|
||||
|
||||
## Ersteinrichtung
|
||||
|
|
@ -166,9 +201,9 @@ idf.py build
|
|||
5. **SIP konfigurieren**
|
||||
- Tab "SIP" → Server, Benutzername, Passwort eingeben
|
||||
|
||||
6. **Bluetooth Headset verbinden**
|
||||
- Headset in Pairing-Modus setzen
|
||||
- Tab "Bluetooth" → Gerät pairen
|
||||
6. **Headset verbinden**
|
||||
- USB-Version: USB-Headset einstecken
|
||||
- Bluetooth-Version: Headset in Pairing-Modus → Tab "Bluetooth" → Gerät pairen
|
||||
|
||||
## API Endpoints
|
||||
|
||||
|
|
@ -191,7 +226,8 @@ idf.py build
|
|||
```
|
||||
bluetooth-sip-client/
|
||||
├── CMakeLists.txt
|
||||
├── sdkconfig.defaults
|
||||
├── sdkconfig.defaults # ESP32-S3 (USB)
|
||||
├── sdkconfig.defaults.esp32 # ESP32 WROOM (Bluetooth)
|
||||
├── partitions.csv
|
||||
└── main/
|
||||
├── main.c # Hauptprogramm
|
||||
|
|
@ -210,17 +246,17 @@ bluetooth-sip-client/
|
|||
│ ├── index.html
|
||||
│ ├── style.css
|
||||
│ └── app.js
|
||||
├── bluetooth/
|
||||
├── bluetooth/ # Nur aktiv auf ESP32 WROOM
|
||||
│ ├── bt_manager.h # BT Manager Header
|
||||
│ ├── bt_manager.c # BT Geräteverwaltung
|
||||
│ ├── bt_hfp.h # HFP Header
|
||||
│ └── bt_hfp.c # HFP Audio Gateway
|
||||
├── usb_audio/
|
||||
├── usb_audio/ # Nur aktiv auf ESP32-S3
|
||||
│ ├── usb_audio_host.h # USB Audio Header
|
||||
│ └── usb_audio_host.c # USB Audio Class Host
|
||||
├── audio/
|
||||
│ ├── audio_router.h # Audio Router Header
|
||||
│ └── audio_router.c # Audio Routing & Priorität
|
||||
│ └── audio_router.c # Audio Routing
|
||||
└── sip/
|
||||
├── sip_client.h # SIP Client Header
|
||||
├── sip_client.c # SIP UA Implementation
|
||||
|
|
@ -230,8 +266,10 @@ bluetooth-sip-client/
|
|||
|
||||
## Einschränkungen
|
||||
|
||||
- **Bluetooth**: Maximal 3-4 gleichzeitig aktive Verbindungen (ESP32 Limitation), aber mehr Geräte können gepaart werden
|
||||
- **USB Audio**: Grundlegende UAC1 Unterstützung, nicht alle Headsets getestet
|
||||
- **ESP32-S3**: Kein Bluetooth Classic - nur USB-Headsets möglich
|
||||
- **ESP32 WROOM**: Kein USB OTG - nur Bluetooth-Headsets möglich
|
||||
- **Bluetooth**: Maximal 3-4 gleichzeitig aktive Verbindungen
|
||||
- **USB Audio**: Grundlegende UAC1 Unterstützung
|
||||
- **Codecs**: Aktuell nur G.711 (PCMU/PCMA)
|
||||
- **SRTP**: Nicht unterstützt (nur unverschlüsseltes RTP)
|
||||
|
||||
|
|
@ -241,13 +279,17 @@ bluetooth-sip-client/
|
|||
- Gerät neu starten
|
||||
- Hotspot sollte nach 30 Sekunden automatisch starten
|
||||
|
||||
### Bluetooth Headset verbindet nicht
|
||||
### Bluetooth Headset verbindet nicht (nur WROOM)
|
||||
- Headset zurücksetzen und erneut pairen
|
||||
- Andere Bluetooth-Verbindungen am Headset trennen
|
||||
|
||||
### USB Headset wird nicht erkannt (nur S3)
|
||||
- USB-Kabel prüfen (muss Datenkabel sein, nicht nur Ladekabel)
|
||||
- Anderes USB-Headset testen
|
||||
|
||||
### Kein Audio bei Anruf
|
||||
- USB-Headset hat Priorität - bei Verwendung von BT das USB-Kabel entfernen
|
||||
- Audio-Routing prüfen im Status-Tab
|
||||
- Headset-Verbindung prüfen
|
||||
|
||||
## Lizenz
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,24 @@
|
|||
* Headset ist das HF (Hands-Free) Device
|
||||
*
|
||||
* Angepasst für ESP-IDF 5.x
|
||||
* Nur auf ESP32 (nicht S3/C3) verfügbar
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "bt_hfp.h"
|
||||
#include "bt_manager.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char* TAG = "BT_HFP";
|
||||
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
#include "esp_hf_ag_api.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
|
||||
static const char* TAG = "BT_HFP";
|
||||
|
||||
// Audio Buffer
|
||||
#define AUDIO_RINGBUF_SIZE (8 * 1024)
|
||||
static RingbufHandle_t s_audio_out_ringbuf = NULL;
|
||||
|
|
@ -343,3 +348,57 @@ bool bt_hfp_is_audio_connected(void)
|
|||
{
|
||||
return s_audio_connected;
|
||||
}
|
||||
|
||||
#else // CONFIG_BT_ENABLED not set - Stub-Implementierungen
|
||||
|
||||
esp_err_t bt_hfp_init(void)
|
||||
{
|
||||
ESP_LOGW(TAG, "HFP nicht verfügbar (Bluetooth Classic deaktiviert)");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_hfp_deinit(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_hfp_connect(const uint8_t* address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_hfp_disconnect(const uint8_t* address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_hfp_audio_connect(void)
|
||||
{
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_hfp_audio_disconnect(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_hfp_send_audio(const uint8_t* data, size_t len)
|
||||
{
|
||||
(void)data;
|
||||
(void)len;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
bool bt_hfp_is_connected(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bt_hfp_is_audio_connected(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_ENABLED
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@
|
|||
* Bluetooth Manager - Verwaltet Bluetooth Classic Headsets
|
||||
*
|
||||
* Unterstützt HFP (Hands-Free Profile) für Headsets
|
||||
* Nur auf ESP32 (nicht S3/C3) verfügbar
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "bt_manager.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char* TAG = "BT_MGR";
|
||||
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
#include "bt_hfp.h"
|
||||
#include "config/config_manager.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_bt.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_bt_device.h"
|
||||
|
|
@ -18,8 +25,6 @@
|
|||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
static const char* TAG = "BT_MGR";
|
||||
|
||||
// State
|
||||
static bool s_initialized = false;
|
||||
static bool s_discovering = false;
|
||||
|
|
@ -144,7 +149,6 @@ esp_err_t bt_manager_init(void)
|
|||
|
||||
// Bluetooth Controller konfigurieren
|
||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
// Mode wird bei esp_bt_controller_enable() gesetzt
|
||||
|
||||
esp_err_t ret = esp_bt_controller_init(&bt_cfg);
|
||||
if (ret != ESP_OK) {
|
||||
|
|
@ -152,7 +156,7 @@ esp_err_t bt_manager_init(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
||||
ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "BT Controller enable failed: %s", esp_err_to_name(ret));
|
||||
return ret;
|
||||
|
|
@ -388,29 +392,6 @@ void bt_manager_register_audio_data_callback(bt_audio_data_callback_t callback)
|
|||
s_audio_data_callback = callback;
|
||||
}
|
||||
|
||||
// Utility Functions
|
||||
void bt_addr_to_str(const esp_bd_addr_t addr, char* str, size_t len)
|
||||
{
|
||||
snprintf(str, len, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
|
||||
}
|
||||
|
||||
esp_err_t bt_str_to_addr(const char* str, esp_bd_addr_t addr)
|
||||
{
|
||||
unsigned int values[6];
|
||||
if (sscanf(str, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
&values[0], &values[1], &values[2],
|
||||
&values[3], &values[4], &values[5]) != 6) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
addr[i] = (uint8_t)values[i];
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// Internal: Wird von bt_hfp aufgerufen
|
||||
void bt_manager_notify_connected(const esp_bd_addr_t address)
|
||||
{
|
||||
|
|
@ -453,3 +434,122 @@ void bt_manager_notify_audio_data(const uint8_t* data, size_t len)
|
|||
s_audio_data_callback(data, len);
|
||||
}
|
||||
}
|
||||
|
||||
bool bt_manager_is_available(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // CONFIG_BT_ENABLED not set - Stub-Implementierung für ESP32-S3
|
||||
|
||||
// Stub-Implementierungen wenn Bluetooth nicht verfügbar ist
|
||||
|
||||
esp_err_t bt_manager_init(void)
|
||||
{
|
||||
ESP_LOGW(TAG, "Bluetooth Classic nicht verfügbar auf diesem Chip");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_deinit(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_start_discovery(void)
|
||||
{
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_stop_discovery(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_pair(const esp_bd_addr_t address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_unpair(const esp_bd_addr_t address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_connect(const esp_bd_addr_t address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_disconnect(const esp_bd_addr_t address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_disconnect_all(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool bt_manager_is_connected(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_get_connected_device(esp_bd_addr_t address)
|
||||
{
|
||||
(void)address;
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_set_discoverable(bool discoverable)
|
||||
{
|
||||
(void)discoverable;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t bt_manager_send_audio(const uint8_t* data, size_t len)
|
||||
{
|
||||
(void)data;
|
||||
(void)len;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void bt_manager_register_device_callback(bt_device_callback_t callback) { (void)callback; }
|
||||
void bt_manager_register_discovery_callback(bt_discovery_callback_t callback) { (void)callback; }
|
||||
void bt_manager_register_audio_callback(bt_audio_callback_t callback) { (void)callback; }
|
||||
void bt_manager_register_button_callback(bt_button_callback_t callback) { (void)callback; }
|
||||
void bt_manager_register_audio_data_callback(bt_audio_data_callback_t callback) { (void)callback; }
|
||||
|
||||
bool bt_manager_is_available(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // CONFIG_BT_ENABLED
|
||||
|
||||
// Utility Functions - immer verfügbar
|
||||
void bt_addr_to_str(const esp_bd_addr_t addr, char* str, size_t len)
|
||||
{
|
||||
snprintf(str, len, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
|
||||
}
|
||||
|
||||
esp_err_t bt_str_to_addr(const char* str, esp_bd_addr_t addr)
|
||||
{
|
||||
unsigned int values[6];
|
||||
if (sscanf(str, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
&values[0], &values[1], &values[2],
|
||||
&values[3], &values[4], &values[5]) != 6) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
addr[i] = (uint8_t)values[i];
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -28,6 +28,14 @@ typedef enum {
|
|||
BT_AUDIO_STATE_STREAMING
|
||||
} bt_audio_state_t;
|
||||
|
||||
// Bluetooth Address Type (für Plattform-Unabhängigkeit)
|
||||
#if CONFIG_BT_ENABLED
|
||||
#include "esp_bt_defs.h"
|
||||
#else
|
||||
typedef uint8_t esp_bd_addr_t[6];
|
||||
#define ESP_BD_ADDR_LEN 6
|
||||
#endif
|
||||
|
||||
// Entdecktes Bluetooth-Gerät
|
||||
typedef struct {
|
||||
esp_bd_addr_t address;
|
||||
|
|
@ -140,6 +148,11 @@ void bt_addr_to_str(const esp_bd_addr_t addr, char* str, size_t len);
|
|||
*/
|
||||
esp_err_t bt_str_to_addr(const char* str, esp_bd_addr_t addr);
|
||||
|
||||
/**
|
||||
* Prüft ob Bluetooth verfügbar ist (Hardware-Support)
|
||||
*/
|
||||
bool bt_manager_is_available(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,18 +2,23 @@
|
|||
* USB Audio Host - USB Headset Unterstützung
|
||||
*
|
||||
* Verwendet ESP32-S3 USB OTG im Host-Modus für USB Audio Class Geräte
|
||||
* Nur auf ESP32-S3 verfügbar (USB OTG Hardware)
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "usb_audio_host.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char* TAG = "USB_AUDIO";
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include "usb/usb_host.h"
|
||||
|
||||
static const char* TAG = "USB_AUDIO";
|
||||
|
||||
// USB Audio Class Definitionen
|
||||
#define USB_CLASS_AUDIO 0x01
|
||||
#define USB_SUBCLASS_AUDIOCONTROL 0x01
|
||||
|
|
@ -354,3 +359,77 @@ void usb_audio_host_register_button_callback(usb_button_callback_t callback)
|
|||
{
|
||||
s_button_callback = callback;
|
||||
}
|
||||
|
||||
bool usb_audio_host_is_available(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#else // Nicht ESP32-S3 - Stub-Implementierungen
|
||||
|
||||
esp_err_t usb_audio_host_init(void)
|
||||
{
|
||||
ESP_LOGW(TAG, "USB Audio Host nicht verfügbar (nur ESP32-S3)");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_deinit(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
usb_audio_state_t usb_audio_host_get_state(void)
|
||||
{
|
||||
return USB_AUDIO_STATE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
bool usb_audio_host_is_connected(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_get_info(usb_audio_info_t* info)
|
||||
{
|
||||
(void)info;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_start_stream(void)
|
||||
{
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_stop_stream(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_send(const uint8_t* data, size_t len)
|
||||
{
|
||||
(void)data;
|
||||
(void)len;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_set_volume(uint8_t volume)
|
||||
{
|
||||
(void)volume;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
esp_err_t usb_audio_host_set_mute(bool mute)
|
||||
{
|
||||
(void)mute;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void usb_audio_host_register_state_callback(usb_audio_state_callback_t callback) { (void)callback; }
|
||||
void usb_audio_host_register_data_callback(usb_audio_data_callback_t callback) { (void)callback; }
|
||||
void usb_audio_host_register_button_callback(usb_button_callback_t callback) { (void)callback; }
|
||||
|
||||
bool usb_audio_host_is_available(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32S3
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -103,6 +104,11 @@ void usb_audio_host_register_state_callback(usb_audio_state_callback_t callback)
|
|||
void usb_audio_host_register_data_callback(usb_audio_data_callback_t callback);
|
||||
void usb_audio_host_register_button_callback(usb_button_callback_t callback);
|
||||
|
||||
/**
|
||||
* Prüft ob USB Audio Host verfügbar ist (Hardware-Support)
|
||||
*/
|
||||
bool usb_audio_host_is_available(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# ESP32-S3 Bluetooth SIP Client - Default Configuration
|
||||
# ESP32-S3 Bluetooth SIP Client - USB Headset Version
|
||||
# Target: ESP32-S3 (nur USB Headsets, kein Bluetooth Classic)
|
||||
|
||||
# Target: ESP32-S3
|
||||
CONFIG_IDF_TARGET="esp32s3"
|
||||
|
||||
# Flash Größe
|
||||
|
|
@ -13,22 +13,10 @@ CONFIG_ESP32S3_SPIRAM_SUPPORT=y
|
|||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
|
||||
# Bluetooth aktivieren
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_BLUEDROID_ENABLED=y
|
||||
CONFIG_BT_CLASSIC_ENABLED=y
|
||||
CONFIG_BT_A2DP_ENABLE=y
|
||||
CONFIG_BT_HFP_ENABLE=y
|
||||
CONFIG_BT_HFP_AG_ENABLE=y
|
||||
CONFIG_BT_HFP_CLIENT_ENABLE=y
|
||||
CONFIG_BT_SSP_ENABLED=y
|
||||
CONFIG_BT_BLE_ENABLED=y
|
||||
# Bluetooth deaktiviert (ESP32-S3 hat kein Bluetooth Classic)
|
||||
CONFIG_BT_ENABLED=n
|
||||
|
||||
# Bluetooth Controller
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=y
|
||||
CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y
|
||||
|
||||
# USB Host
|
||||
# USB Host für USB Headsets
|
||||
CONFIG_USB_OTG_SUPPORTED=y
|
||||
CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE=1024
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
# ESP32 SIP Client - Bluetooth Headset Version
|
||||
# Target: ESP32 WROOM (Bluetooth Classic, kein USB Host)
|
||||
|
||||
CONFIG_IDF_TARGET="esp32"
|
||||
|
||||
# Flash Größe
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
|
||||
|
||||
# PSRAM (optional, falls auf Board vorhanden)
|
||||
# CONFIG_ESP32_SPIRAM_SUPPORT=y
|
||||
|
||||
# Bluetooth Classic aktiviert
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_BLUEDROID_ENABLED=y
|
||||
CONFIG_BT_CLASSIC_ENABLED=y
|
||||
CONFIG_BT_A2DP_ENABLE=n
|
||||
CONFIG_BT_HFP_ENABLE=y
|
||||
CONFIG_BT_HFP_AG_ENABLE=y
|
||||
CONFIG_BT_HFP_CLIENT_ENABLE=n
|
||||
CONFIG_BT_SSP_ENABLED=y
|
||||
CONFIG_BT_BLE_ENABLED=n
|
||||
|
||||
# Bluetooth Controller (ESP32 BTDM)
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
|
||||
CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y
|
||||
|
||||
# SCO Data Path für HFP Audio
|
||||
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y
|
||||
|
||||
# Bluetooth Memory
|
||||
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=n
|
||||
CONFIG_BT_RESERVE_DRAM=0xdb5c
|
||||
|
||||
# WiFi
|
||||
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y
|
||||
CONFIG_ESP_WIFI_NVS_ENABLED=y
|
||||
|
||||
# LWIP
|
||||
CONFIG_LWIP_IPV4=y
|
||||
CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
|
||||
|
||||
# HTTP Server
|
||||
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
|
||||
CONFIG_HTTPD_MAX_URI_LEN=512
|
||||
|
||||
# NVS
|
||||
CONFIG_NVS_ENCRYPTION=n
|
||||
|
||||
# Logging
|
||||
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||
CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y
|
||||
|
||||
# FreeRTOS
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3072
|
||||
|
||||
# Compiler Optimierung
|
||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||
Loading…
Reference in New Issue