文章目录
- Kernel 部分支持
- 配置 menuconfig
- WiFi 功能支持
- Bluetooth 功能支持
- 原SDK的Busybox配置
- BT 部分
- 文件系统部分
- 蓝牙测试
- dbus 安装测试遇到的问题
- 让`hci0`出来
- 使用hcitool来操作
Kernel 部分支持
配置 menuconfig
WiFi 功能支持
Bluetooth 功能支持
正基和海华的模块都使用内核的默认 CONFIG_BT_HCIUART
驱动,而Realtek使用自己的hci uart驱动,源码目录为: external\rkwifibt\realtek\bluetooth_uart_driver
, 且使用ko方式加载,所以使用Realtek时一定要把内核的CONFIG_BT_HCIUART
配置去掉!如下图,不要选上!!!
原SDK的Busybox配置
增加rfkill
的支持
BT 部分
需要一个文件夹:rkwifibt-1.0.0 (我从RV1126的SDK里面找到的)
# insmod hci_uart.ko
[ 242.292615] Bluetooth: HCI UART driver ver 2.2.74e8f89.20210423-153941
[ 242.292# 653] Bluetooth: HCI H4 protocol initialized
[ 242.292662] Bluetooth: HCI Realtek H5 protocol initialized
[ 242.292669] rtk_btcoex: rtk_btcoex_init: version: 1.2
[ 242.292676] rtk_btcoex: create workqueue
[ 242.292894] rtk_btcoex: alloc buffers 1408, 2240 for ev and l2
# ./rtk_hciattach -n -s 115200 /dev/ttyS5 rtk_h5
Realtek Bluetooth init uart with init speed:115200, final_speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 2.5Realtek Bluetooth :3-wire sync pattern resend : 1, len: 8Realtek Bluetooth :Get SYNC Resp PktRealtek Bluetooth :Get SYNC pkt-active modeRealtek Bluetooth :3-wire config pattern resend : 1 , len: 10
Realtek Bluetooth :Get CONFG pkt-active modeRealtek Bluetooth :Get CONFG resp pkt-active modeRealtek Bluetooth :H5 init finishedRealtek Bluetooth :config offset(f4),length(8)
Realtek Bluetooth :config baud rate to :4928002, hwflowcontrol:5f, 1
Realtek Bluetooth :config offset(27),length(1)
Realtek Bluetooth :config offset(fe),length(1)
Realtek Bluetooth :config offset(15b),length(4)
Realtek Bluetooth :config offset(1e3),length(1)
Realtek Bluetooth :Get config baud rate from config file:4928002
Realtek Bluetooth :Load FW OK
Realtek Bluetooth :RTK send HCI_VENDOR_READ_RTK_ROM_VERISION_CommandRealtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :receive hci command complete event with command:1001Realtek Bluetooth :Read RTK LMP version with Status:0
Realtek Bluetooth :gLmpVersion = 0x8723
Realtek Bluetooth :RTK send HCI_VENDOR_READ_RTK_ROM_VERISION_CommandRealtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :receive hci command complete event with command:fc6dRealtek Bluetooth :Read RTK rom version with Status:0
Realtek Bluetooth :rtk_hw_cfg.eversion = 1
Realtek Bluetooth :rtk_get_fw_project_id: opcode 0, len 1, data 1
Realtek Bluetooth :fw_ver 0x1e3ee40e, patch_num 2
Realtek Bluetooth :patch length is 0x5e90
Realtek Bluetooth :start offset is 0x4f00
Realtek Bluetooth :fw: exists, config file: exists
Realtek Bluetooth :baudrate in change speed command: 0x2 0x80 0x92 0x4
....Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 99Realtek Bluetooth :Send FW last command
Realtek Bluetooth :hci_download_patch tx_index:100 rx_index: 99Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 100Realtek Bluetooth :Init Process finished
[ 267.653151] Bluetooth: h5_Realtek Bluetooth post process
Device setup complete
open
[ 267.653191] Bluetooth: hci_uart_register_dev
[ 267.660539] rtk_btcoex: Open BTCOEX
[ 267.663640] rtk_btcoex: BTCOEX hci_rev 0x1e3e
[ 267.663669] rtk_btcoex: BTCOEX lmp_subver 0xe40e
[ 269.707229] Bluetooth: __hci_uart_flush: hdev 27dbab53 tty 71c11fc3
[ 269.707306] Bluetooth: hci_uart_close: hdev 27dbab53
[ 269.707332] Bluetooth: __hci_uart_flush: hdev 27dbab53 tty 71c11fc3
[ 269.707354] rtk_btcoex: Close BTCOEX
[ 269.707372] rtk_btcoex: -x
[ 335.605060] RTL8723BS: rtw_set_802_11_connect(wlan0) fw_state = 0x00000008
文件系统部分
需要借助buildroot来构建一些蓝牙相关的软件例如:bluez5
我尝试了手动交叉编译这些软件,卡在了bluez5这里已经花费我20h。而借用Buildroot只花费了2h。
xxxx_defconfig
BR2_arm=y
BR2_cortex_a7=y
BR2_ARM_FPU_NEON_VFPV4=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_PATH="/home/liefyuan/luckfox-pico-main/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-rockchip830-linux-uclibcgnueabihf"
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
BR2_TOOLCHAIN_EXTERNAL_WCHAR=y
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
# BR2_TARGET_ENABLE_ROOT_LOGIN is not set
BR2_SYSTEM_BIN_SH_NONE=y
BR2_SYSTEM_ENABLE_NLS=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_DBUS_CPP=y
BR2_PACKAGE_DBUS_TRIGGERD=y
BR2_PACKAGE_BLUEZ_TOOLS=y
BR2_PACKAGE_BLUEZ5_UTILS=y
BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y
BR2_PACKAGE_BLUEZ5_UTILS_TOOLS=y
BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y
BR2_PACKAGE_BLUEZ5_UTILS_EXPERIMENTAL=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_UTIL_LINUX=y
我的Buildroot版本是:Buildroot-2023.02.06
上面的配置出来的文件系统非常干净,看一下(make graph-depends
)依赖图
大概只有12MB左右。
蓝牙测试
dbus 安装测试遇到的问题
使用dbus-daemon --system --print-pid --print-address
命令来启动dbus后台程序为了和蓝牙通讯。
# dbus-daemon --system --print-pid --print-address
dbus-daemon[469]: Failed to start message bus: Failed to bind socket "/run/dbus/system_bus_socket": No such file or directory
需要创建目录/run/dbus
# mkdir -p /run/dbus
# dbus-daemon --system --print-pid --print-address
unix:path=/run/dbus/system_bus_socket,guid=6973ec2014fa0880afbdcae3000000b1
dbus-daemon[461]: Failed to start message bus: Could not get UID and GID for username "dbus"
需要创建一个用户名叫dbus
,密码不需要,我文件系统里面没有adduser命令,所以只能在/etc/passwd文件里面最后添加:
dbus:0:0:0:::
然后就可以正常了。如下
# dbus-daemon --system --print-pid --print-address
unix:path=/run/dbus/system_bus_socket,guid=8e19ed4e6e585e498d7c956c0000046a
474
让hci0
出来
安装.ko:insmod hci_uart.ko
# insmod hci_uart.ko
[ 32.387318] Bluetooth: HCI UART driver ver 2.2.74e8f89.20210423-153941
[ 32.38734# 9] Bluetooth: HCI H4 protocol initialized
[ 32.387356] Bluetooth: HCI Realtek H5 protocol initialized
[ 32.387363] rtk_btcoex: rtk_btcoex_init: version: 1.2
[ 32.387369] rtk_btcoex: create workqueue
[ 32.387582] rtk_btcoex: alloc buffers 1408, 2240 for ev and l2
运行:./rtk_hciattach -n -s 115200 ttyS5 rtk_h5 &
# ./rtk_hciattach -n -s 115200 ttyS5 rtk_h5 &
# [ 46.923577] of_dma_request_slave_channel: dma-names property of node Realtek Bluetooth init uart with i'/nit speed:115200,115200, type:HCI UART H5
seriRealtek Bluetooth :Realtek hciattach version 2.5al@ff4f0000' misRealtek Bluetooth :3-wire sync pattern resend : 1, len: 8Realtek Bluetooth :Get SYNC Resp PktRealtek Bluetooth :Get SYNC pkt-active modeRealtek Bluetooth :3-wire config pattern resend : 1 , len: 10
Realtek Bluetooth :Get CONFG pkt-active modeRealtek Bluetooth :Get CONFG resp pkt-active modesing Realtek Bluetooth :H5 init finishedor empty
[ Realtek Bluetooth :config offset(f4),length(8)
Realtek Bluetooth :config baud rate to :4928002, hwflowcontrol:5f, 1
Realtek Bluetooth :config offset(27),length(1)
Realtek Bluetooth :config offset(fe),length(1)
Realtek Bluetooth :config offset(15b),length(4)
Realtek Bluetooth :config offset(1e3),length(1)
Realtek Bluetooth :Get config baud rate from config file:492800246.923698] dw-apb-uart ff4f0000.serial: failed to request DMA, use Realtek Bluetooth :Load FW OK
Realtek Bluetooth :RTK send HCI_VENDOR_READ_RTK_ROM_VERISION_CommandRealtek Bluetooth :Received reliaible seqno 0 from card
Realtek Bluetooth :receive hci command complete event with command:1001Realtek Bluetooth :Read RTK LMP version with Status:0
nterrupt mode
Realtek Bluetooth :gLmpVersion = 0x8723
Realtek Bluetooth :RTK send HCI_VENDOR_READ_RTK_ROM_VERISION_CommandRealtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :receive hci command complete event with command:fc6dRealtek Bluetooth :Read RTK rom version with Status:0
Realtek Bluetooth :rtk_hw_cfg.eversion = 1
Realtek Bluetooth :rtk_get_fw_project_id: opcode 0, len 1, data 1
Realtek Bluetooth :fw_ver 0x1e3ee40e, patch_num 2
Realtek Bluetooth :patch length is 0x5e90
Realtek Bluetooth :start offset is 0x4f00
Realtek Bluetooth :fw: exists, config file: exists
Realtek Bluetooth :baudrate in change speed command: 0x2 0x80 0x92 0x4Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :receive hci command complete event with command:fc17Realtek Bluetooth :Change BD Rate with status:0
Realtek Bluetooth :final_speed 1500000Realtek Bluetooth :hw flow control enable
Realtek Bluetooth :iEndIndex:96 iLastPacketLen:71 iAdditionpkt:4Realtek Bluetooth :hci_download_patch tx_index:0 rx_index: -1Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 0Realtek Bluetooth :hci_download_patch tx_index:1 rx_index: 0Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 1Realtek Bluetooth :hci_download_patch tx_index:2 rx_index: 1Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 2Realtek Bluetooth :hci_download_patch tx_index:3 rx_index: 2Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 3Realtek Bluetooth :hci_download_patch tx_index:4 rx_index: 3Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 4Realtek Bluetooth :hci_download_patch tx_index:5 rx_index: 4Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 5Realtek Bluetooth :hci_download_patch tx_index:6 rx_index: 5Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 6Realtek Bluetooth :hci_download_patch tx_index:7 rx_index: 6Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 7Realtek Bluetooth :hci_download_patch tx_index:8 rx_index: 7Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 8Realtek Bluetooth :hci_download_patch tx_index:9 rx_index: 8Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 9Realtek Bluetooth :hci_download_patch tx_index:10 rx_index: 9Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 10Realtek Bluetooth :hci_download_patch tx_index:11 rx_index: 10Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 11Realtek Bluetooth :hci_download_patch tx_index:12 rx_index: 11Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 12Realtek Bluetooth :hci_download_patch tx_index:13 rx_index: 12Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 13Realtek Bluetooth :hci_download_patch tx_index:14 rx_index: 13Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 14Realtek Bluetooth :hci_download_patch tx_index:15 rx_index: 14Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 15Realtek Bluetooth :hci_download_patch tx_index:16 rx_index: 15Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 16Realtek Bluetooth :hci_download_patch tx_index:17 rx_index: 16Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 17Realtek Bluetooth :hci_download_patch tx_index:18 rx_index: 17Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 18Realtek Bluetooth :hci_download_patch tx_index:19 rx_index: 18Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 19Realtek Bluetooth :hci_download_patch tx_index:20 rx_index: 19Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 20Realtek Bluetooth :hci_download_patch tx_index:21 rx_index: 20Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 21Realtek Bluetooth :hci_download_patch tx_index:22 rx_index: 21Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 22Realtek Bluetooth :hci_download_patch tx_index:23 rx_index: 22Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 23Realtek Bluetooth :hci_download_patch tx_index:24 rx_index: 23Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 24Realtek Bluetooth :hci_download_patch tx_index:25 rx_index: 24Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 25Realtek Bluetooth :hci_download_patch tx_index:26 rx_index: 25Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 26Realtek Bluetooth :hci_download_patch tx_index:27 rx_index: 26Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 27Realtek Bluetooth :hci_download_patch tx_index:28 rx_index: 27Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 28Realtek Bluetooth :hci_download_patch tx_index:29 rx_index: 28Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 29Realtek Bluetooth :hci_download_patch tx_index:30 rx_index: 29Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 30Realtek Bluetooth :hci_download_patch tx_index:31 rx_index: 30Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 31Realtek Bluetooth :hci_download_patch tx_index:32 rx_index: 31Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 32Realtek Bluetooth :hci_download_patch tx_index:33 rx_index: 32Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 33Realtek Bluetooth :hci_download_patch tx_index:34 rx_index: 33Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 34Realtek Bluetooth :hci_download_patch tx_index:35 rx_index: 34Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 35Realtek Bluetooth :hci_download_patch tx_index:36 rx_index: 35Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 36Realtek Bluetooth :hci_download_patch tx_index:37 rx_index: 36Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 37Realtek Bluetooth :hci_download_patch tx_index:38 rx_index: 37Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 38Realtek Bluetooth :hci_download_patch tx_index:39 rx_index: 38Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 39Realtek Bluetooth :hci_download_patch tx_index:40 rx_index: 39Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 40Realtek Bluetooth :hci_download_patch tx_index:41 rx_index: 40Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 41Realtek Bluetooth :hci_download_patch tx_index:42 rx_index: 41Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 42Realtek Bluetooth :hci_download_patch tx_index:43 rx_index: 42Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 43Realtek Bluetooth :hci_download_patch tx_index:44 rx_index: 43Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 44Realtek Bluetooth :hci_download_patch tx_index:45 rx_index: 44Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 45Realtek Bluetooth :hci_download_patch tx_index:46 rx_index: 45Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 46Realtek Bluetooth :hci_download_patch tx_index:47 rx_index: 46Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 47Realtek Bluetooth :hci_download_patch tx_index:48 rx_index: 47Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 48Realtek Bluetooth :hci_download_patch tx_index:49 rx_index: 48Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 49Realtek Bluetooth :hci_download_patch tx_index:50 rx_index: 49Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 50Realtek Bluetooth :hci_download_patch tx_index:51 rx_index: 50Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 51Realtek Bluetooth :hci_download_patch tx_index:52 rx_index: 51Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 52Realtek Bluetooth :hci_download_patch tx_index:53 rx_index: 52Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 53Realtek Bluetooth :hci_download_patch tx_index:54 rx_index: 53Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 54Realtek Bluetooth :hci_download_patch tx_index:55 rx_index: 54Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 55Realtek Bluetooth :hci_download_patch tx_index:56 rx_index: 55Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 56Realtek Bluetooth :hci_download_patch tx_index:57 rx_index: 56Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 57Realtek Bluetooth :hci_download_patch tx_index:58 rx_index: 57Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 58Realtek Bluetooth :hci_download_patch tx_index:59 rx_index: 58Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 59Realtek Bluetooth :hci_download_patch tx_index:60 rx_index: 59Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 60Realtek Bluetooth :hci_download_patch tx_index:61 rx_index: 60Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 61Realtek Bluetooth :hci_download_patch tx_index:62 rx_index: 61Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 62Realtek Bluetooth :hci_download_patch tx_index:63 rx_index: 62Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 63Realtek Bluetooth :hci_download_patch tx_index:64 rx_index: 63Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 64Realtek Bluetooth :hci_download_patch tx_index:65 rx_index: 64Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 65Realtek Bluetooth :hci_download_patch tx_index:66 rx_index: 65Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 66Realtek Bluetooth :hci_download_patch tx_index:67 rx_index: 66Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 67Realtek Bluetooth :hci_download_patch tx_index:68 rx_index: 67Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 68Realtek Bluetooth :hci_download_patch tx_index:69 rx_index: 68Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 69Realtek Bluetooth :hci_download_patch tx_index:70 rx_index: 69Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 70Realtek Bluetooth :hci_download_patch tx_index:71 rx_index: 70Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 71Realtek Bluetooth :hci_download_patch tx_index:72 rx_index: 71Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 72Realtek Bluetooth :hci_download_patch tx_index:73 rx_index: 72Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 73Realtek Bluetooth :hci_download_patch tx_index:74 rx_index: 73Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 74Realtek Bluetooth :hci_download_patch tx_index:75 rx_index: 74Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 75Realtek Bluetooth :hci_download_patch tx_index:76 rx_index: 75Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 76Realtek Bluetooth :hci_download_patch tx_index:77 rx_index: 76Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 77Realtek Bluetooth :hci_download_patch tx_index:78 rx_index: 77Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 78Realtek Bluetooth :hci_download_patch tx_index:79 rx_index: 78Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 79Realtek Bluetooth :hci_download_patch tx_index:80 rx_index: 79Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 80Realtek Bluetooth :hci_download_patch tx_index:81 rx_index: 80Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 81Realtek Bluetooth :hci_download_patch tx_index:82 rx_index: 81Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 82Realtek Bluetooth :hci_download_patch tx_index:83 rx_index: 82Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 83Realtek Bluetooth :hci_download_patch tx_index:84 rx_index: 83Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 84Realtek Bluetooth :hci_download_patch tx_index:85 rx_index: 84Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 85Realtek Bluetooth :hci_download_patch tx_index:86 rx_index: 85Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 86Realtek Bluetooth :hci_download_patch tx_index:87 rx_index: 86Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 87Realtek Bluetooth :hci_download_patch tx_index:88 rx_index: 87Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 88Realtek Bluetooth :hci_download_patch tx_index:89 rx_index: 88Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 89Realtek Bluetooth :hci_download_patch tx_index:90 rx_index: 89Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 90Realtek Bluetooth :hci_download_patch tx_index:91 rx_index: 90Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 91Realtek Bluetooth :hci_download_patch tx_index:92 rx_index: 91Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 92Realtek Bluetooth :hci_download_patch tx_index:93 rx_index: 92Realtek Bluetooth :Received reliable seqno 0 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 93Realtek Bluetooth :hci_download_patch tx_index:94 rx_index: 93Realtek Bluetooth :Received reliable seqno 1 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 94Realtek Bluetooth :hci_download_patch tx_index:95 rx_index: 94Realtek Bluetooth :Received reliable seqno 2 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 95Realtek Bluetooth :hci_download_patch tx_index:96 rx_index: 95Realtek Bluetooth :Received reliable seqno 3 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 96Realtek Bluetooth :hci_download_patch tx_index:97 rx_index: 96Realtek Bluetooth :Received reliable seqno 4 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 97Realtek Bluetooth :hci_download_patch tx_index:98 rx_index: 97Realtek Bluetooth :Received reliable seqno 5 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 98Realtek Bluetooth :hci_download_patch tx_index:99 rx_index: 98Realtek Bluetooth :Received reliable seqno 6 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 99Realtek Bluetooth :Send FW last command
Realtek Bluetooth :hci_download_patch tx_index:100 rx_index: 99Realtek Bluetooth :Received reliable seqno 7 from card
Realtek Bluetooth :rtk_hw_cfg.rx_index 100Realtek Bluetooth :Init Process finished
[ 48.864039] Bluetooth: h5_open
Realtek Bluetooth post process
Device setup com[ 48.864091] Bluetopleteot
h: hci_uart_register_dev
[ 48.871291] rtk_btcoex: Open BTCOEX
[ 48.875794] rtk_btcoex: BTCOEX hci_rev 0x1e3e
[ 48.875815] rtk_btcoex: BTCOEX lmp_subver 0xe40e
[ 51.040637] Bluetooth: __hci_uart_flush: hdev 5ae14a4f tty 8bc69d32
[ 51.040720] Bluetooth: hci_uart_close: hdev 5ae14a4f
[ 51.040747] Bluetooth: __hci_uart_flush: hdev 5ae14a4f tty 8bc69d32
[ 51.040767] rtk_btcoex: Close BTCOEX
[ 51.040786] rtk_btcoex: -x
使用命令:hciconfig
# hciconfig
hci0: Type: Primary Bus: UARTBD Address: 84:20:96:B1:4D:92 ACL MTU: 1021:8 SCO MTU: 255:16DOWNRX bytes:1057 acl:0 sco:0 events:30 errors:0TX bytes:827 acl:0 sco:0 commands:30 errors:0
打开hci0
使用命令:hciconfig hci0 up
# hciconfig -a
hci0: Type: Primary Bus: UARTBD Address: 84:20:96:B1:4D:92 ACL MTU: 1021:8 SCO MTU: 255:16DOWNRX bytes:1057 acl:0 sco:0 events:30 errors:0TX bytes:827 acl:0 sco:0 commands:30 errors:0Features: 0xff 0xff 0xff 0xfe 0xdb 0xff 0x7b 0x87Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3Link policy: RSWITCH HOLD SNIFF PARKLink mode: PERIPHERAL ACCEPT# hciconfig hci0 up
[ 301.298323] rtk_btcoex: Open BTCOEX
[ 301.573864] Bluetooth: hu 8958aa1c retransmitting 1 pkts
[ 301.576198] rtk_btcoex: BTCOEX hci_rev 0x1e3e
[ 301.576224] rtk_btcoex: BTCOEX lmp_subver 0xe40e
# hciconfig
hci0: Type: Primary Bus: UARTBD Address: 84:20:96:B1:4D:92 ACL MTU: 1021:8 SCO MTU: 255:16DOWNRX bytes:1057 acl:0 sco:0 events:30 errors:0TX bytes:859 acl:0 sco:0 commands:30 errors:0# hciconfig hci0 up
[ 109.720402] rtk_btcoex: Open BTCOEX
[ 109.973975] Bluetooth: hu 8e040b96 retransmitting 1 pkts
[ 109.976315] rtk_btcoex: BTCOEX hci_rev 0x1e3e
[ 109.976346] rtk_btcoex: BTCOEX lmp_subver 0xe40e
# hciconfig
hci0: Type: Primary Bus: UARTBD Address: 84:20:96:B1:4D:92 ACL MTU: 1021:8 SCO MTU: 255:16UP RUNNINGRX bytes:2113 acl:0 sco:0 events:60 errors:0TX bytes:1518 acl:0 sco:0 commands:61 errors:0# hciconfig -a
hci0: Type: Primary Bus: UARTBD Address: 84:20:96:B1:4D:92 ACL MTU: 1021:8 SCO MTU: 255:16UP RUNNINGRX bytes:2113 acl:0 sco:0 events:60 errors:0TX bytes:1518 acl:0 sco:0 commands:61 errors:0Features: 0xff 0xff 0xff 0xfe 0xdb 0xff 0x7b 0x87Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3Link policy: RSWITCH HOLD SNIFF PARKLink mode: PERIPHERAL ACCEPT
[ 134.027303] Bluetooth: hu 8e040b96 retransmitting 1 pktsName: 'RTK_BT_4.0'Class: 0x000000Service Classes: UnspecifiedDevice Class: Miscellaneous,HCI Version: 4.0 (0x6) Revision: 0x1e3eLMP Version: 4.0 (0x6) Subversion: 0xe40eManufacturer: Realtek Semiconductor Corporation (93)# [ 134.037521] rtk_btcoex: BTCOEX hci_rev 0x1e3e
[ 134.037549] rtk_btcoex: BTCOEX lmp_subver 0xe40e
查看当前系统中全部的蓝牙设备信息:
hciconfig -a
开启指定名称的蓝牙设备:hciconfig hci0 up
关闭指定名称的蓝牙设备:hciconfig hci0 down
重置指定名称的蓝牙设备:hciconfig hci0 reset
打开dbus
# mkdir -p /run/dbus
# dbus-daemon --system --print-pid --print-address
unix:path=/run/dbus/system_bus_socket,guid=efd8f0def3b1d532a9e4538f000001a4
465
进入目录/usr/libexec/bluetooth/bluetoothd
运行命令:bluetoothd -n -d &
# cd /usr/libexec/bluetooth/
# ./bluetoothd -n -d &
# ./bluetoothd -n -d &
# bluetoothd[479]: Bluetooth daemon 5.65
bluetoothd[479]: src/adapter.c:adapter_init() sending read version command
bluetoothd[479]: Starting SDP server
bluetoothd[479]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:0541
bluetoothd[479]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[479]: src/plugin.c:add_plugin() Loading hostname plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading wiimote plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading autopair plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading policy plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading network plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading gap plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading scanparam plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading deviceinfo plugin
bluetoothd[479]: src/plugin.c:add_plugin() Loading battery plugin
bluetoothd[479]: src/plugin.c:plugin_init() Loading plugins /usr/lib/bluetooth/plugins
bluetoothd[479]: profiles/network/manager.c:read_config() Config options: Security=true
bluetoothd[479]: src/rfkill.c:rfkill_init() Failed to open RFKILL control device
bluetoothd[479]: src/main.c:main() Entering main loop
bluetoothd[479]: src/shared/mgmt.c:send_request() [0xffff] command 0x0001
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0xffff] command 0x0001 complete: 0x00
bluetoothd[479]: Bluetooth management interface 1.18 initialized
bluetoothd[479]: src/adapter.c:read_version_complete() sending read supported commands command
bluetoothd[479]: src/adapter.c:read_version_complete() sending read index list command
bluetoothd[479]: src/shared/mgmt.c:send_request() [0xffff] command 0x0002
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0xffff] command 0x0002 complete: 0x00
bluetoothd[479]: src/adapter.c:read_commands_complete() Number of commands: 79
bluetoothd[479]: src/adapter.c:read_commands_complete() Number of events: 40
bluetoothd[479]: src/adapter.c:read_commands_complete() enabling kernel-side connection control
bluetoothd[479]: src/adapter.c:read_commands_complete() kernel supports the set_blocked_keys op
bluetoothd[479]: src/adapter.c:read_commands_complete() kernel supports controller cap command
bluetoothd[479]: src/adapter.c:read_commands_complete() kernel supports exp features
bluetoothd[479]: src/adapter.c:read_commands_complete() kernel supports set system confic
bluetoothd[479]: src/adapter.c:read_commands_complete() kernel supports suspend/resume events
bluetoothd[479]: src/shared/mgmt.c:send_request() [0xffff] command 0x0003
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0xffff] command 0x0003 complete: 0x00
bluetoothd[479]: src/adapter.c:read_index_list_complete() Number of controllers: 1
bluetoothd[479]: src/adapter.c:read_index_list_complete() Found index 0
bluetoothd[479]: src/adapter.c:index_added() index 0
bluetoothd[479]: src/adapter.c:reset_adv_monitors() sending remove Adv Monitor command with handle 0
bluetoothd[479]: src/adapter.c:btd_adapter_new() System name: BlueZ 5.65
bluetoothd[479]: src/adapter.c:btd_adapter_new() Major class: 0
bluetoothd[479]: src/adapter.c:btd_adapter_new() Minor class: 0
bluetoothd[479]: src/adapter.c:btd_adapter_new() Modalias: usb:v1D6Bp0246d0541
bluetoothd[479]: src/adapter.c:btd_adapter_new() Discoverable timeout: 180 seconds
bluetoothd[479]: src/adapter.c:btd_adapter_new() Pairable timeout: 0 seconds
bluetoothd[479]: src/adapter.c:index_added() sending read info command for index 0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0053
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0053 complete: 0x00
bluetoothd[479]: src/adapter.c:reset_adv_monitors_complete() Removed all Adv Monitors
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0049
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0049 complete: 0x00
bluetoothd[479]: src/adapter.c:read_exp_features_complete() index 0 status 0x00
bluetoothd[479]: src/adapter.c:read_exp_features_complete() 671b10b5-42c0-4696-9227-eb28d1b049d6 flags 0 action 0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0004
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0004 complete: 0x00
bluetoothd[479]: src/adapter.c:read_info_complete() index 0 status 0x00
bluetoothd[479]: src/adapter.c:clear_uuids() sending clear uuids command for index 0
bluetoothd[479]: src/adapter.c:clear_devices() sending clear devices command for index 0
bluetoothd[479]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[479]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[479]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[479]: src/adapter.c:set_privacy() sending set privacy command for index 0
bluetoothd[479]: src/adapter.c:set_privacy() setting privacy mode 0x00 for index 0
bluetoothd[479]: src/gatt-database.c:btd_gatt_database_new() GATT Manager registered for adapter: /org/bluez/hci0
bluetoothd[479]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10001
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001800-0000-1000-8000-00805f9
bluetoothd[479]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[479]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[479]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10002
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001801-0000-1000-8000-00805f9
bluetoothd[479]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[479]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[479]: src/adapter.c:adapter_service_add() /org/bluez/hci0
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10003
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9
bluetoothd[479]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 0000180a-0000-1000-8000-00805f9
bluetoothd[479]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[479]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[479]: src/advertising.c:btd_adv_manager_new() LE Advertising Manager created for adapter: /org/bluez/hci0
bluetoothd[479]: plugins/policy.c:policy_adapter_probe()
bluetoothd[479]: plugins/hostname.c:hostname_probe()
bluetoothd[479]: profiles/network/manager.c:panu_server_probe() path /org/bluez/hci0
bluetoothd[479]: profiles/network/server.c:server_register() Registered interface org.bluez.NetworkServer1 on path /org/bluez/hci0
bluetoothd[479]: profiles/network/manager.c:gn_server_probe() path /org/bluez/hci0
bluetoothd[479]: profiles/network/manager.c:nap_server_probe() path /org/bluez/hci0
bluetoothd[479]: src/adapter.c:btd_adapter_unblock_address() hci0 00:00:00:00:00:00
bluetoothd[479]: src/adapter.c:load_link_keys() hci0 keys 0 debug_keys 0
bluetoothd[479]: src/adapter.c:load_ltks() hci0 keys 0
bluetoothd[479]: src/adapter.c:load_irks() hci0 irks 0
bluetoothd[479]: src/adapter.c:load_conn_params() hci0 conn params 0
bluetoothd[479]: src/adapter.c:load_connections() sending get connections command for index 0
bluetoothd[479]: src/adapter.c:adapter_service_insert() /org/bluez/hci0
bluetoothd[479]: src/adapter.c:add_uuid() sending add uuid command for index 0
bluetoothd[479]: src/adapter.c:set_did() hci0 source 2 vendor 1d6b product 246 version 541
bluetoothd[479]: src/adapter.c:adapter_register() Adapter /org/bluez/hci0 registered
bluetoothd[479]: src/adapter.c:set_dev_class() sending set device class command for index 0
bluetoothd[479]: src/adapter.c:set_name() sending set local name command for index 0
bluetoothd[479]: src/adapter.c:adapter_start() adapter /org/bluez/hci0 has been enabled
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0011
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0011 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0034
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0034 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x000b
[ 918.880428] Bluetooth: hu 8958aa1c retransmitting 1 pkts
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x000b complete: 0x00
bluetoothd[479]: src/adapter.c:new_settings_callback() Settings: 0x000000c1
bluetoothd[479]: src/adapter.c:settings_changed() Changed settings: 0x00000040
bluetoothd[479]: src/adapter.c:settings_changed() Pending settings: 0x00000000
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x000d
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x000d complete: 0x00
bluetoothd[479]: src/adapter.c:new_settings_callback() Settings: 0x000002c1
bluetoothd[479]: src/adapter.c:settings_changed() Changed settings: 0x00000200
bluetoothd[479]: src/adapter.c:settings_changed() Pending settings: 0x00000000
bluetoothd[479]: src/adapter.c:trigger_passive_scanning()
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x002d
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x002d complete: 0x00
bluetoothd[479]: src/adapter.c:new_settings_callback() Settings: 0x00000ac1
bluetoothd[479]: src/adapter.c:settings_changed() Changed settings: 0x00000800
bluetoothd[479]: src/adapter.c:settings_changed() Pending settings: 0x00000000
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x002f
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x2f status: 0x0b
bluetoothd[479]: Failed to set privacy: Rejected (0x0b)
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0010
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0010 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0010
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0010 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0010
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0010 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x003d
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x003d complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0027
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0027 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0012
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0012 complete: 0x00
bluetoothd[479]: src/adapter.c:load_link_keys_complete() link keys loaded for hci0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0013
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0013 complete: 0x00
bluetoothd[479]: src/adapter.c:load_ltks_complete() LTKs loaded for hci0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0030
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0030 complete: 0x00
bluetoothd[479]: src/adapter.c:load_irks_complete() IRKs loaded for hci0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0035
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0035 complete: 0x00
bluetoothd[479]: src/adapter.c:load_conn_params_complete() Connection Parameters loaded for hci0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0015
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0015 complete: 0x00
bluetoothd[479]: src/adapter.c:get_connections_complete() Connection count: 0
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0010
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0010 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0028
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0028 complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x000e
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x000e complete: 0x00
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x000f
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x000f complete: 0x00
bluetoothd[479]: src/adapter.c:local_name_changed_callback() Name: BlueZ 5.65
bluetoothd[479]: src/adapter.c:local_name_changed_callback() Short name:
bluetoothd[479]: src/adapter.c:local_name_changed_callback() Current alias: BlueZ 5.65
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0046
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0046 complete: 0x00
bluetoothd[479]: src/adapter.c:set_blocked_keys_complete() Successfully set blocked keys for index 0
运行bluetoothctl
进入交互模式
# bluetoothctl
[bluetooth]# bluetoothd[479]: src/agent.c:add_default_agent() Default agent set to :1.2 /org/bluez/agent
bluetoothd[479]: src/adapter.c:set_mode() sending set mode command for index 0
bluetoothd[479]: src/agent.c:agent_ref() 0x5236c8: ref=1
bluetoothd[479]: src/agent.c:register_agent() agent :1.2
Agent registered
[bluetooth]# bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0009
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0009 complete: 0x00
bluetoothd[479]: src/adapter.c:new_settings_callback() Settings: 0x00000ad1
bluetoothd[479]: src/adapter.c:settings_changed() Changed settings: 0x00000010
bluetoothd[479]: src/adapter.c:settings_changed() Pending settings: 0x00000000
bluetoothd[479]: src/shared/mgmt.c:send_request() [0x0000] command 0x0018
bluetoothd[479]: src/shared/mgmt.c:can_read_data() [0x0000] command 0x0018 complete: 0x00
[CHG] Controller 84:20:96:B1:4D:92 Pairable: yes
[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# scan on
[bluetooth]#
这样看起来,进入蓝牙命令交互之后,是不正常的。
运行:power on相当于打开蓝牙
运行:agent on
查找设备:scan on或者devices查找可配对设备
配对:pair MACaddress(刚刚查找的配对设备的mac地址) 这一步需要在手机确认
连接:connect MACaddress(刚刚查找的配对设备的mac地址)
信任设备:trust MACaddress(刚刚查找的配对设备的mac地址)
- bluetoothctl命令解析:Bluetoothctl全解析
使用hcitool来操作
上一节中在bluetoothctl没法操作。找到hcitool来操作:
命令:
# hcitool -help
hcitool - HCI Tool ver 5.65
Usage:hcitool [options] <command> [command parameters]
Options:--help Display help-i dev HCI device
Commands:dev Display local devicesinq Inquire remote devicesscan Scan for remote devicesname Get name from remote deviceinfo Get information from remote devicespinq Start periodic inquiryepinq Exit periodic inquirycmd Submit arbitrary HCI commandscon Display active connectionscc Create connection to remote devicedc Disconnect from remote devicesr Switch central/peripheral rolecpt Change connection packet typerssi Display connection RSSIlq Display link qualitytpl Display transmit power levelafh Display AFH channel maplp Set/display link policy settingslst Set/display link supervision timeoutauth Request authenticationenc Set connection encryptionkey Change connection link keyclkoff Read clock offsetclock Read local or remote clocklescan Start LE scanleinfo Get LE remote informationlealadd Add device to LE Accept Listlealrm Remove device from LE Accept Listlealsz Read size of LE Accept Listlealclr Clear LE Accept Listlewladd Deprecated. Use lealadd instead.lewlrm Deprecated. Use lealrm instead.lewlsz Deprecated. Use lealsz instead.lewlclr Deprecated. Use lealclr instead.lerladd Add device to LE Resolving Listlerlrm Remove device from LE Resolving Listlerlclr Clear LE Resolving Listlerlsz Read size of LE Resolving Listlerlon Enable LE Address Resolutionlerloff Disable LE Address Resolutionlecc Create a LE Connectionledc Disconnect a LE Connectionlecup LE Connection UpdateFor more information on the usage of each command use:hcitool <command> --help
dev 显示本地设备inq 查询远程设备scan 扫描远程设备name 从远程设备获取名称info 从远程设备获取信息spinq 开始定期查询epinq 退出定期查询cmd 提交任意HCI命令con 显示活动连接cc 创建到远程设备的连接dc 断开与远程设备的连接sr 切换 主/从 角色cpt 更改连接数据包类型rssi 显示连接RSSIlq 显示链接质量tpl 显示发射功率水平afh 显示AFH通道图lp 设置/显示链接策略设置lst 设置/显示链接时间超时auth 请求身份验证enc 设置连接加密key 更改连接链接密钥clkoff 读时钟偏移clock 读取本地或远程时钟lescan 开始LE扫描lewladd 将设备添加到LE白名单lewlrm 从LE白名单中删除设备lewlsz 阅读LE的尺寸白色清单lewlclr 清除LE白名单lecc 创建一个LE连接ledc 断开LE连接lecup LE连接更新
BLE扫描:
# hcitool lescan
LE Scan ...
65:CB:01:01:36:A9 (unknown)
73:EA:18:45:5B:94 (unknown)
52:A3:99:59:87:56 (unknown)
45:62:42:A1:1E:B4 (unknown)
2D:98:31:2F:12:6C (unknown)
3F:5B:7D:70:B0:4B (unknown)
63:BC:FD:06:D9:D1 (unknown)
55:28:0A:62:B6:88 (unknown)
56:03:BC:EC:4F:23 (unknown)
54:FA:90:91:81:AC (unknown)
1A:58:FD:49:AD:7A (unknown)
D5:19:20:99:CE:D0 (unknown)
4A:96:02:E4:D4:83 (unknown)
6D:CB:2F:84:52:12 (unknown)
BT扫描:
# hcitool scan
Scanning ...
[ 850.534585] rtk_btcoex: hci (periodic)inq start
[ 860.777952] rtk_btcoex: inquiry completeA4:55:90:0F:90:E6 Redmi K40 Pro+
扫描出我的手机蓝牙。
本地设备信息:
# hcitool device
Devices:hci0 84:20:96:B1:4D:92
直到这里,我才知道我其实用手机已经扫出了这个蓝牙!因为不知道为啥设备名没有显示出来!