Blob: bluetoothctl.rst

Blob id: 0187e877d60b28eb1e735181b3203e60da821e6f

Size: 8.3 KB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
============
bluetoothctl
============

-----------------------------------
Bluetooth Control Command Line Tool
-----------------------------------

:Version: BlueZ
:Copyright: Free use of this software is granted under the terms of the GNU
            Lesser General Public Licenses (LGPL).
:Date: March 2024
:Manual section: 1
:Manual group: Linux System Administration

SYNOPSIS
========

**bluetoothctl** [**-a** *capability*] [**-e**] [**-m**] [**-t** *seconds*]
[**-v**] [**-h**]

DESCRIPTION
===========

**bluetoothctl(1)** interactive bluetooth control tool. The tool works with
Bluetooth Classic (BR/EDR) and Bluetooth Low Energy (LE) controllers.

The tool is menu driven but can be automated from the command line.
Examples are given in the automation section.

OPTIONS
=======

-a capability, --agent capability        Register agent handler: <capability>
-e, --endpoints                  Register Media endpoints
-m, --monitor                    Enable monitor output
-t seconds, --timeout seconds    Timeout in seconds for non-interactive mode
-v, --version       Display version
-h, --help          Display help


Commands
========

list
----

List available controllers.

:Usage: **> list**

show
----

Controller information.

:Usage: **> show [ctrl]**

select
------

Select default controller.

:Usage: **> select <ctrl>**

devices
-------

List available devices, with an optional property as the filter.

:Usage: **> devices [Paired/Bonded/Trusted/Connected]**

system-alias
------------

Set controller alias.

:Usage: **> system-alias <name>**

reset-alias
-----------

Reset controller alias.

:Usage: **> reset-alias**

power
-----

Set controller power.

When the controller is powered off, the USB port the controller is attached to
is put into a suspend state.

:Usage: **> power <on/off>**

advertise
---------

Enable/disable advertising with given type.

If you exit the program advertising will be disabled.

When advertising the controller should advertise with random address but may
use its public address if it does not support the feature (address of the
device).

A device can advertise if it initiated the connection to another advertising
device.

:Usage: **> advertise <on/off/type>**

set-alias
---------

Set device alias.

:Usage: **> set-alias <alias>**

scan
----

Scan for devices.

For LE, scanning is an important requirement before connecting or pairing.

The purpose of scanning is to find devices that are advertising with their
discoverable flag set (either limited or general). Once you have found the
address then you can connect or pair.

Note the following when scanning:

  - When scanning the controller will use a random address that is not
    resolvable so the public address is not leaked. A new random address is
    created every time scan on is used.
  - When turning on scanning the device will start receiving advertising reports
    of what devices are advertising.
  - The filtering of duplicate advertising reports may be enabled depending on
    the filtering settings.
  - Device objects found during a scan session will only be persisted if they
    are connected/paired otherwise they are removed after some time.

:Usage: **> scan <on/off/bredr/le>**

pair
----

Pair with device.

This will pair with a device and then trust and connect to it. If the device is
already paired this will first remove the pairing.

The command can either be used while the controller is in the connected or not
connected state.

If the controller is already connected then the pair command can be used without
an arguments. If the controller is not connected, the pair command can be given
the address of a device with an active scan report and it will initiate the
connection before pairing.

Before pairing the agent must be selected to choose the authentication
mechanism.

:Usage: **> pair <dev>**

pairable
--------

Set controller pairable mode.

This enables/disables pairing. If pairing is disabled then the controller will
not accept any pairing requests.

:Usage: **> pairable <on/off>**

discoverable
------------

Set discoverable mode.

This enables/disables discoverable mode. If discoverable is disabled then the
controller will not respond to any scan requests.

In LE if discoverable if off the controller will just passively scan and not
make scan requests to advertising devices. If on it will make the advertising
requests.

It will use a random address if supported by the controller. The length of time
"discoverable on" is valid is determined by discoverable-timeout command.

:Usage: **> discoverable <on/off>**

discoverable-timeout
--------------------

Set discoverable timeout.

The time in seconds that "discoverable on" is valid.

:Usage: **> discoverable-timeout [value]**

agent
-----

Enable/disable agent with given capability.

This chooses the local authentication mechanism of the controller. It is needed
for pairing and allows you to choose the IO capabilities of the controller.

The valid agent capabilities are: DisplayOnly, DisplayYesNo, KeyboardDisplay,
KeyboardOnly, NoInputNoOutput.

:Usage: **> agent <on/off/capability>**

default-agent
-------------

Set current agent as the default one.

After selecting the agent this will make it the default agent.

:Usage: **> default-agent**

trust
-----

Trust device.

:Usage: **> trust <dev>**

untrust
-------

Untrust device.

:Usage: **> untrust <dev>**

block
-----

Block device.

:Usage: **> block <dev>**

unblock
-------
Unblock device

:Usage: **> unblock <dev>**

remove
------

Remove device.

:Usage: **> remove <dev>**

connect
-------

Connect device.

This will initiate a connection to a device.

By default this commands tries to connect all the profiles the remote device
supports and have been flagged as auto-connectable. In case when the UUID of
the remote service is given only that service will be connected. The UUID can
be either a short form (16-bit UUID) or a long form (128-bit UUID). There are
also some special values for well-known profiles like "a2dp-sink",
"a2dp-source", "hfp-hf", "hfp-ag", "ftp" or "spp".

To connect with an LE device the controller must have an active scan report of
the device it wants to connect to.

If no advertising report is received before the timeout a
le-connection-abort-by-local error will be issued. In that case either try
again to connect assuming the device is advertising.

:Usage: **> connect <dev> [uuid]**
:Example: **> connect 1C:48:F9:9D:81:5C**
:Example: **> connect 1C:48:F9:9D:81:5C hsp-hs**
:Example: **> connect 1C:48:F9:9D:81:5C 00001108-0000-1000-8000-00805f9b34fb**
:Example: **> connect 1C:48:F9:9D:81:5C 0x1108**

disconnect
----------

Disconnect device.

By default this commands disconnects all profiles and then terminates the
connection. In case when the UUID of the remote service is given only that
service will be disconnected.

For LE when disconnecting from an active connection the device address is not
needed.

:Usage: **> disconnect <dev> [uuid]**

info
----

Device information.

:Usage: **> info <dev>**

bearer
------

Get/Set preferred bearer.

:Usage: **> bearer <dev> [last-seen/bredr/le]**
:Example get preferred bearer:
	| > bearer <addr>
        |    PreferredBearer: last-seen
:Example set preferred bearer to LE:
	| > bearer <addr> le
	| [CHG] Device <addr> PreferredBearer: le
	| Changing le succeeded
:Example set preferred bearer to BREDR:
	| > bearer <addr> bredr
	| [CHG] Device <addr> PreferredBearer: bredr
	| Changing bredr succeeded

Advertise Submenu
=================

See **bluetoothctl-advertise(1)**.

Monitor Submenu
===============

See **bluetoothctl-monitor(1)**

Scan Submenu
============

See **bluetoothctl-scan(1)**

Gatt Submenu
============

See **bluetoothctl-gatt(1)**

Admin Submenu
=============

See **bluetoothctl-admin(1)**

Player Submenu
==============

See **bluetoothctl-player(1)**

Endpoint Submenu
================

See **bluetoothctl-endpoint(1)**

Transport Submenu
=================

See **bluetoothctl-transport(1)**

Management Submenu
==================

See **bluetoothctl-mgmt(1)**

Assistant Submenu
==================

See **bluetoothctl-assistant(1)**

AUTOMATION
==========
Two common ways to automate the tool are to use Here Docs or the program expect.
Using Here Docs to show information about the Bluetooth controller.

.. code::

   bluetoothctl <<EOF
   list
   show
   EOF


RESOURCES
=========

http://www.bluez.org

REPORTING BUGS
==============

linux-bluetooth@vger.kernel.org