BLE_GAP_SetScanningEnable
C
uint16_t BLE_GAP_SetScanningEnable(bool enable, uint8_t filterDuplicate, uint8_t mode, uint16_t duration);
Description
Starts or stops scanning for advertising devices.
Note
Scanning is used to discover nearby advertising devices. If scanning is already active, setting the enable parameter to true will update the filterDuplicate setting. This API is part of the legacy advertising feature set and will be disallowed if any API from the extended advertising feature set has been used previously. See Categories of advertising APIs and events for details on advertising APIs. The BLE_GAP_ScanInit function must be called prior to using this API.
Events generated
BLE_GAP_EVT_ADV_REPORT is generated when scan is enabled.
BLE_GAP_EVT_DIRECT_ADV_REPORT is generated when scanning is enabled and a direct advertisement is received.
BLE_GAP_EVT_SCAN_TIMEOUT is generated when scanning is enabled and times out.
Parameters
Parameter | Description |
---|---|
[in] enable | Start (true) or stop (false) scanning. |
[in] filterDuplicate | Duplicate filtering policy, see Scan filter duplicate options. Valid values are BLE_GAP_SCAN_FD_DISABLE and BLE_GAP_SCAN_FD_ENABLE. |
[in] mode | Scan mode., see Scan modes. |
[in] duration | Scan duration in units of 100 ms. |
Return values
Return value | Description |
---|---|
MBA_RES_SUCCESS | Successfully starts or stop scanning. |
MBA_RES_OOM | Internal memory allocation failure occurred. |
MBA_RES_INVALID_PARA | Invalid parameters, such as out-of-range values. |
MBA_RES_COMMAND_DISALLOWED | Command disallowed when the extended advertising feature is in use. |