Auto-accepting Bluetooth pairing confirmation on a headless Pi 3
Translated from Türkçe by AI ·
Pi 3B+, Bookworm Lite, inside a panel in the field, no screen or keyboard. During setup the technician connects with a tablet over Bluetooth serial (SPP) and enters a few settings: Wi-Fi info and the Hermetry access token. Trying it with a screen on the bench works fine, but in the field, during pairing, bluetoothctl waits for this:
[agent] Confirm passkey 482913 (yes/no):
Since there is no screen, nobody can type “yes”, and pairing times out. Is there a way to accept this automatically? Also, on the SPP side I opened getty with rfcomm, but nothing comes through when the tablet connects.
Pi 3B+, Bookworm Lite, sahada bir pano içinde, ekran klavye yok. Kurulumda teknisyen tablet ile Bluetooth seri (SPP) üzerinden bağlanıp birkaç ayar giriyor: Wi-Fi bilgisi ve Hermetry access token’ı. Masada ekranla denerken sorun yok, ama sahada eşleşme sırasında bluetoothctl şunu bekliyor:
[agent] Confirm passkey 482913 (yes/no):
Ekran olmadığı için kimse “yes” diyemiyor, eşleşme zaman aşımına uğruyor. Bunu otomatik kabul ettirmenin yolu var mı? Bir de SPP tarafında rfcomm ile getty açtım ama tablet bağlanınca bir şey gelmiyor.
Translated from Türkçe by AI ·
If you accept automatically, anyone within range can pair, so be careful. Bluetooth passes through walls even when the panel is locked.
Otomatik kabul edersen menzildeki herkes eşleşebilir, buna dikkat. Pano kilitli bile olsa Bluetooth duvardan geçer.
Translated from Türkçe by AI ·
I did the same thing in the lab, there are two separate issues.For pairing, run bt-agent from the bluez-tools package in NoInputNoOutput mode. In this mode no passkey is requested:
sudo apt install bluez-tools
# /etc/systemd/system/bt-agent.service
[Service]
ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
Restart=always
[Install]
WantedBy=multi-user.target
Because of what Ms. Derya said, I didn’t keep the device visible all the time. There is a small script that runs bluetoothctl discoverable on and pairable on for 2 minutes when a button on the panel is pressed, and turns both off when the time is up.The reason getty doesn’t appear on the SPP side is most likely that bluetoothd is not running in compatibility mode. On Bookworm the SPP profile is not registered by default. Start bluetoothd with -C, then add the serial port:
# /etc/systemd/system/bluetooth.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/libexec/bluetooth/bluetoothd -C
sudo sdptool add SP
sudo rfcomm watch hci0 1 getty rfcomm0 115200 vt100
After entering the token, don’t leave it on the screen. And if it stayed on a technician’s tablet, it’s a good idea to rotate it later from Hermetry.
Ben laboratuvarda aynısını yaptım, iki ayrı sorun var.
Eşleşme için bluez-tools paketindeki bt-agent’ı NoInputNoOutput moduyla çalıştır. Bu modda passkey sorulmuyor:
sudo apt install bluez-tools
# /etc/systemd/system/bt-agent.service
[Service]
ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
Restart=always
[Install]
WantedBy=multi-user.target
Derya Hanım’ın dediği yüzünden ben cihazı sürekli görünür bırakmadım. Panodaki bir butona basınca 2 dakika bluetoothctl discoverable on ve pairable on yapan küçük bir script var, süre bitince ikisini de kapatıyor.
SPP tarafında getty’nin gelmemesinin sebebi büyük ihtimalle bluetoothd’nin uyumluluk modunda çalışmaması. Bookworm’da SPP profili kayıtlı gelmiyor. bluetoothd’yi -C ile başlat, sonra seri portu ekle:
# /etc/systemd/system/bluetooth.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/libexec/bluetooth/bluetoothd -C
sudo sdptool add SP
sudo rfcomm watch hci0 1 getty rfcomm0 115200 vt100
Token’ı girdikten sonra ekranda bıraktırma, bir de teknisyenin tabletinde kaldıysa sonra Hermetry’den rotate etmek iyi fikir.
Translated from Türkçe by AI ·
I set up the bt-agent service plus a button-triggered 2-minute window, and pairing now works without issues. The getty problem was exactly as you said: the -C was missing, and rfcomm was throwing an “sdp” error, I was looking for the error in the wrong place. Thanks.
bt-agent servisi + butonla 2 dakikalık pencere yaptım, eşleşme artık sorunsuz. getty meselesi tam dediğin gibi -C eksikti, rfcomm “sdp” hatası veriyordu, ben hatayı yanlış yerde arıyordum. Teşekkürler.
Translated from Türkçe by AI ·
The button idea is good, we also put it inside the panel cover, so it can’t be pressed without opening the cover.
Buton fikri iyi, biz de pano kapağının içine koymuştuk, kapak açılmadan basılamıyor.
- You must be logged in to reply to this topic.
Join the conversation
Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

