当前文档版本为 v0.2.0,您可以访问当前页面的 开发中 版本以获取最近可能的更新。

BLE Vehicles Key

1 功能概述

此项目演示基于HID服务的自动连接服务,通过RSSI值的大小模拟实现电动二轮车的利用距离自动开关功能。

2 环境要求

  • board: pan107x evb

  • uart(option): 用来显示串口log(波特率921600,选项8n1)s_key

3 编译和烧录

例程位置:<home>\nimble\samples\solutions\ble_vehicles_key\keil

使用keil进行打开项目选择需要的controller进行烧录ble_vehicles_key或者ble_vehicles_key_spark进行编译烧录。

4 演示说明

  1. 在设置蓝牙界面连接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
    
  2. 如果使用EVB板的话,请将RGB-G的跳线帽连接,如果RSSI距离达到接近阈值时会触发的动作,足够远时会触发的距离动作。

  3. 关于rssi的滤波算法使用的是去除最大和最小值各RSSI_REMOVE_BORDER_NUM个,默认RSSI_REMOVE_BORDER_NUM为2个,排序使用冒泡排序。

  4. RSSI的整体处理在hog.c中。

5 RAM/Flash资源使用情况

Origin Controller:

FLASH:     155759 B
SRAM:      38248 B

Spark Controller:

FLASH:     129555 B
SRAM:      40280 B