Engineering notes
Raspberry Pi Bluetooth discoverable, but the phone can't find it
Raspberry Pi Bluetooth discoverable but not showing on Android? BlueZ's default inquiry scan listens 11 ms every 2.56 s. Measurements and the two-line fix.
We had a Raspberry Pi 5 acting as a Bluetooth headset. During a pairing window, bluetoothctl show said everything a guide tells you to check:
Discoverable: yes
Pairable: yes
Class: 0x00600404
0x600404 is a wearable headset with the Audio and Telephony service bits set, which is what a phone expects from a hands-free device. And yet a Pixel sitting on its "Pair new device" screen never listed the Pi. A Mac running a long inquiry did find it.
Most threads about this blame the device name, a stale cache on the phone, or a missing pairing agent. None of those were it. The setting that mattered was the inquiry scan timing, and BlueZ's config option for it is accepted and then never sent to the controller.
Setup
- Raspberry Pi 5, Raspberry Pi OS, kernel 6.18 (
rpi-2712) - BlueZ 5.82, onboard controller on
hci0 - Phone: a Pixel. Test inquirer: a Mac with
blueutil
What "discoverable" means at the radio
Discoverable in BlueZ means one thing: the controller has inquiry scan enabled. While it is enabled, the controller wakes up every interval, listens for window, and answers any inquiry it hears.
You can read the current values without root:
$ hciconfig hci0 inqtype
Inquiry scan type: Standard Inquiry Scan
$ hciconfig hci0 inqparms
Inquiry interval: 4096 slots (2560.00 ms), window: 18 slots (11.25 ms)
(Header lines trimmed.)
That is the slowest setting the spec allows: an 11.25 ms listen every 2.56 s. "Standard" scan also listens on only one of the two frequency trains an inquiring device sweeps, so a given listen can miss the inquirer entirely.
A phone does not inquire for long. Android runs classic inquiry in short bursts and shares the radio with BLE scanning. When the target listens for 11 ms out of every 2,560, many of those bursts land entirely between its windows.
Measuring it
We used the Mac as a stand-in phone, ran blueutil --inquiry <seconds> repeatedly with the Pi in a pairing window, and counted runs that found the Pi by name.
One quirk first: back-to-back blueutil inquiries alternate hit and miss (1, 0, 1, 0...). Space runs about 1 s apart, or the numbers mean nothing.
| Pi setting | Inquiry length, spacing | Found |
|---|---|---|
| Pairing window closed (control) | 2 s | 0/2 |
| Inquiry scan disabled (control) | 2 s, spaced | 0/3 |
| Defaults (standard, 2.56 s) | 2 s, unspaced | 0/10 |
| Defaults | 3 s, unspaced | 0/10 |
| Defaults | 6 s, unspaced | 3/6 |
| Defaults | 2 s, spaced | 5/8, later 2/10 |
| Interlaced, 320 ms interval | 2 s, unspaced | 5/10 |
| Interlaced, 160 ms interval | 2 s, spaced | 10/10 |
| Interlaced, 160 ms interval | 1 s, spaced | 10/10 |
The scan-disabled control matters: it shows blueutil is not answering from a cache.
With defaults, short inquiries found the Pi somewhere between never and half the time. With interlaced scan at a 160 ms interval, a 1 s inquiry found it every time.
The config option that does nothing
BlueZ's main.conf has the obvious knobs in its [BR] section:
[BR]
InquiryScanType = 1
InquiryScanInterval = 256
InquiryScanWindow = 18
bluetoothd parses them without a warning and sends them to the kernel at startup through the management interface (MGMT_OP_SET_DEF_SYSTEM_CONFIG). After a restart, hciconfig still reads back 2.56 s and Standard.
The kernel source explains why. net/bluetooth/mgmt_config.c accepts parameters 0x0003 to 0x0005 and stores them in def_inq_scan_type, def_inq_scan_int and def_inq_scan_window on the device. Nothing in net/bluetooth reads those fields back. The page scan defaults stored right next to them are used when the kernel writes the page scan activity (hci_sync.c); the inquiry scan ones are never written to the controller. So the setting is accepted, stored, and ignored.
(Side note: the section is [BR]. [BREDR] is rejected with Unknown group BREDR.)
Renaming the device, a longer pairing window, and showing the advertised name in the UI did not help either. The phone never heard an inquiry response, so nothing on the naming side could matter.
The fix
Write the controller directly:
sudo hciconfig hci0 inqtype 1 # interlaced: both trains in each listen
sudo hciconfig hci0 inqparms 18:256 # window:interval in 0.625 ms slots = 11.25 ms / 160 ms
The catch is that this does not persist. bluetoothctl power off then power on restores the controller defaults, and so does any HCI reset. So re-apply it:
- from an
ExecStartPost=oneshot tied tobluetooth.service, for boots and restarts - from a periodic timer that checks
hciconfig hci0 inqparmsand re-applies when it drifts. With a 15 s timer the settings came back within about 11 s of a power cycle
A faster interval costs radio time, but inquiry scan only runs while the device is discoverable. Outside pairing windows it costs nothing.
Our regression check: open a pairing window, run 10 short inquiries from the Mac spaced 1 s apart, and require at least 8 hits. Before the fix: 2/10. After: 10/10.
The phone was broken too
After the Pi fix, the Pixel still did not list it. That made the fix look like a failure, and it was not.
adb shell dumpsys bluetooth_manager showed the phone's Bluetooth stack stuck:
Discovering: true, withDiscoveryEndMsfrom two days earlier- every
startDiscoverycall returnedtrueand did nothing; noDISCOVERY_STARTEDbroadcast went out, and Settings cancelled each scan after 60 s
The "Pair new device" screen still looked alive, because Settings runs its own BLE scan in parallel and listed BLE devices from that. All 112 devices in its nearby cache were BLE. None came from a classic inquiry.
Turning Bluetooth off and on reset it:
adb shell cmd bluetooth_manager disable
adb shell cmd bluetooth_manager enable
Right after, a test app's discovery finished in 12.8 s and found the Pi as a classic device with class 0x600404 at -69 to -81 dBm, 3 runs out of 3.
If you write your own probe app for this, two gotchas cost us time:
- A receiver registered at runtime with
RECEIVER_NOT_EXPORTEDgets no discovery broadcasts. They come from the Bluetooth app's uid, so the receiver has to be exported. - An activity behind the keyguard or a dock screensaver gets none either.
showWhenLockedplusturnScreenOnfixed it.
Takeaways
- "Discoverable" only means inquiry scan is on. At BlueZ's defaults, a phone's short scan often misses it.
InquiryScanIntervaland friends inmain.confare accepted and stored but never reach the controller. Usehciconfig hci0 inqtype 1andinqparms 18:256, and re-apply after every controller reset.- Before tuning a device a phone "can't see", check the phone's discovery state. Here both sides were broken, and each fix looked like it failed until the other one was done.
We hit a related Android Bluetooth problem with earbuds that showed as connected but played nothing; the cause was a different layer of the same stack, and the write-up is in AirPods on a Pixel: "connected", but no audio.