Scan, Pair, Connect to Bluetooth device from Ubuntu from command line using bluetoothctl

bluetoothctl is bluetooth control tool which allows us to make the host discoverable, scan other devices, pair to the scanned devices and also connect to those devices using command line utility on ubuntu.

Follow below commands for the same. Commands are self explanatory, replace scaned mac address of your device instead of “6C:C4:D5:6C:C5:BC” whereever required.

$ bluetoothctl
[NEW] Controller 70:1A:04:59:69:04 ubuntu-0 [default] 
 [bluetooth]# list
Controller 70:1A:04:59:69:04 ubuntu-0 [default]
 [bluetooth]# show 70:1A:04:59:69:04
Controller 70:1A:04:59:69:04
	Name: laptop
	Alias: ubuntu-0
	Class: 0x3c010c
	Powered: yes
	Discoverable: no
	Pairable: yes
	UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
	UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: OBEX File Transfer        (00001106-0000-1000-8000-00805f9b34fb)
	UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
	UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: IrMC Sync                 (00001104-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
	UUID: Message Notification Se.. (00001133-0000-1000-8000-00805f9b34fb)
	UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
	UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
	Modalias: usb:v1D6Bp0246d0525
	Discovering: no
 [bluetooth]# select 70:1A:04:59:69:04 
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 70:1A:04:59:69:04 Discoverable: yes
[bluetooth]# scan on
Discovery started
[CHG] Controller 70:1A:04:59:69:04 Discovering: yes
[bluetooth]# devices
[NEW] Device 6C:C4:D5:6C:C5:BC Nokia 7 plus
[bluetooth]# pair 6C:C4:D5:6C:C5:BC
Attempting to pair with 6C:C4:D5:6C:C5:BC
[CHG] Device 6C:C4:D5:6C:C5:BC Connected: yes
Request confirmation
[agent] Confirm passkey 090015 (yes/no): yes
[CHG] Device 6C:C4:D5:6C:C5:BC Modalias: bluetooth:v001Dp1200d1436
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001103-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001106-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 0000112d-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 6C:C4:D5:6C:C5:BC Paired: yes
Pairing successful
[CHG] Device 6C:C4:D5:6C:C5:BC Connected: no
[bluetooth]# trust 6C:C4:D5:6C:C5:BC
[CHG] Device 6C:C4:D5:6C:C5:BC Trusted: yes
Changing 6C:C4:D5:6C:C5:BC trust succeeded
[CHG] Controller 70:1A:04:59:69:04 Discoverable: no
[bluetooth]# connect 6C:C4:D5:6C:C5:BC
Attempting to connect to 6C:C4:D5:6C:C5:BC
[CHG] Device 6C:C4:D5:6C:C5:BC Connected: yes
Connection successful
[Nokia 7 plus]# info
Device 6C:C4:D5:6C:C5:BC
	Name: Nokia 7 plus
	Alias: Nokia 7 plus
	Class: 0x5a020c
	Icon: phone
	Paired: yes
	Trusted: yes
	Blocked: no
	Connected: yes
	LegacyPairing: no
	UUID: Dialup Networking         (00001103-0000-1000-8000-00805f9b34fb)
	UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
	UUID: OBEX File Transfer        (00001106-0000-1000-8000-00805f9b34fb)
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
	UUID: PANU                      (00001115-0000-1000-8000-00805f9b34fb)
	UUID: NAP                       (00001116-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
	UUID: SIM Access                (0000112d-0000-1000-8000-00805f9b34fb)
	UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
	UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
	UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
	Modalias: bluetooth:v001Dp1200d1436
	RSSI: -69
[Nokia 7 plus]# help
Available commands:
  list                       List available controllers
  show [ctrl]                Controller information
  select               Select default controller
  devices                    List available devices
  paired-devices             List paired devices
  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
  set-scan-filter-uuids [uuid1 uuid2 ...] Set scan filter uuids
  set-scan-filter-rssi [rssi] Set scan filter rssi, and clears pathloss
  set-scan-filter-pathloss [pathloss] Set scan filter pathloss, and clears rssi
  set-scan-filter-transport [transport] Set scan filter transport
  set-scan-filter-clear      Clears discovery filter.
  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
  list-attributes [dev]      List attributes
  select-attribute  Select attribute
  attribute-info [attribute] Select attribute
  read                       Read attribute value
  write    Write attribute value
  notify             Notify attribute value
  register-profile  Register profile to connect
  unregister-profile         Unregister profile
  version                    Display version
  quit                       Quit program
 $ quit 
Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply