如何建立蓝牙连接
来自百问网嵌入式Linux wiki
如何建立蓝牙连接
如何设置蓝牙
设置
- 检查是否已在内核日志消息中正确检测到了对应的驱动程序。
Board $>[ 0.923697] STM32 USART driver initialized
Board $>[ 0.928711] 4000e000.serial: ttyS1 at MMIO 0x4000e000 (irq = 42, base_baud = 6046875) is a stm32-usart
- 检查本地蓝牙设备的详细信息。
Board $> hciconfig -a
hci0: Type: Primary Bus: UART
BD Address: 43:43:A1:12:1F:AC ACL MTU: 1021:8 SCO MTU: 64:1
DOWN
RX bytes:619 acl:0 sco:0 events:31 errors:0
TX bytes:410 acl:0 sco:0 commands:31 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
初始化蓝牙接口
Board $> hciconfig hci0 up
Board $> hciconfig -a
hci0: Type: Primary Bus: UART
BD Address: AA:AA:AA:AA:AA:AA ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:1378 acl:0 sco:0 events:74 errors:0
TX bytes:1186 acl:0 sco:0 commands:74 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'BlueZ 5.46'
Class: 0x000000
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: 4.1 (0x7) Revision: 0x0
LMP Version: 4.1 (0x7) Subversion: 0x2209
Manufacturer: Broadcom Corporation (15)