Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Auto-trust bluetooth devices
#3
IIRC Bluetooth comms setup sequence is as follows:

Trust
Pair
Connect

If the device is not trusted before pairing a passcode will be required. This would be indicated by a passcode prompt on the client trying to pair with the untrusted device.

In moOde /var/www/util/blu-control.sh script all scanned devices are automatically trusted for 90 secs.

Code:
# Set to the value of the TemporaryTimeout param in /etc/bluetooth/main.conf
TRUSTED_DEVICE_TIMEOUT=90

.
.
.

# Trust scanned devices
TRUST() {
    echo "** Trust expires in $TRUSTED_DEVICE_TIMEOUT seconds"
    unset btdev
    mapfile -t btdev < <(echo -e "devices\nquit"  | bluetoothctl | grep "^Device" |  while IFS= read -r line ; do echo "$line" |cut -d " " -f2- ; done )
    for i in "${btdev[@]}" ; do
       echo "** $i"
       y="$( echo $i | cut -d " " -f1)"
       echo -e "trust $y\nquit"  | bluetoothctl >/dev/null
       #sleep 1
    done
    echo "**"
}
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
Auto-trust bluetooth devices - by Tim Curtis - 06-22-2023, 11:55 AM
RE: Auto-trust bluetooth devices - by Tim Curtis - 06-22-2023, 06:11 PM

Forum Jump: