linux-bluetooth-console

linux 下如何使用蓝牙console

本文基于Arch linux.

安装基础软件

1
sudo pacman -S bluez bluez-utils-compat

配对

  • 注意,由于 BLE_SPP 无法完成连接,因此只达到可连接状态即可

即状态如下即可

img

1
2
3
4
5
6
7
8
9
10
# 命令行方式
# systemctl start bluetooth
# bluetoothctl
Agent registered
[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# scan on
... wait ...
[bluetooth]# scan off
[bluetooth]# pair <dev-mac>

创建虚拟串口

1
rfcomm bind 0 <dev-mac>

ls /dev/rfcomm0 可看到虚拟console设备

连接虚拟console 口

  • 使用虚拟终端软件 minicom 连接虚拟终端 /dev/rfcomm0

    1
    $ minicom -s #设置各项参数,串行设备,比特率等 进行连接
  • 也可使用支持串口的终端,eg: tabby

效果