TEXT   53

Bluetooth Connections

Guest on 13th May 2022 01:59:20 AM

  1. ~~~~~~~~~~~~~~~~~~~~~
  2. Bluetooth Connections
  3. ~~~~~~~~~~~~~~~~~~~~~
  5. .. include:: prologue.rst
  7. Pairing a Bluetooth Device
  8. ==========================
  10. You need to "pair" your device with the host on which you wish to use it. You
  11. can pair a device with more than one host, but you can usually only use it with
  12. one host at a time.
  14. On Linux
  15. --------
  17. Pairing a Bluetooth device on Linux is relatively easy if you're comfortable
  18. working within the graphical (X) environment. All you need to do is to run
  19. ``bluetooth-applet`` and follow the steps it presents to you. It's a little
  20. trickier to pair a Bluetooth device via the command line, but it can be done.
  21. How to do it depends on the version of the Bluetooth software stack that you're
  22. using.
  24. For Bluetooth Version 5
  25. ~~~~~~~~~~~~~~~~~~~~~~~
  27. As of Bluetooth version 5, all required actions for pairing a device via the
  28. command-line can be performed with a single tool called ``bluetoothctl``.
  30. First, in case you have several Bluetooth controllers in use (uncommon, but
  31. possible), you need to make sure that the correct one is currently selected.
  32. Use the ``list`` command to show all available controllers, and the
  33. ``select <host-address>`` command to select one:
  35. .. code-block:: console
  37.    # bluetoothctl
  38.    [bluetooth]# list
  39.    Controller 01:23:45:67:89:AB fzidpc73
  40.    [bluetooth]# select 01:23:45:67:89:AB
  42. It can happen that the selected controller is not powered on at the moment.
  43. Make sure it is, and, if it isn't, use the ``power on`` command to enable the
  44. controller:
  46. .. code-block:: console
  48.    [bluetooth]# show
  49.    Controller 01:23:45:67:89:AB
  50.            Name: fzidpc73
  51.            Alias: fzidpc73-0
  52.            Class: 0x000000
  53.            Powered: no
  54.            Discoverable: no
  55.            Pairable: yes
  56.            UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
  57.            UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
  58.            UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
  59.            UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
  60.            UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
  61.            Modalias: usb:v1D6Bp0246d0517
  62.            Discovering: no
  63.    [bluetooth]# power on
  64.    [CHG] Controller 01:23:45:67:89:AB Class: 0x000104
  65.    Changing power on succeeded
  66.    [CHG] Controller 01:23:45:67:89:AB Powered: yes
  68. To obtain the Bluetooth device address of the device you want to pair with,
  69. enable scan mode:
  71. .. code-block:: console
  73.    [bluetooth]# scan on
  74.    Discovery started
  75.    [CHG] Controller 01:23:45:67:89:AB Discovering: yes
  76.    [NEW] Device 12:34:56:78:9A:BC braillex live 0139
  77.    [bluetooth]# scan off
  78.    Discovery stopped
  79.    [CHG] Controller 01:23:45:67:89:AB Discovering: no
  81. To be able to receive PIN code requests directly on the console, you need to
  82. enable the *agent*:
  84. .. code-block:: console
  86.    [bluetooth]# agent on
  87.    Agent registered
  89. Now you are finally ready to initiate the pairing:
  91. .. code-block:: console
  93.    [bluetooth]# pair 12:34:56:78:9A:BC
  94.    Attempting to pair with 12:34:56:78:9A:BC
  95.    [CHG] Device 12:34:56:78:9A:BC Connected: yes
  96.    Request PIN code
  97.    [agent] Enter PIN code: 1234
  98.    [CHG] Device 12:34:56:78:9A:BC UUIDs:
  99.            00001101-0000-1000-8000-00805f9b34fb
  100.    [CHG] Device 12:34:56:78:9A:BC Paired: yes
  101.    Pairing successful
  102.    [CHG] Device 12:34:56:78:9A:BC Connected: no
  104. For Bluetooth Version 4
  105. ~~~~~~~~~~~~~~~~~~~~~~~
  107. You need to find out your host's Bluetooth Device Address (referred to later in
  108. this document as *host-address*). To do this, run the command::
  110.    hciconfig hci0
  112. Look for the (indented) line which begins with ``BD Address:``. The very next
  113. "word" on that line is your host's Bluetooth Device Address. It'll be six
  114. two-digit hexadecimal numbers separated by colons (``:``). Examples in this
  115. document use the value ``01:23:45:67:89:AB``.
  117. You need to find out your device's Bluetooth Device Address (referred to later
  118. in this document as *device-address*). To do this, run the command::
  120.    hcitool scan
  122. This command can take a while to complete as it gives devices a fair bit of
  123. time to respond. Each device which responds creates one two-column output line.
  124. The first column is its Bluetooth Device Address (examples in this document use
  125. the value ``12:34:56:78:9A:BC``), and the second column is its
  126. current name. Manufacturers usually set a device's initial name to its product
  127. name and model number so that it's easy to spot within the scan output. If your
  128. device allows you to change its name, it's okay to do so even after you've
  129. paired it.
  131. A device needs to be "visible" in order for the scan to find it. Most devices
  132. are "invisible" by default, but have a way to be made temporarily visible. You
  133. should check your device's manual to find out how to do this. In many cases,
  134. there's either a button which needs to be pressed or a menu item which needs to
  135. be selected. Since both the device's temporary visibility and the host's scan
  136. time out, make your device visible just before you initiate the scan.
  138. You need to know what PIN (password) your device is expecting. Your device's
  139. documentation should contain this information. Many devices allow you to set
  140. the PIN, in which case they'll have a menu which allows you to do this.
  141. Examples in this document use the value ``1234``.
  143. Go into the directory ``/var/lib/bluetooth/<host-address>``. In there (create
  144. if necessary) is the file ``pincodes``. Each line in this file associates a
  145. device with its PIN. It has two fields separated by space. The first field is
  146. the device's Bluetooth Device Address and the second field is its PIN. The
  147. Bluetooth Device Address must be in uppercase. For example::
  149.    cat /var/lib/bluetooth/01:23:45:67:89:AB/pincodes
  150.    12:34:56:78:9A:BC 1234
  153. Using a Bluetooth Device with BRLTTY
  154. ====================================
  156. After your device has been paired with your host, it's ready to be used by
  157. BRLTTY.
  159. Identifying the Device
  160. ----------------------
  162. You can tell BRLTTY to use your Bluetooth device either via the ``-d``
  163. (or ``--braille-device=``) command line option, or via the ``braille-device``
  164. line in the file ``/etc/brltty.conf``. The device should be specified as the
  165. word ``bluetooth``, a colon (``:``), and the device's Bluetooth Device Address.
  166. For example::
  168.    brltty -d bluetooth:12:34:56:78:9A:BC
  170. or::
  172.    cat /etc/brltty.conf
  173.    braille-device bluetooth:12:34:56:78:9A:BC
  175. On some platforms,
  176. BRLTTY supports the detection of a Bluetooth device based on its name.
  177. These platforms include:
  179. * Android
  180. * Linux (if the Bluetooth version is at least 5)
  181. * Windows
  183. The address of the device needn't be specified on these platforms -
  184. specifying just ``bluetooth:`` is sufficient.
  185. BRLTTY will find the braille device based on its name.
  186. It'll only consider devices that have already been paired with the host.
  188. If two (or more) braille devices are paired with your host,
  189. and if both of them are near by, turned on, and configured for Bluetooth access,
  190. then, of course, BRLTTY might choose the wrong one.
  191. As long as both of them don't have the same Bluetooth name,
  192. you can still specify the intended device without knowing its address.
  193. You can limit the devices that BRLTTY will consider
  194. by specifying the beginning of its Bluetooth name::
  196.    bluetooth:name=prefix
  198. If you need to specify a space within the prefix, then:
  200. * On the command line, use quotes::
  202.     -d "bluetooth:name=braille device"
  204. * In ``/etc/brltty.conf``, use \\s::
  206.     braille-device bluetooth:name=braille\sdevice

Raw Paste

Login or Register to edit or fork this paste. It's free.