STM32 SIP User Agent
This is a simple SIP/VoIP application running on STM32F429ZI nucleo board (Cortex-M4, 256 kB RAM). It is based on re/rem/baresip and other commercially-friendly (BSD/MIT licenses, e.g. FreeRTOS v10) components.
Bit of warning: SIP is memory intensive and actual memory usage is depending very much on traffic volume and required functionality. STM32 or similar microcontroller has a small fraction of resources available to Linux SBCs or PCs and would have problems handling multiple simultaneous SIP transactions/dialogs or high call rate. Heap can be depleted pretty quickly, heap fragmentation might also be a problem. Using a microcontroller in a large network with hard to predict traffic bursts might not be a good idea in general.
I've used EmBitz 1.11 for this project - a 50 MB installer contains everything that is needed to compile sources and debugging is also quite smooth. It looks like there is no official download source for this version at the moment, so just in case I've uploaded it as https://github.com/tomek-o/EmBitz-1.11.
One annoyance to be aware of is that if one of library projects (e.g. re/rem/baresip) changes then top-level project may not see this update automatically and might need forcing relinking by e.g. modifying any source file.
Nucleo board has built-in ST-Link programmer/debugger supporting also virtual serial port used for logging. Opening serial terminal (115200 8N1) is highly recommended - logs include e.g. heap memory usage reports after each SIP call.
This application has no user configuration at the moment (it can be configured only by changing source code and recompiling). Network can be configured to start with a DHCP client, if DHCP fails switching to static IP (192.168.10.11 with netmask 255.255.254.0 as set in main.h), although at the moment DHCP is not enabled (again: see main.h). Application resembles the functionality of a simple SIP audio gate: it answers any incoming call and plays received audio through STM32 built-in DAC. In the other direction only silence is transmitted ("nullaudio" audio source device is selected).
You can connect DAC outputs to some amplifier (I guess some resistor and DC-blocking capacitor in series would be recommended) or use DAC to directly drive headphones (in this case 1 kOhm resistor in series for each DAC output should be used).
I've slightly changed (halved) SIP timers (T1, T2, T4) from their default re values as default SIP timer values are rather long (500 ms T1) and shortening them helps reducing memory usage in some cases.
Included audio codecs:
- L16/32000/1 (16-bit uncompressed PCM, 32000 samples per second, mono)
- G.711a, G.711u
Actual RAM usage: almost all of 192 kB "main" SRAM is allocated, starting with 112 kB FreeRTOS heap. 64 kB of CCM is not used at the moment.
Any SIP softphone or desk phone capable of direct IP/p2p calling should work. I might recommend using tSIP. For clean, not configured yet copy you would need to:
- select network interface (this is not always necessary, but I still would recommend starting with it); for laptop that is normally using separate WiFi, I've used direct Ethernet connection with nucleo board and static IP address (using 192.168.10.10 for laptop, 192.168.10.11 for nucleo board).
- enter 0.0.0.0:5060 as bind address; you might need to use other port for SIP if you already have some other SIP application running
- use YOUR_NETWORK_INTERFACE_IP:YOUR_SIP_PORT as server address
- select audio device if necessary; you might also use wav file (mono, S16 PCM) as audio source; if using microphone on Windows 10 you might need to explicitely allow tSIP to use microphone in Windows Privacy settings
- select codec to be used; default configuration has only G.711a/u enabled which would offer PSTN-like quality so you might want to use G.722 or L16
- call from tSIP to sip:STM32_BOARD_IP (if using DHCP you can see obtained address in startup log)
- 2022.10.01 STM32-SIP-126.96.36.199z