【BLE】BLE扫描参数

软件: nRF SKD Ver 15.2, S140 SoftDevice API

文档路径: ~/nRF5_SDK_15.2.0_offline_doc/s140/structble__gap__scan__params__t.html

1. ble_gap_scan_params_t::active; 

    值:   1: 主动扫描, 0: 被动扫描; 

如果需要获得扫描响应,需要 Central 主机设置为主动扫描。如果只是需要广播数据则设置为被动扫描。

两者区别在于:主动扫描可以获得广播数据和扫描响应数据,而被动扫描只能获得广播数据。

2. ble_gap_scan_params_t::timeout;  (单位: 10 毫秒, 扫描超时 )

    值:   受限于 GAP Scan timeout max and min

        #define     BLE_GAP_SCAN_TIMEOUT_MIN   0x0001                // 1: 最小扫描时间周期  1* 10mS = 10 毫秒.
        #define     BLE_GAP_SCAN_TIMEOUT_UNLIMITED   0x0000   //0: 一直扫描直到被停止, 没有扫描超时限制;

3. ble_gap_scan_params_t::interval;  (单位: 625 微秒,扫描间隔 )

    值:   受限于 GAP Scan interval max and min 

        #define     BLE_GAP_SCAN_INTERVAL_MIN   0x0004    // Minimum Scan interval in 625 us units, i.e. 2.5 ms.
        #define     BLE_GAP_SCAN_INTERVAL_MAX   0xFFFF  // Maximum Scan interval in 625 us units, i.e. 40,959.375 s.

4. ble_gap_scan_params_t::window;  (单位: 625 微秒,扫描窗口 )

    值:    受限于 GAP Scan window max and min

        #define     BLE_GAP_SCAN_WINDOW_MIN   0x0004    // Minimum Scan interval in 625 us units, i.e. 2.5 ms.
        #define     BLE_GAP_SCAN_WINDOW_MAX   0xFFFF  // Maximum Scan interval in 625 us units, i.e. 40,959.375 s.

如果参数 ble_gap_scan_params_t::scan_phys 为  BLE_GAP_PHY_1MBPS 或 BLE_GAP_PHY_CODED, ble_gap_scan_params_t::interval 设定值须大于或等于2倍  ble_gap_scan_params_t::window 设定值;

5. ble_gap_scan_params_t::filter_policy  (接收广播过滤,如白名单)

    值:    GAP Scanner filter policies

       #define     BLE_GAP_SCAN_FP_ACCEPT_ALL   0x00 
       #define     BLE_GAP_SCAN_FP_WHITELIST   0x01 
       #define     BLE_GAP_SCAN_FP_ALL_NOT_RESOLVED_DIRECTED   0x02 
       #define     BLE_GAP_SCAN_FP_WHITELIST_NOT_RESOLVED_DIRECTED   0x03

     注: 当使用 sd_ble_gap_connect() 函数时,仅仅参数  BLE_GAP_SCAN_FP_ACCEPT_ALL , BLE_GAP_SCAN_FP_WHITELIST 有效.

6. ble_gap_scan_params_t::scan_phys (扫描通讯速率)

    值:    默认值: BLE_GAP_PHY_1MBPS. 

     ble_gap_scan_params_t::extended 被设置为 0, 此参数仅能为 BLE_GAP_PHY_1MBPS. 

    使用  sd_ble_gap_scan_start() 时, 主机将使用此设置扫描主广播通道;主机也接受 BLE_GAP_PHYS_SUPPORTED 作为次要广播通道的物理配置。

    使用  sd_ble_gap_connect() 时,这位域指示可能用这参数进行初始化。如果scan_phys 包含 BLE_GAP_PHY_1MBPS 或BLE_GAP_PHY_2MBPS, 则主扫描速率为BLE_GAP_PHY_1MBPS. 如果scan_phys 也包含 BLE_GAP_PHY_CODED, 则主扫描速率包含 BLE_GAP_PHY_CODED. 如果scan_phys 只有 BLE_GAP_PHY_CODED, 则主扫描速率仅为 BLE_GAP_PHY_CODED. 

7. ble_gap_scan_params_t::channel_mask (通讯通道)

    值:   至少设置一个主广播通道 ( Channel: 37~39), 其值被设为 0;次要通道暂时不支持;

typedef uint8_t     ble_gap_ch_mask_t [5]
     Channel mask (40 bits). Every channel is represented with a bit positioned as per channel index defined in Bluetooth Core Specification v5.0, Vol 6, Part B, Section 1.4.1. The LSB contained in array element 0 represents channel index 0, and bit 39 represents channel index 39. If a bit is set to 1, the channel is not used. 

8. ble_gap_scan_params_t::extended (广播扩展)

    值:  1: 扫描主机将接受蓝牙扩展广播包 ;  0: 扫描主机不接收第二个广播通道的蓝牙广播包,且不能接收长广播包(PDU, protocol data unit ). 

9. ble_gap_scan_params_t::report_incomplete_evts

    值:  1: ble_gap_evt_adv_report_t 事件中可能, ble_gap_adv_report_type_t::status 被设为 BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. 

当使用 sd_ble_gap_connect() 函数时, 此参数无效; 

注意:此参数可能被用来中止接收来自扩展广播事件的多个数据包,它仅有效于扩展扫描,详情请见 sd_ble_gap_scan_start().

当前 S140 SoftDevice 不支持此功能。

NORDIC 官方原文:

ble_gap_scan_params_t Struct Reference

Structures

GAP scanning parameters. More...

#include <ble_gap.h>

Data Fields
uint8_t     extended: 1
 
uint8_t     report_incomplete_evts: 1
 
uint8_t     active: 1
 
uint8_t     filter_policy: 2
 
uint8_t     scan_phys
 
uint16_t     interval
 
uint16_t     window
 
uint16_t     timeout
 
ble_gap_ch_mask_t     channel_mask
 

Detailed Description
GAP scanning parameters.

Field Documentation

uint8_t ble_gap_scan_params_t::active
If 1, perform active scanning by sending scan requests. This parameter is ignored when used with sd_ble_gap_connect.


ble_gap_ch_mask_t ble_gap_scan_params_t::channel_mask
               Channel mask for primary and secondary advertising channels.
At least one of the primary channels, that is channel index 37-39, must be set to 0. Masking away secondary channels is not supported.


uint8_t ble_gap_scan_params_t::extended
If 1, the scanner will accept extended advertising packets. If set to 0, the scanner will not receive advertising packets on secondary advertising channels, and will not be able to receive long advertising PDUs.


uint8_t ble_gap_scan_params_t::filter_policy
Scanning filter policy.

See Also

GAP Scanner filter policies.

Note

Only BLE_GAP_SCAN_FP_ACCEPT_ALL and BLE_GAP_SCAN_FP_WHITELIST are valid when used with sd_ble_gap_connect


uint16_t ble_gap_scan_params_t::interval
Scan interval in 625 us units.

See Also

GAP Scan interval max and min.


uint8_t ble_gap_scan_params_t::report_incomplete_evts
If 1, events of type ble_gap_evt_adv_report_t may have ble_gap_adv_report_type_t::status set to BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. This parameter is ignored when used with sd_ble_gap_connect

Note

This may be used to abort receiving more packets from an extended advertising event, and is only available for extended scanning, see sd_ble_gap_scan_start.

This feature is not supported by this SoftDevice.


uint8_t ble_gap_scan_params_t::scan_phys
                  Bitfield of PHYs to scan on. If set to @ref BLE_GAP_PHY_AUTO,
scan_phys will default to BLE_GAP_PHY_1MBPS.

If ble_gap_scan_params_t::extended is set to 0, the only supported PHY is BLE_GAP_PHY_1MBPS.
When used with sd_ble_gap_scan_start, the bitfield indicates the PHYs the scanner will use for scanning on primary advertising channels. The scanner will accept BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs.
When used with sd_ble_gap_connect, the bitfield indicates the PHYs on where a connection may be initiated. If scan_phys contains BLE_GAP_PHY_1MBPS and/or BLE_GAP_PHY_2MBPS, the primary scan PHY is BLE_GAP_PHY_1MBPS. If scan_phys also contains BLE_GAP_PHY_CODED, the primary scan PHY will also contain BLE_GAP_PHY_CODED. If the only scan PHY is BLE_GAP_PHY_CODED, the primary scan PHY is BLE_GAP_PHY_CODED only.

uint16_t ble_gap_scan_params_t::timeout
Scan timeout in 10 ms units.

See Also

GAP Scan timeout max and min.


uint16_t ble_gap_scan_params_t::window
                     Scan window in 625 us units.@sa BLE_GAP_SCAN_WINDOW.
If scan_phys contains both BLE_GAP_PHY_1MBPS and BLE_GAP_PHY_CODED interval shall be larger than or equal to twice the scan window.
————————————————
版权声明:本文为CSDN博主「Hansen Mi」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42396877/article/details/85397047

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值