Repository navigation
Bluetooth Receiver: the phone's battery and signal, and a call card - #196
Merged
Merged
Conversation
A phone sends its battery and signal over its hands-free link, never over AVRCP, so the app now opens a HandsFree beside the AudioSink and shows both at the top right whenever the phone is connected. A call shows a card over the player: answer or decline while it rings; mute, the call's audio back to the phone, and hang up once answered, with the call's time. The call plays through audio_out at the call's rate with the microphones uplinked, and the music's output comes back when it ends. The contract covers every battery level, the signal and no service, and the card's answer, decline, mute, route and hang-up paths, on CPython and unix MicroPython.
…e their audio On a board whose HandsFree.call_audio is False (the ESP32-S31 for now, whose Bluetooth controller can't carry a call's audio link reliably, and the Pico W), the call card still shows the caller and answers, declines and hangs up, but offers no mute or speaker button and says the call's audio stays on the phone. The app never opens the speaker for the call there. A firmware without call_audio is taken to carry call audio, as before. The contract gains the same call on a demo phone without call audio, and a planted fault (mute shown anyway) fails it.
…d on The hands-free link (the phone's battery and signal from it, and the call card) now comes only with a switch in the header, "Phone calls and battery". It's off on every board until you turn it on, and the app keeps it in its config.json, so it stays as set the next time the app opens. Off, no HandsFree is opened and the app is the speaker it was: the battery at the top right is the one the phone's player reports over AVRCP. Checked with tests/btreceiver_contract.py on CPython and unix MicroPython: the switch starts off and opens no link, the player's battery shows, turning it on opens the link and shows the phone's battery and signal, off again closes it, and the setting is read back when the app opens again. Defaulting it to on fails 12 of those checks. The screenshots are taken again, the call states with the switch on.
bdbarnett
force-pushed
the
btreceiver-calls
branch
from
November 21, 2026 04:28
6d39cd3 to
11c1e2e
Compare
… turns on The hands-free link follows the sink only when the sink connects, so a phone that was already connected when Phone calls and battery was turned on never got one. The app now calls that phone itself, up to three times, three seconds apart. The board picture is a real screenshot from an ESP32-S31 board with the switch on. Checked on the board: with the switch off there's no hands-free link and music plays. Turned on, the phone's battery and signal show within seconds. The setting is still on after a reset. The contract test passes on CPython and unix MicroPython.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bluetooth Receiver now shows the phone's battery whenever the phone is connected, and it handles calls. A phone never sends its battery over AVRCP; it sends battery and signal over its hands-free link. So the app now opens a btclassic
HandsFreebeside theAudioSink, which follows the same phone by itself. The battery's 0 to 5 maps onto the iconkit battery icons, amber at 1 or below. The signal shows as four thin bars beside it, and no service empties them and says so. The AVRCP battery path is gone, and its charging state with it, since nothing reported it. A call shows a card over the player with the caller's number. While it rings you can decline or answer; once answered you can mute, hand the audio back to the phone (and bring it back), or hang up, and the card counts the call's time. The call's audio plays throughaudio_outat the call's rate with the board's microphones uplinked throughpcm_in, and the music's output comes back at its own rate when the call's audio leaves. If the board can't record while it plays, the card says the caller can't hear you.The demo gains
incomingandcallstates, and its states now show different battery levels.tools/shots.pysaves the two new pictures beside the others indocs/images, and the README has a Calls section. The contract adds checks for every battery level and its colour, the signal and no service, and the card's answer, decline, mute, use phone and use speaker, and hang up. It also checks that the phone's music pauses for a call and plays again after a hang-up or a decline, and that closing the app mid-call lets the hands-free link go. It passes on CPython and unix MicroPython, and two planted faults (the amber threshold moved, the card left up after a call) each fail it.On a Waveshare ESP32-S31-Touch-LCD-4.3C with a Galaxy S21 (79% charged), the Box showed battery level 4 with the player running, read from the phone's hands-free link. The phone has no SIM, so I couldn't place a cellular call or reach voicemail. Instead, a WebRTC page in the phone's Chrome made Android carry an active hands-free call to the board at 16 kHz. The card showed ON A CALL with the number Android gave it and a running timer. The page played a 1 kHz tone in 4-second bursts to the board's speaker, and read its own Bluetooth microphone: about -28 dB during each burst against -44 dB between them, tracking every burst. So the board's microphones reached the phone. When the call ended, the music output reopened at 44.1 kHz and A2DP played on with no underruns. The microphone needs the board config in PyDevices/omnipython#730 (that board's speaker and microphones share one I2S port). Not verified: an incoming cellular call's ringing state, decline and answer on real hardware (those are covered by the demo and the contract only), and caller names, which btclassic doesn't report. On that board's current firmware the Bluetooth controller panics as a call's audio starts in about half the tries; that's PyDevices/omnipython-builds#599, below this app.
Where the firmware's
HandsFree.call_audiois False, which is the ESP32-S31 with PyDevices/omnipython-builds#603 and the Pico W, the card leaves the call's audio on the phone. It shows the caller and still answers, declines and hangs up, hides Mute and Use phone, and says the audio stays on the phone. The demo takescall_audio=False, and the contract has a section for it. The README says so in its Calls section, and the roadmap has a line about bringing call audio back to the S31.On the same board with #600 and #603,
call_audioread False, and battery and signal showed and followed the phone (its battery level changed on the board within seconds). A call made by a WebRTC page in the phone's Chrome still reset the board, because Android routes that kind of call to the board even with the audio policy #603 sends, and the controller faults as soon as the phone asks for the audio link. The details are on #603. So answering and hanging up from the board during a call aren't verified on the S31, and neither is the ringing card on a real cellular call (the phone has no SIM card).