ESP32-S3 SIP Firmware

Job ID: 40068148

Budget: $30 – $250 USD

I want custom firmware written for an ESP32-S3 SIP module
## Project Overview
We are building a **hardware–software audio gateway** that converts a **live cellular call audio from an Android phone** into a **SIP call**, and back again, in real time.
### High-level flow:
**Android phone , SIM call
→ USB OTG
→ **ESP32-S3 (USB Audio Class 1 device)**
→ **On-device SIP + Opus client**
→ SIP server / VoIP endpoint

…and **two-way audio must work reliably** for extended calls.

This is **not an Android app project**.
This is an **embedded firmware + SIP/audio pipeline project**.

## Project Goals (Non-Negotiable)

✔ ESP32-S3 enumerates as a **USB headset (UAC1)** on Android
✔ Android routes **SIM call audio** to USB
✔ ESP32-S3 runs a **SIP client with Opus codec**
✔ Audio flows both ways:

* SIM call → SIP
* SIP → SIM call
✔ Stable audio for **30+ minutes without drift or dropouts**
## Hardware & Environment

### ESP32 Side

* **ESP32-S3 with 8MB PSRAM**
* ESP-IDF (latest stable)
* TinyUSB for UAC1
* Wi-Fi for SIP/RTP

### Android Side

* **Redmi 4A**
* Android 6–7 range
* USB OTG enabled
* SIM call active (GSM/VoLTE)
## Project Scope (3 Mandatory Parts)
# PART 1 — USB Audio Class 1 (UAC1)

### Objective
ESP32-S3 must act as a **USB Audio Class 1 headset** when connected to Android via OTG.
### Requirements
* ESP32 acts as **USB Device**
* UAC1 compliant (not UAC2)
* Mono PCM audio
* 8 kHz or 16 kHz (configurable)
* Isochronous IN + OUT endpoints
* Ring buffers in PSRAM
* No audio glitches under continuous load
### Acceptance Criteria

Android detects device as **USB headset**
SIM call audio routes to USB automatically or via standard Android routing
USB loopback test works (speaker → mic)
Audio plays continuously for **10+ minutes**
# PART 2 — SIP Client on ESP32-S3
### Objective
ESP32 registers to a SIP server and handles VoIP calls.
### Requirements

* SIP REGISTER / INVITE / ANSWER / BYE
* Digest authentication
* SDP negotiation
* RTP transport
* **Opus codec mandatory**
* UDP SIP (TCP optional)
* Configurable SIP credentials
* Clean reconnection logic

### Acceptance Criteria

ESP32 registers and stays registered
Can place outgoing SIP calls
Can receive incoming SIP calls
Two-way audio works with a SIP softphone
Stable for **10+ minutes**

# PART 3 — Audio Transport Bridge

### Objective

Real-time bridge between USB PCM audio and SIP RTP audio.
### Required Pipeline
USB Speaker PCM → Opus Encode → RTP Send
RTP Receive → Opus Decode → USB Mic PCM
```### Architecture Requirements
* Separate FreeRTOS tasks:

* USB RX
* RTP TX
* RTP RX
* USB TX
* Ring buffers + jitter buffer
* Drift control (drop/insert or simple resampling)
* Underrun protection (never stall USB)
* Configurable latency buffers

### Acceptance Criteria

SIM call audio heard on SIP endpoint
SIP endpoint audio heard in SIM call
No progressive drift over **30+ minutes**
End-to-end latency ≤ 300 ms (reasonable target)
## Deliverables

1. **Complete ESP-IDF firmware project**
* Clean build
* PSRAM enabled
2. **Source code (no binaries only)**
3. **Build & flash instructions**
4. **Configuration documentation**
5. **Audio test & validation notes**
6. **Runtime logs/screenshots proving success**
## Required Repository Structure
firmware/
├── components/
│ ├── uac1_device/
│ ├── sip_client/
│ ├── rtp_opus/
│ ├── audio_bridge/
├── main/
docs/
├── setup.md
├── test_plan.md

1 — UAC1 Working
* USB headset recognized
* Loopback audio works
**30%**

### Milestone 2 — SIP Client Working
* SIP calls with Opus audio
**30%**
### Milestone 3 — Full Gateway Bridge
* SIM call ↔ SIP call fully bridged
* 30+ minute stability test
## Final Acceptance Test (Mandatory)

✔ Place real SIM call on Redmi 4A
✔ Audio passes through ESP32 to SIP endpoint
✔ SIP audio returns to phone call
✔ Call lasts **30+ minutes without audio failure**

No final payment without this test passing.
Ideal Freelancer Profile
* Strong **ESP32 / ESP-IDF** experience
* USB Audio Class (UAC) implementation experience
* SIP / RTP / Opus knowledge
* Real-time audio processing background
* Comfortable debugging timing & buffer issues
When Applying, Include:

1. Relevant ESP32 + audio projects
2. USB Audio or SIP experience
3. Which SIP stack you plan to use
4. Estimated timeline