Bluetooth in Terminal

14,227

Give this tool a try:

bluetoothctl

Here is the installation guide: (https://wiki.archlinux.org/index.php/bluetooth#Installation)

it gives you a lot of posibilities:

Menu main:
Available commands:
-------------------
advertise                                         Advertise Options Submenu
scan                                              Scan Options Submenu
gatt                                              Generic Attribute Submenu
list                                              List available controllers
show [ctrl]                                       Controller information
select <ctrl>                                     Select default controller
devices                                           List available devices
paired-devices                                    List paired devices
system-alias <name>                               Set controller alias
reset-alias                                       Reset controller alias
power <on/off>                                    Set controller power
pairable <on/off>                                 Set controller pairable mode
discoverable <on/off>                             Set controller discoverable mode
agent <on/off/capability>                         Enable/disable agent with given capability
default-agent                                     Set agent as the default one
advertise <on/off/type>                           Enable/disable advertising with given type
set-alias <alias>                                 Set device alias
scan <on/off>                                     Scan for devices
info [dev]                                        Device information
pair [dev]                                        Pair with device
trust [dev]                                       Trust device
untrust [dev]                                     Untrust device
block [dev]                                       Block device
unblock [dev]                                     Unblock device
remove <dev>                                      Remove device
connect <dev>                                     Connect device
disconnect [dev]                                  Disconnect device
menu <name>                                       Select submenu
version                                           Display version
quit                                              Quit program
exit                                              Quit program
help                                              Display help about this program

you can even drill down into the advertise policies and more:

# menu advertise 
Menu advertise:
Available commands:
-------------------
uuids [uuid1 uuid2 ...]                           Set/Get advertise uuids
service [uuid] [data=xx xx ...]                   Set/Get advertise service data
manufacturer [id] [data=xx xx ...]                Set/Get advertise manufacturer data
tx-power [on/off]                                 Show/Enable/Disable TX power to be advertised
name [on/off/name]                                Configure local name to be advertised
appearance [on/off/value]                         Configure custom appearance to be advertised
duration [seconds]                                Set/Get advertise duration
timeout [seconds]                                 Set/Get advertise timeout
clear [uuids/service/manufacturer/config-name...] Clear advertise config
back                                              Return to main menu
version                                           Display version
quit                                              Quit program
exit                                              Quit program
help                                              Display help about this program

That is a lot of information you can pull (and set) directly.

Share:
14,227

Related videos on Youtube

Daniel James
Author by

Daniel James

Updated on October 03, 2022

Comments

  • Daniel James
    Daniel James about 1 year

    I want to see the Bluetooth adapter details in terminal without using Bluetooth GUI. Initially Bluetooth is turned off both in terminal and GUI.

    My commands for different functions in Terminal

    View status of Bluetooth (it will show active/inactive and status in some cases, and just active/inactive in some other cases)

    sudo /etc/init.d/bluetooth status
    

    Turn on Bluetooth

    sudo /etc/init.d/bluetooth start
    

    Turn off Bluetooth

    sudo /etc/init.d/bluetooth stop
    

    View the Bluetooth adapter details

    hciconfig
    

    I can see the adapter details with the help of Bluetooth GUI in Settings GUI.

    I researched the status of Bluetooth in different cases by doing following steps in order:

    1. Turn on Bluetooth via terminal

    • Status = "Running"
    • Active = "active (running)"
    • Bluetooth adapter details: Doesn't display anything

    2. Turn off Bluetooth via terminal

    • Status = Not shown
    • Active = "inactive (dead)"
    • Bluetooth adapter details: Doesn't display anything

    3. Turn on Bluetooth via GUI

    • Status = "Running"
    • Active = "active (running)"
    • Bluetooth adapter details: Shows the adapter details

    4. Turn off Bluetooth via terminal, but doesn't change in GUI

    • Status = "Quitting"
    • Active = "inactive (dead)"
    • Bluetooth adapter details: Shows the adapter details

    5. Turn on Bluetooth via terminal

    • Status = "Running"
    • Active = "active (running)"
    • Bluetooth adapter details: Shows the adapter details

    6. Turn off Bluetooth via terminal, but doesn't change in GUI

    • Status = "Quitting"
    • Active = "inactive (dead)"
    • Bluetooth adapter details: Shows the adapter details

    7. Turn off Bluetooth in GUI

    • Status = Not shown
    • Active = "inactive (dead)"
    • Bluetooth adapter details: Doesn't display anything

    Can someone please help me what's wrong in my commands? Also, why it works fine along with GUI? What does GUI actually do?