BLE Vehicles Key¶
1 功能概述¶
此项目演示基于HID服务的自动连接服务,通过RSSI值的大小模拟实现电动二轮车的利用距离自动开关功能。
2 环境要求¶
board:
pan107x evb
uart(option): 用来显示串口log(波特率921600,选项
8n1
)s_key
4 演示说明¶
在设置蓝牙界面连接
vehicles key
进行配对后会自动跟踪rssi值的大小,模拟电动二轮车钥匙实现近距离自动开关。[19:57:21.854] Try to load HW calibration data.. DONE. - Chip Type : 0x80 - Chip CP Version : None - Chip FT Version : 8 - Chip MAC Address : D0000C0CBBF5 - Chip Flash UID : 32313334320EAC834330FFFFFFFFFFFF - Chip Flash Size : 1024 KB LL Spark Controller Version:b0e99c4 [19:57:21.919] ble_store_config_num_our_secs:0 ble_store_config_num_peer_secs:0 ble_store_config_num_cccds:0 registered service 0x1812 with handle=1 registering characteristic 0x2a4a with def_handle=2 val_handle=3 registering characteristic 0x2a4b with def_handle=4 val_handle=5 registering characteristic 0x2a4d with def_handle=6 val_handle=7 registering descriptor 0x2908 with handle=9 registering characteristic 0x2a4d with def_handle=10 val_handle=11 registering descriptor 0x2908 with handle=13 registering characteristic 0x2a4c with def_handle=14 val_handle=15 Device Address: 01 02 03 04 05 06 [19:57:28.164] connection established; status=0 handle=1 our_ota_addr_type=0 our_ota_addr=01 02 03 04 05 06 our_id_addr_type=0 our_id_addr=01 02 03 04 05 06 peer_ota_addr_type=1 peer_ota_addr=f4 be 2e 4e 35 50 peer_id_addr_type=1 peer_id_addr=f4 be 2e 4e 35 50 conn_itvl=24 conn_latency=0 supervision_timeout=500 encrypted=0 authenticated=0 bonded=0 [19:57:30.923] encryption change event; status=0 handle=1 our_ota_addr_type=0 our_ota_addr=01 02 03 04 05 06 our_id_addr_type=0 our_id_addr=01 02 03 04 05 06 peer_ota_addr_type=1 peer_ota_addr=f4 be 2e 4e 35 50 peer_id_addr_type=1 peer_id_addr=f4 be 2e 4e 35 50 conn_itvl=24 conn_latency=0 supervision_timeout=500 encrypted=1 authenticated=0 bonded=1 ediv=0 rand=0 authenticated=0 ltk= f5f99f23fb223b4ff0f5f7f21c0146d1 irk= 00000000000000000000000000000000 ediv=0 rand=0 authenticated=0 ltk= f5f99f23fb223b4ff0f5f7f21c0146d1 irk= 4a3711a0c1b7cd2c92d64048e813fe34 [19:57:31.223] connection updated; status=0 handle=1 our_ota_addr_type=0 our_ota_addr=01 02 03 04 05 06 our_id_addr_type=0 our_id_addr=01 02 03 04 05 06 peer_ota_addr_type=1 peer_ota_addr=f4 be 2e 4e 35 50 peer_id_addr_type=0 peer_id_addr=07 49 34 4d af 50 conn_itvl=6 conn_latency=0 supervision_timeout=500 encrypted=1 authenticated=0 bonded=1 connection updated; status=0 handle=1 our_ota_addr_type=0 our_ota_addr=01 02 03 04 05 06 our_id_addr_type=0 our_id_addr=01 02 03 04 05 06 peer_ota_addr_type=1 peer_ota_addr=f4 be 2e 4e 35 50 peer_id_addr_type=0 peer_id_addr=07 49 34 4d af 50 conn_itvl=24 conn_latency=0 supervision_timeout=500 encrypted=1 authenticated=0 bonded=1 [19:57:32.135] subscribe event; conn_handle=1 attr_handle=7 reason=1 prevn=0 curn=1 previ=0 curi=0 [19:57:32.189] subscribe event; conn_handle=1 attr_handle=11 reason=1 prevn=0 curn=1 previ=0 curi=0 [19:57:32.238] open led
如果使用EVB板的话,请将
RGB-G
的跳线帽连接,如果RSSI距离达到接近阈值时会触发开
的动作,足够远时会触发关
的距离动作。关于
rssi的滤波算法
使用的是去除最大和最小值各RSSI_REMOVE_BORDER_NUM
个,默认RSSI_REMOVE_BORDER_NUM
为2个,排序使用冒泡排序。RSSI的整体处理在
hog.c
中。