Linux show bluetooth device

How to check bluetooth status via terminal

I suppose I needed to word my question better. This answer provides me with what I need. With this I can see if my device is on or off based on whether or not it shows up. Thank you for your reply.

More information with hciconfig -a

hciconfig -a provides way more information, including the Bluetooth version.

$ hciconfig -a hci0: Type: Primary Bus: USB BD Address: 00:1A:7D:DC:70:13 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:1013 acl:0 sco:0 events:60 errors:0 TX bytes:4890 acl:0 sco:0 commands:60 errors:0 Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'hostname' Class: 0x1c0104 Service Classes: Rendering, Capturing, Object Transfer Device Class: Computer, Desktop workstation HCI Version: 4.0 (0x6) Revision: 0x22bb LMP Version: 4.0 (0x6) Subversion: 0x22bb Manufacturer: Cambridge Silicon Radio (10) 

Just press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, You can run this command to see the status of bluetooth

sudo service bluetooth status 

after you enter your password, you should see something like

Regardless of whether or not the bluetooth is on i get the same message from that command: bluetooth start/running, process 1132

The Bluetooth icon disappeared.I get the following message. Can anyone please help me what this mean?

ashoke@Dell-3470:~$ sudo service bluetooth status ● bluetooth.service — Bluetooth service Mar 09 15:16:42 Dell-3470 bluetoothd[1141]: Starting SDP server Mar 09 15:16:42 Dell-3470 bluetoothd[1141]: Bluetooth management interface 1.14> Mar 09 16:35:14 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) Mar 09 16:35:59 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) Mar 09 16:36:01 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) Mar 09 16:36:04 Dell-3470 bluetoothd[1141]: Failed to set mode: Failed (0x03) lines 1-20/20 (END)

This answer was correct for me. I wanted to see if it was active and it said so, I think this answers the question. Thanks for the help:)

An alternative is to use the command hciconfig . It will list clearly the interfaces, and you will see by the marker «RUNNING» or «DOWN» what is their current status.

With BlueZ: Using bluetoothctl (interactive bluetooth control tool), which gives you a terminal with show and these other commands:

[bluetooth]# help 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 Select default controller devices List available devices paired-devices List paired devices system-alias Set controller alias reset-alias Reset controller alias power Set controller power pairable Set controller pairable mode discoverable Set controller discoverable mode discoverable-timeout [value] Set discoverable timeout agent Enable/disable agent with given capability default-agent Set agent as the default one advertise Enable/disable advertising with given type set-alias Set device alias scan 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 Remove device connect Connect device disconnect [dev] Disconnect device menu Select submenu version Display version quit Quit program exit Quit program help Display help about this program export Print environment variables 

With bluez-tools: bt-* ( apropos bt- ) like bt-device , a bluetooth device manager.

Читайте также:  Нужно ли устанавливать линукс

Источник

bluetoothctl: list connected devices?

I’m trying to get a list of connected Bluetooth devices via the command line on Kubuntu. When I launch bluetoothctl , it defaults to the latest connected device, and I need to disconnect it to display the other one. Is there a way to list the connected Bluetooth devices?

6 Answers 6

Here’s a fish-shell one-liner (see below for bash)

bluetoothctl devices | cut -f2 -d' ' | while read uuid; bluetoothctl info $uuid; end|grep -e "Device\|Connected\|Name" 

bash one-liner:

bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid; done|grep -e "Device\|Connected\|Name" 

You can list paired devices with bluetoothctl paired-devices

From this list you can get info for each device with bluetoothctl info On the info you have the Connected status.

So loop on each devices grep for Connected: yes if so display the name:

bluetoothctl paired-devices | cut -f2 -d' '| while read -r uuid do info=`bluetoothctl info $uuid` if echo "$info" | grep -q "Connected: yes"; then echo "$info" | grep "Name" fi done 

This may help: sudo bluetoothctl info MAC-ADDRESS-OF-DEVICE

Welcome to Super User! Would you mind explaining how that would help the person who asked the question?

I see my headphones listed when i run bluetoothctl paired-devices — but when I run bluetoothctl info I still get the error Missing device address argument .

@CarlWalsh, the error tells you exactly what you’re missing: bluetoothctl info gives information about a single device, thus you need to tell it the MAC address of the device you want to get information about.

As of bluez/bluetoothctl 5.65 ( bluetoothctl —version ), we can use bluetoothctl devices Connected (Capitalized C) to list connected bluetooth devices. For example:

$ bluetoothctl devices Connected Device AA:BB:CC:DD:EE:FF MY-DEVICE-NAME 

If you care about paired devices, use bluetoothctl devices Paired for bluez/bluetoothctl version >= 5.65, or bluetoothctl paired-devices for bluez/bluetoothctl < 5.65.

After running sudo bluetoothctl .

you can type paired-devices to see a list of paired devices
or list to see a list of currently connected controllers

you can also type info to see info about each device.

Each command here supports tab completion of MAC addresses.

Читайте также:  Криптопро csp for linux

I use this to display the currently connected device in my Swaybar:

bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid; done | grep -e "Name\|Connected: yes" | grep -B1 "yes" | head -n 1 | cut -d\ -f2- 
bluetoothctl devices # List all devices cut -f2 -d' ' # Cut out the second column containing the MAC address while read uuid; do bluetoothctl info $uuid; done # For each MAC address call bluetoothctl info grep -e "Name\|Connected: yes" # Find all lines that have either name or Connected: yes grep -B1 "yes" # Find the line with yes and the line before that line head -n 1 # Return the last line cut -d\ -f2- # Return the second column and all other columns for the device name 

Источник

Retrieve paired Bluetooth devices from console

Is there any way to retrieve all paired bluetooth devices («Friendly name» and MAC-Adress) from the console? Is there any universal solution for any Linux distribution? In case there isn’t: I’m using an Ubuntu derivative. I already tried some stuff with hcitool , but nothing worked so far.

3 Answers 3

Late to the party, I tried listing as suggested by @panmari and @MarkCh but I was getting some unknown mac addresses (on a C.H.I.P with Debian), so I used the following command:

It will return both friendly name and Mac of all paired devices.

I found a solution myself. In Linux, the friendly names with their according mac adresses are saved in the file:

It should be easy enough to read it out with a shell script or the programming language of your choice.

This directory does not exist on Ubuntu 17, nor the file names , but /var/lib/bluetooth///info exists

Install bluez-utils , run bluetoothctl paired-devices . See bluetoothctl —help for more useful commands.

I am using Raspian on Raspberry Pi 4 and connected my Bluetooth keyboard via the GUI. After setting boot mode to CLI it did not work anymore. bluez-tools (now bluez) was already installed. After starting bluetoothctl I saw with the command paired-devices , that no keyboard was connected. With scan on I was able to find out the device address and pair it with pair , trust it with trust and connect it with connect

Источник

Bluetooth in Terminal

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 
sudo /etc/init.d/bluetooth start 
sudo /etc/init.d/bluetooth stop 
  • 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
Читайте также:  Linux date format time

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?

Questions that are not about writing software should be on a different StackExchange site. In this case, consider Unix & Linux or SuperUser

(Also, we can’t say anything useful about your GUI without knowing which one it is — lots of different Linux distributions have their own settings GUIs, and nothing included in this question specifies your distro, desktop environment, etc; similarly, /etc/init.d/bluetooth is itself distribution-specific).

1 Answer 1

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 Select default controller devices List available devices paired-devices List paired devices system-alias Set controller alias reset-alias Reset controller alias power Set controller power pairable Set controller pairable mode discoverable Set controller discoverable mode agent Enable/disable agent with given capability default-agent Set agent as the default one advertise Enable/disable advertising with given type set-alias Set device alias scan 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 Remove device connect Connect device disconnect [dev] Disconnect device menu 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.

Источник

Оцените статью
Adblock
detector