Changing raspberry pi bluetooth device name?
It stores the display name in /var/lib/bluetooth/xx:xx:xx:xx:xx:xx/config file. If you wants to change the bluetooth display(broadcast) name then you need to follow the below steps:
- delete /var/lib/bluetooth/xx:xx:xx:xx:xx:xx/config file.
- Edit /etc/bluetooth/main.conf(For ex: Name=%d-%h to Name=abcd-5)
- service bluetooth restart.
Note: If this already paired with some other BT devices, so you need to remove the pairing to see the new BT name of the same device(MAC).
You can also just disable the hostname plugin and configure the name.
Run sudo vim /etc/systemd/system/bluetooth.target.wants/bluetooth.service
and append --noplugin=hostname
, like this:
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=hostname
Then edit the bluetooth config and set your desired name:
sudo vim /etc/bluetooth/main.conf
Name = YourNewName
If you want to change the bluetooth device name permanently, you have to create a file called /etc/machine-info which should have the following content:
PRETTY_HOSTNAME=device-name
Then issue "service bluetooth restart" after that
@Evangelos Nannos answer still works (BlueZ 5.50) but if you want to change bluetooth alias on the fly you may try bluetoothctl (tested on Pi Zero W running Raspbian Stretch & BlueZ 5.50)
To set new alias open terminal:
pi@raspberrypi:~ $ bluetoothctl
[bluetooth]# system-alias 'Your New BT Alias'
Changing Your New BT Alias succeeded
[CHG] Controller AA:BB:CC:DD:EE:FF Alias: Your New BT Alias
Use show to see current bluetooth settings:
[bluetooth]# show
Controller AA:BB:CC:DD:EE:FF
Name: Some_other_name #default or as PRETTY_HOSTNAME
Alias: Your New BT Alias #alias will be shown when scanning for bt devices
(...)
Reset alias and go back to using system device name with:
[bluetooth]# reset-alias
Exit bluetootctl with:
[bluetooth]# quit
With Discoverable on (yes) the device will show up during scaning as Your New BT Alias.
Take note that alias will be kept after reboot!
I've use pexpect to manipulate bluetoothctl, bash works too. There were problems registering Agent on BlueZ 5.43 via pexpect, had to upgrade to 5.50
Alternative command (note it will not return a response):
pi@raspberrypi:~ $ sudo hciconfig hci0 name 'New device name'