Bluetooth: Host: Adds periodic advertising min/max interval macros

Add the BT_GAP_PER_ADV_MIN_INTERVAL and BT_GAP_PER_ADV_MAX_INTERVAL
macros in gap.h that are also reference in bluetooth.h and
used for parameter validation in adv.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-04-22 12:32:42 +02:00 committed by Carles Cufí
commit 2bada95482
3 changed files with 18 additions and 4 deletions

View file

@ -614,10 +614,20 @@ enum {
};
struct bt_le_per_adv_param {
/** Minimum Periodic Advertising Interval (N * 1.25 ms) */
/**
* @brief Minimum Periodic Advertising Interval (N * 1.25 ms)
*
* Shall be greater or equal to BT_GAP_PER_ADV_MIN_INTERVAL and
* less or equal to interval_max.
*/
uint16_t interval_min;
/** Maximum Periodic Advertising Interval (N * 1.25 ms) */
/**
* @brief Maximum Periodic Advertising Interval (N * 1.25 ms)
*
* Shall be less or equal to BT_GAP_PER_ADV_MAX_INTERVAL and
* greater or equal to interval_min.
*/
uint16_t interval_max;
/** Bit-field of periodic advertising options */

View file

@ -149,6 +149,10 @@ enum {
#define BT_GAP_PER_ADV_MAX_SKIP 0x01F3
#define BT_GAP_PER_ADV_MIN_TIMEOUT 0x000A
#define BT_GAP_PER_ADV_MAX_TIMEOUT 0x4000
/** Minimum Periodic Advertising Interval (N * 1.25 ms) */
#define BT_GAP_PER_ADV_MIN_INTERVAL 0x0006
/** Maximum Periodic Advertising Interval (N * 1.25 ms) */
#define BT_GAP_PER_ADV_MAX_INTERVAL 0xFFFF
/** Constant Tone Extension (CTE) types */

View file

@ -1369,8 +1369,8 @@ int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv,
return -EINVAL;
}
if (param->interval_min < 0x0006 ||
param->interval_max > 0xFFFF ||
if (param->interval_min < BT_GAP_PER_ADV_MIN_INTERVAL ||
param->interval_max > BT_GAP_PER_ADV_MAX_INTERVAL ||
param->interval_min > param->interval_max) {
return -EINVAL;
}