How to run scanning with limited duration only in KW38 BLE

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to run scanning with limited duration only in KW38 BLE

跳至解决方案
1,044 次查看
FedericoWegher
Contributor III

Hello.

I am using KW38 BLE with SDK 2.6.6 on both central and peripheral devices. Currently the central is using continuous scan, that is, is calls the following API:

App_StartScanning(&gScanParams, BleApp_ScanningCallback, gGapDuplicateFilteringDisable_c, gGapScanContinuously_d, gGapScanPeriodicDisabled_d);

with

gapScanningParameters_t gScanParams =
{
.type = gScanTypePassive_c,
.interval = 3200,
.window = 1600,
.ownAddressType = gBleAddrTypePublic_c,
.filterPolicy = gScanAll_c,
.scanningPHYs = gLePhy1MFlag_c
};

That is, scan window is 1 second and interval is 2 second. It works fine.

Now my need is to use finite duration for scanning and have it stopped after one period. Ideally, I would like to stop after the scan window is over. I modified the API call this way:

App_StartScanning(&gScanParams, BleApp_ScanningCallback, gGapDuplicateFilteringDisable_c, 100, gGapScanPeriodicDisabled_d);

but the scan never stops. I tried the following values: 100, 101, 200, 201, 1000, always without success.

Please help to make scan periodic.

标记 (3)
0 项奖励
回复
1 解答
986 次查看
anca_codreanu
NXP Employee
NXP Employee

Hi @FedericoWegher ,

Duration and period parameters are not part of the legacy Scan Enable command. They are included only in Extended Scan Enable command.

legacy_scan.PNG

extended.PNG

In our API, they are used only when extended scanning is enabled, otherwise they are ignored.

The support for Bluetooth 5.0 Extended Advertising/Scanning comes in separate host libraries in our SDK. The Bluetooth LE examples from our SDK use the legacy host libraries. To support the extended advertising/scanning, the corresponding host libraries need to be used ( they have _AE_ in their name).

Taking as example the project w_uart from the SDK ( it can be found at the following path sdk_folder\boards\frdmkw38\wireless_examples\bluetooth ), to enable the extended scanning please do the following steps:

  • use lib_ble_5-0_AE_host_cm0p_iar.a instead of lib_ble_5-0_host_cm0p_iar.a

lib.PNG

 

  • add #define gAppExtAdvEnable_d 1 in app_preinclude.h file

 

If you need more details please let us know.

Best regards,

Anca

在原帖中查看解决方案

0 项奖励
回复
1 回复
987 次查看
anca_codreanu
NXP Employee
NXP Employee

Hi @FedericoWegher ,

Duration and period parameters are not part of the legacy Scan Enable command. They are included only in Extended Scan Enable command.

legacy_scan.PNG

extended.PNG

In our API, they are used only when extended scanning is enabled, otherwise they are ignored.

The support for Bluetooth 5.0 Extended Advertising/Scanning comes in separate host libraries in our SDK. The Bluetooth LE examples from our SDK use the legacy host libraries. To support the extended advertising/scanning, the corresponding host libraries need to be used ( they have _AE_ in their name).

Taking as example the project w_uart from the SDK ( it can be found at the following path sdk_folder\boards\frdmkw38\wireless_examples\bluetooth ), to enable the extended scanning please do the following steps:

  • use lib_ble_5-0_AE_host_cm0p_iar.a instead of lib_ble_5-0_host_cm0p_iar.a

lib.PNG

 

  • add #define gAppExtAdvEnable_d 1 in app_preinclude.h file

 

If you need more details please let us know.

Best regards,

Anca

0 项奖励
回复