Programmatically removing all bluetooth devices on the Linux command line
bluetooth, bluez, hci, linux
Solution
For those using Ubuntu 20.04, here is the same command using the bluetoothctl command
#!/bin/bash
for device in $(bluetoothctl devices | grep -o "[[:xdigit:]:]\{8,17\}"); do
echo "removing bluetooth device: $device | $(bluetoothctl remove $device)"
done
Problem
I am able to scan for all available bluetooth devices with hcitool or with my C program. I can pair the device using it's address with a simple-agent python script. I would like to know if I can also remove the paired device using either hcitool, hciconfig or some kind of bluetooth command. I know the information of detected devices for the hci0 controller is stored in /var/lib/bluetooth/XX:XX:XX:XX:XX:XX, where XX:XX:XX:XX:XX is the address of the hci controller. This would be useful for testing pairing, connecting and disconnecting devices.