2018-12-18 05:48:20 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2019 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOTE: Definitions used internal to ULL implementations */
|
|
|
|
|
2020-04-14 17:22:07 +05:30
|
|
|
#define SCAN_HANDLE_1M 0
|
|
|
|
#define SCAN_HANDLE_PHY_CODED 1
|
|
|
|
|
2020-10-15 15:58:17 +05:30
|
|
|
#define EXT_SCAN_DURATION_UNIT_US 10000U
|
|
|
|
#define EXT_SCAN_PERIOD_UNIT_US 1280000U
|
|
|
|
|
2020-10-17 05:48:31 +05:30
|
|
|
/* Convert period in 1.28 s units to duration of 10 ms units*/
|
|
|
|
#define ULL_SCAN_PERIOD_TO_DURATION(period) \
|
|
|
|
((uint32_t)(period) * EXT_SCAN_PERIOD_UNIT_US / \
|
|
|
|
EXT_SCAN_DURATION_UNIT_US)
|
|
|
|
|
|
|
|
/* Convert duration in 10 ms unit to radio events count */
|
|
|
|
#define ULL_SCAN_DURATION_TO_EVENTS(duration, interval) \
|
|
|
|
(((uint32_t)(duration) * EXT_SCAN_DURATION_UNIT_US / \
|
2021-01-16 13:38:07 +01:00
|
|
|
SCAN_INT_UNIT_US) / (interval))
|
2020-10-17 05:48:31 +05:30
|
|
|
|
|
|
|
/* Convert period in 1.28 s unit to radio events count */
|
|
|
|
#define ULL_SCAN_PERIOD_TO_EVENTS(period, interval) \
|
|
|
|
(((uint32_t)(period) * EXT_SCAN_PERIOD_UNIT_US / \
|
2021-01-16 13:38:07 +01:00
|
|
|
SCAN_INT_UNIT_US) / (interval))
|
2020-10-17 05:48:31 +05:30
|
|
|
|
2018-12-18 05:48:20 +01:00
|
|
|
int ull_scan_init(void);
|
|
|
|
int ull_scan_reset(void);
|
|
|
|
|
|
|
|
/* Set scan parameters */
|
2020-05-27 11:26:57 -05:00
|
|
|
void ull_scan_params_set(struct lll_scan *lll, uint8_t type, uint16_t interval,
|
|
|
|
uint16_t window, uint8_t filter_policy);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
|
|
|
/* Enable and start scanning/initiating role */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint8_t ull_scan_enable(struct ll_scan_set *scan);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
|
|
|
/* Disable scanning/initiating role */
|
2020-04-08 16:17:48 +05:30
|
|
|
uint8_t ull_scan_disable(uint8_t handle, struct ll_scan_set *scan);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
2020-10-16 10:06:43 +05:30
|
|
|
/* Helper function to dequeue scan timeout event */
|
|
|
|
void ull_scan_term_dequeue(uint8_t handle);
|
|
|
|
|
2018-12-18 05:48:20 +01:00
|
|
|
/* Return ll_scan_set context (unconditional) */
|
2020-04-08 16:17:48 +05:30
|
|
|
struct ll_scan_set *ull_scan_set_get(uint8_t handle);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
|
|
|
/* Return the scan set handle given the scan set instance */
|
2020-04-08 16:17:48 +05:30
|
|
|
uint8_t ull_scan_handle_get(struct ll_scan_set *scan);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
2020-11-05 18:13:25 +05:30
|
|
|
/* Helper function to check and return if a valid scan context */
|
|
|
|
struct ll_scan_set *ull_scan_is_valid_get(struct ll_scan_set *scan);
|
|
|
|
|
2018-12-18 05:48:20 +01:00
|
|
|
/* Return ll_scan_set context if enabled */
|
2020-04-08 16:17:48 +05:30
|
|
|
struct ll_scan_set *ull_scan_is_enabled_get(uint8_t handle);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
|
|
|
/* Return ll_scan_set contesst if disabled */
|
2020-04-08 16:17:48 +05:30
|
|
|
struct ll_scan_set *ull_scan_is_disabled_get(uint8_t handle);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
|
|
|
/* Return flags if enabled */
|
2020-04-08 16:17:48 +05:30
|
|
|
uint32_t ull_scan_is_enabled(uint8_t handle);
|
2018-12-18 05:48:20 +01:00
|
|
|
|
|
|
|
/* Return filter policy used */
|
2020-04-08 16:17:48 +05:30
|
|
|
uint32_t ull_scan_filter_pol_get(uint8_t handle);
|
2020-04-21 11:12:41 +05:30
|
|
|
|
|
|
|
int ull_scan_aux_init(void);
|
|
|
|
int ull_scan_aux_reset(void);
|
|
|
|
|
|
|
|
/* Helper to setup scanning on auxiliary channel */
|
2020-11-05 18:13:25 +05:30
|
|
|
void ull_scan_aux_setup(memq_link_t *link, struct node_rx_hdr *rx);
|
2020-04-21 11:12:41 +05:30
|
|
|
|
2020-10-12 21:56:59 +05:30
|
|
|
/* Helper function to handle scan done events */
|
|
|
|
void ull_scan_done(struct node_rx_event_done *done);
|
|
|
|
|
2020-04-21 11:12:41 +05:30
|
|
|
/* Helper to clean up auxiliary channel scanning */
|
|
|
|
void ull_scan_aux_done(struct node_rx_event_done *done);
|