Ubuntu Server : Bluetooth 설정.

우분투 서버, 즉 CLI 환경에서 블루투스를 설정하는 방법을 정리해본다.

먼저 bluez 를 설치한다.

sudo apt install bluez

다시 한번, ArchiLinux 팀의 도움을 받아, Bluetooth Control 을 사용하여 설정한다.
아치리눅스 문서에 있는 내용을 그대로 옮겨왔다.

  1. (optional) Select a default controller with select MAC_address.
  2. Enter power on to turn the power to the controller on. It is off by default and will turn off again each reboot, see #Auto power-on after boot.
  3. Enter devices to get the MAC Address of the device with which to pair.
  4. Enter device discovery mode with scan on command if device is not yet on the list.
  5. Turn the agent on with agent on or choose a specific agent: if you press tab twice after agent you should see a list of available agents, e.g. DisplayOnly KeyboardDisplay NoInputNoOutput DisplayYesNo KeyboardOnly off on.
  6. Enter pair MAC_address to do the pairing (tab completion works).
  7. If using a device without a PIN, one may need to manually trust the device before it can reconnect successfully. Enter trust MAC_address to do so.
  8. Enter connect MAC_address to establish a connection.
sudo bluetoothctl
[NEW] Controller D0:C6:37:06:68:5E lattedel [default]
[NEW] Device 34:88:5D:98:6E:8F Keyboard K380
Agent registered

[bluetooth]# default-agent
Default agent request successful

[bluetooth]# power on
Changing power on succeeded
[CHG] Controller 00:10:20:30:40:50 Powered: yes

[bluetooth]# scan on
Discovery started
[CHG] Controller 00:10:20:30:40:50 Discovering: yes
[NEW] Device 00:12:34:56:78:90 myLino
[CHG] Device 00:12:34:56:78:90 LegacyPairing: yes

[bluetooth]# pair 00:12:34:56:78:90
Attempting to pair with 00:12:34:56:78:90
[CHG] Device 00:12:34:56:78:90 Connected: yes
[agent] Passkey: 766836
[agent] Passkey: 766836
[agent] Passkey: 766836
[agent] Passkey: 766836
[agent] Passkey: 766836
[agent] Passkey: 766836
[agent] Passkey: 766836

# 위 숫자를 차례대로 입력하고, 끝에 엔터를 넣어줘야 제대로 작동하는 듯 하다.
....
[CHG] Device 00:12:34:56:78:90 Paired: yes
Pairing successful
[CHG] Device 00:12:34:56:78:90 Connected: no

[bluetooth]# connect 00:12:34:56:78:90
Attempting to connect to 00:12:34:56:78:90
[CHG] Device 00:12:34:56:78:90 Connected: yes
Connection successful

[Keyboard ABCD]# trust
[CHG] Device [Keyboard ABCD]# trust
[CHG] Device 00:12:34:56:78:90 Trusted: yes
Changing (null) trust succeeded

위 내용대로 따라하면 블루투스 키보드(아직 마우스는 해보지 않았다.)를 사용할 수 있다. 물론, 부팅이 되고 난 뒤 로그인 화면(Console 화면)부터 사용가능하다. (펌웨어 단계에선 USB 키보드가 필요하다.)

다만, 확실하지 않은 부분은 trust 다. 위 문서에는 trust 를 먼저하고 connect 를 하라고는 되어 있는데, 순서는 관계가 없어보인다.

내 경우, trust 를 하지 않으면 재부팅하고 난 뒤 자동접속이 되질 않았다. (이 부분에도 오류가 있을런지 모른다. 자동 접속이 정말 안된건지, 아니면 내가 성급해서 제대로 확인하지 못한 건지.)

아무튼, 기본 설정은 위와 같다.
이렇게 해놓으면, 나중에 GUI 를 실행해도 블루투스 키보드가 잘 작동한다.
(Bluetooth 오디오를 사용하려면, 아마도 추가 모듈이 필요할 듯 한데.. 거기까진 아직 불필요하기에 더 이상은 파고 들지 않았다.)

Author: 아무도안

안녕하세요. 글 남겨주셔서 고맙습니다.