New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Auto-accepting Bluetooth pairing confirmation on a headless Pi 3

Auto-accepting Bluetooth pairing confirmation on a headless Pi 3

Solved 4 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.

♥ 0

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.

♥ 1

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.

Accepted solution♥ 5

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.

♥ 1

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.

♥ 2
Viewing 5 posts – 1 through 5 (of 5 total)
  • 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.

Share