BT[2]-BLE初体验:心率计

一、简介

通过“BT[1]-Introduction to Bluetooth Low Energy”知道,两个个BLE设备通信需要完成两件事:

广播

建立连接

准备

RK3308+BLE:作为蓝牙的Peripheral设备。

手机+BLE Scanner:作为蓝牙的Central设备。BLE Scanner APP(iPhone)界面如下:

二、Peripheral设备发送广播

echo 1 > /sys/class/rfkill/rfkill0/state 

sleep 3
brcm_patchram_plus1 --enable_hci --no2bytes --use_baudrate_for_download --tosleep 200000 --baudrate 1500000 --patchram /system/etc/firmware/bcm43438a1.hcd /dev/ttyS4 &
sleep 3

hciconfig hci0 up
sleep 2
hciconfig hci0 piscan

# hciconfig -a
hci0: Type: Primary Bus: UART
BD Address: 8C:F7:10:4A:71:B5 ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN ISCAN
RX bytes:9721 acl:6 sco:0 events:328 errors:0
TX bytes:747 acl:2 sco:0 commands:53 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: 'BCM43438A1 26MHz AP6212A1_CL1 BT4.0 OTP-BD-0058'
Class: 0x000000
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: 4.0 (0x6) Revision: 0xf9
LMP Version: 4.0 (0x6) Subversion: 0x2209
Manufacturer: Broadcom Corporation (15)

# hcitool -i hci0 cmd 0x08 0x000a 01
< HCI Command: ogf 0x08, ocf 0x000a, plen 1
01
> HCI Event: 0x0e plen 4
01 0A 20 00

# hcitool -i hci0 cmd 0x08 0x0008 16 02 01 06 03 02 80 ff 0e 09 62 6c 65 5f 6e 61 6d 65 5f 5a 30 30 31
< HCI Command: ogf 0x08, ocf 0x0008, plen 23
16 02 01 06 03 02 80 FF 0E 09 62 6C 65 5F 6E 61 6D 65 5F 5A
30 30 31
> HCI Event: 0x0e plen 4

01 08 20 00

三、GATT

test

猜你喜欢

转载自www.cnblogs.com/rockyching2009/p/10603013.html
今日推荐