LOG-01PHYSICS
One radio, two jobs
Wi-Fi and Bluetooth share one 2.4 GHz radio on the ESP32 and time-slice the same antenna. When A2DP is transmitting, the TCP window (~5.7 KB — an Arduino LWIP compile-time constant) multiplied by an RTT stretched to 350–500 ms gives you 12–14 KB/s. A 128 kbps MP3 stream needs 16. The deficit isn't a bug, it's arithmetic.
LOG-02GOTCHA
WiFi.setSleep(false)
Classic forum advice for speeding up Wi-Fi on the ESP32. With Bluetooth active, the controller hits abort() and the cube boot-loops every 26 seconds. Modem-sleep stays; the coex layer requires it.
LOG-03PHYSICS
Burst-equilibrium
The CDN hands over the first few seconds of a stream in a fast burst, then settles into exactly 1× realtime. Any buffer threshold set above the equilibrium point will never be reached — the radio waits forever to "finish buffering." Every reserve threshold had to come down below it.
LOG-04DISCOVERY
Decoder budget ≠ bandwidth
Tripling the decoder's work per loop pass didn't add a single audio frame (the deficit lives in the network), but it stretched the pass to 1.6 s and killed touch response. Under a network deficit, the decoder budget only governs UI responsiveness. We set it back to 8192 frames per pass.
LOG-05BUG
The rotation that didn't rotate
The stream's death paths never cleared the active endpoint, so "candidate rotation" had been reopening the same dead URL over and over. Symptom: 81 restarts in 3 minutes. The fix came down to clearing the endpoint in three places.
LOG-06RAM
TLS versus Bluetooth
A TLS handshake needs ~40 KB of free DRAM. With Bluetooth playing, only 25–30 KB is left, so switching to a station that needs HTTPS discovery mid-playback is physically impossible. The fix: pinned plain-HTTP fallbacks per station, plus a cache of the last source that worked.
LOG-07BT
The pairing window
After a power cycle, the speaker doesn't politely wait for a scan — it calls the cube itself. And the cube was rejecting strangers. A standoff. Fix: tapping "scan" opens a window where any matching incoming speaker gets adopted and remembered.
LOG-08RF
Too close to the router
Two meters from the access point, the audio drops out in waves; one room over, it plays flawlessly. The router's Wi-Fi transmitter is drowning out the cube's Bluetooth receiver. Sometimes the best firmware fix is moving the device three meters.