255 lines
7.0 KiB
Markdown
255 lines
7.0 KiB
Markdown
# ESP32-S3 Bluetooth SIP Client
|
|
|
|
Ein SIP-Telefon basierend auf ESP32-S3 mit Bluetooth- und USB-Headset-Unterstützung. Entwickelt für Thin-Client-Umgebungen ohne nativen CTI-Support.
|
|
|
|
## Features
|
|
|
|
- **WiFi-Konfiguration**
|
|
- Automatischer Hotspot-Modus wenn keine WLAN-Daten konfiguriert
|
|
- Web-basierte Konfiguration (SSID: `ESP32-SIP-Phone`, IP: `192.168.4.1`)
|
|
- DHCP oder statische IP-Konfiguration
|
|
- Automatischer Fallback zu Hotspot bei Verbindungsproblemen
|
|
|
|
- **Bluetooth Headsets**
|
|
- 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
|
|
- G.711 µ-law und A-law Codec
|
|
- Digest Authentication
|
|
|
|
- **Weboberfläche**
|
|
- Status-Übersicht
|
|
- WLAN-Konfiguration mit Scan
|
|
- SIP-Einstellungen
|
|
- Bluetooth-Geräte-Management
|
|
- System-Einstellungen (Neustart, Werksreset)
|
|
|
|
## Hardware
|
|
|
|
### Empfohlenes 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
|
|
|
|
## Installation
|
|
|
|
### ESP-IDF 5 installieren
|
|
|
|
#### Linux (Ubuntu/Debian)
|
|
|
|
```bash
|
|
# Abhängigkeiten installieren
|
|
sudo apt-get update
|
|
sudo apt-get install git wget flex bison gperf python3 python3-pip python3-venv \
|
|
cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
|
|
|
|
# ESP-IDF klonen
|
|
mkdir -p ~/esp
|
|
cd ~/esp
|
|
git clone -b v5.2.2 --recursive https://github.com/espressif/esp-idf.git
|
|
|
|
# Tools installieren
|
|
cd ~/esp/esp-idf
|
|
./install.sh esp32s3
|
|
|
|
# Umgebung aktivieren (in jeder neuen Shell)
|
|
. ~/esp/esp-idf/export.sh
|
|
```
|
|
|
|
#### Arch Linux
|
|
|
|
```bash
|
|
# Abhängigkeiten
|
|
sudo pacman -S --needed gcc git make flex bison gperf python cmake ninja ccache dfu-util libusb
|
|
|
|
# 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
|
|
. ~/esp/esp-idf/export.sh
|
|
```
|
|
|
|
#### Windows
|
|
|
|
1. [ESP-IDF Tools Installer](https://dl.espressif.com/dl/esp-idf/) herunterladen
|
|
2. Installer ausführen, ESP-IDF v5.2.x auswählen
|
|
3. "ESP-IDF PowerShell" oder "ESP-IDF CMD" aus Startmenü öffnen
|
|
|
|
#### macOS
|
|
|
|
```bash
|
|
# Xcode Command Line Tools
|
|
xcode-select --install
|
|
|
|
# Homebrew Abhängigkeiten
|
|
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
|
|
. ~/esp/esp-idf/export.sh
|
|
```
|
|
|
|
### Umgebung dauerhaft aktivieren (optional)
|
|
|
|
```bash
|
|
# In ~/.bashrc oder ~/.zshrc einfügen:
|
|
alias get_idf='. ~/esp/esp-idf/export.sh'
|
|
```
|
|
|
|
Dann mit `get_idf` aktivieren.
|
|
|
|
### Build & Flash
|
|
|
|
```bash
|
|
# ESP-IDF Umgebung aktivieren (falls nicht schon aktiv)
|
|
. ~/esp/esp-idf/export.sh
|
|
|
|
# In Projektverzeichnis wechseln
|
|
cd /pfad/zu/bluetooth-sip-client
|
|
|
|
# Target setzen
|
|
idf.py set-target esp32s3
|
|
|
|
# Optional: Konfiguration anpassen
|
|
idf.py menuconfig
|
|
|
|
# Bauen und Flashen
|
|
idf.py build flash monitor
|
|
```
|
|
|
|
**Tastenkürzel im Monitor:**
|
|
- `Ctrl+]` - Monitor beenden
|
|
- `Ctrl+T` dann `Ctrl+R` - Reset
|
|
|
|
### Clean Rebuild
|
|
|
|
Bei Problemen oder nach Änderungen an Dependencies:
|
|
|
|
```bash
|
|
rm -rf build managed_components dependencies.lock
|
|
idf.py set-target esp32s3
|
|
idf.py build
|
|
```
|
|
|
|
## Ersteinrichtung
|
|
|
|
1. **ESP32 mit Strom versorgen**
|
|
- LED sollte nach Boot leuchten
|
|
|
|
2. **Mit Hotspot verbinden**
|
|
- SSID: `ESP32-SIP-Phone`
|
|
- Passwort: `sip-phone-setup`
|
|
|
|
3. **Weboberfläche öffnen**
|
|
- Browser: `http://192.168.4.1`
|
|
|
|
4. **WLAN konfigurieren**
|
|
- Tab "WLAN" → Netzwerk auswählen → Verbinden
|
|
|
|
5. **SIP konfigurieren**
|
|
- Tab "SIP" → Server, Benutzername, Passwort eingeben
|
|
|
|
6. **Bluetooth Headset verbinden**
|
|
- Headset in Pairing-Modus setzen
|
|
- Tab "Bluetooth" → Gerät pairen
|
|
|
|
## API Endpoints
|
|
|
|
| Endpoint | Methode | Beschreibung |
|
|
|----------|---------|--------------|
|
|
| `/api/status` | GET | Gesamtstatus |
|
|
| `/api/wifi/config` | GET/POST | WLAN-Konfiguration |
|
|
| `/api/wifi/scan` | GET | WLAN scannen |
|
|
| `/api/sip/config` | GET/POST | SIP-Konfiguration |
|
|
| `/api/bluetooth/devices` | GET | Gepaarte BT-Geräte |
|
|
| `/api/bluetooth/scan` | POST | BT-Scan starten |
|
|
| `/api/bluetooth/pair` | POST | Gerät pairen |
|
|
| `/api/call/answer` | POST | Anruf annehmen |
|
|
| `/api/call/hangup` | POST | Anruf beenden |
|
|
| `/api/system/reboot` | POST | Neustart |
|
|
| `/api/system/factory-reset` | POST | Werksreset |
|
|
|
|
## Projektstruktur
|
|
|
|
```
|
|
bluetooth-sip-client/
|
|
├── CMakeLists.txt
|
|
├── sdkconfig.defaults
|
|
├── partitions.csv
|
|
└── main/
|
|
├── main.c # Hauptprogramm
|
|
├── config/
|
|
│ ├── config_manager.h # Konfiguration Header
|
|
│ └── config_manager.c # NVS-basierte Config
|
|
├── wifi/
|
|
│ ├── wifi_manager.h # WiFi Header
|
|
│ └── wifi_manager.c # WiFi AP/STA Manager
|
|
├── web/
|
|
│ ├── web_server.h # Webserver Header
|
|
│ ├── web_server.c # HTTP Server
|
|
│ ├── web_api.h # API Header
|
|
│ ├── web_api.c # REST API
|
|
│ └── static/ # Web UI
|
|
│ ├── index.html
|
|
│ ├── style.css
|
|
│ └── app.js
|
|
├── bluetooth/
|
|
│ ├── 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_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
|
|
└── sip/
|
|
├── sip_client.h # SIP Client Header
|
|
├── sip_client.c # SIP UA Implementation
|
|
├── sip_parser.h # SIP Parser Header
|
|
└── sip_parser.c # SIP Message Parser
|
|
```
|
|
|
|
## 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
|
|
- **Codecs**: Aktuell nur G.711 (PCMU/PCMA)
|
|
- **SRTP**: Nicht unterstützt (nur unverschlüsseltes RTP)
|
|
|
|
## Troubleshooting
|
|
|
|
### Kein WLAN nach Konfiguration
|
|
- Gerät neu starten
|
|
- Hotspot sollte nach 30 Sekunden automatisch starten
|
|
|
|
### Bluetooth Headset verbindet nicht
|
|
- Headset zurücksetzen und erneut pairen
|
|
- Andere Bluetooth-Verbindungen am Headset trennen
|
|
|
|
### Kein Audio bei Anruf
|
|
- USB-Headset hat Priorität - bei Verwendung von BT das USB-Kabel entfernen
|
|
- Audio-Routing prüfen im Status-Tab
|
|
|
|
## Lizenz
|
|
|
|
MIT License
|