Nordic nRF5 SDK 學習筆記之十, 藍牙 Central 掃描參數 ble_gap_scan_params_t 理解

軟件: 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_CODEDble_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

    值:    

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.

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.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章