From 98aa715f74e54a0be68f6d6ae32a3b4dc95dfa95 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 14 Sep 2022 15:27:34 +0200 Subject: [PATCH] gap: add gap_periodic_advertising_sync_transfer_set_default_parameters --- src/gap.h | 17 +++++++++++++++++ src/hci.c | 27 +++++++++++++++++++++++++++ src/hci.h | 8 ++++++++ 3 files changed, 52 insertions(+) diff --git a/src/gap.h b/src/gap.h index 014a33306..4f15f56c9 100644 --- a/src/gap.h +++ b/src/gap.h @@ -772,6 +772,23 @@ uint8_t gap_periodic_advertising_start(uint8_t advertising_handle, bool include_ */ uint8_t gap_periodic_advertising_stop(uint8_t advertising_handle); +/** + * @brief Set Default Periodic Advertising Sync Transfer Parameters + * @note The parameters are used for all subsequent connections over the LE transport. + * If mode != 0, an HCI_LE_Periodic_Advertising_Sync_Transfer_Received event will be emitted by the Controller + * @param mode 0 = ignore (default), 1 = periodic advertising events disabled + * 2 = periodic advertising events enabled with duplicate filtering + * 3 = periodic advertising events enabled with duplicate filtering + * @return status + * @param skip The number of periodic advertising packets that can be skipped after a successful receive + * @param sync_timeout Range: 0x000A to 0x4000, Time = N*10 ms, Time Range: 100 ms to 163.84 s + * @param cte_type bit 0 = Do not sync to packets with an AoA Constant Tone Extension + * bit 1 = Do not sync to packets with an AoD Constant Tone Extension with 1 μs slots + * bit 2 = Do not sync to packets with an AoD Constant Tone Extension with 2 μs slots + * bit 3 = Do not sync to packets without a Constant Tone Extension + */ +uint8_t gap_periodic_advertising_sync_transfer_set_default_parameters(uint8_t mode, uint16_t skip, uint16_t sync_timeout, uint8_t cte_type); + /** * @brief Remove advertising set from Controller * @param advertising_handle diff --git a/src/hci.c b/src/hci.c index dfaff16d3..69787c0b8 100644 --- a/src/hci.c +++ b/src/hci.c @@ -6203,6 +6203,22 @@ static bool hci_run_general_gap_le(void){ } } #endif +#endif + +#ifdef ENABLE_LE_CENTRAL +#ifdef ENABLE_LE_EXTENDED_ADVERTISING +#ifdef ENABLE_LE_PERIODIC_ADVERTISING + if (hci_stack->le_past_set_default_params){ + hci_stack->le_past_set_default_params = false; + hci_send_cmd(&hci_le_set_default_periodic_advertising_sync_transfer_parameters, + hci_stack->le_past_mode, + hci_stack->le_past_skip, + hci_stack->le_past_sync_timeout, + hci_stack->le_past_cte_type); + return true; + } +#endif +#endif #endif // post-pone all actions until stack is fully working @@ -8138,6 +8154,17 @@ uint8_t gap_periodic_advertising_stop(uint8_t advertising_handle){ hci_run(); return ERROR_CODE_SUCCESS; } + +uint8_t gap_periodic_advertising_sync_transfer_set_default_parameters(uint8_t mode, uint16_t skip, uint16_t sync_timeout, uint8_t cte_type){ + hci_stack->le_past_mode = mode; + hci_stack->le_past_skip = skip; + hci_stack->le_past_sync_timeout = sync_timeout; + hci_stack->le_past_cte_type = cte_type; + hci_stack->le_past_set_default_params = true; + hci_run(); + return ERROR_CODE_SUCCESS; +} + #endif /* ENABLE_LE_PERIODIC_ADVERTISING */ #endif diff --git a/src/hci.h b/src/hci.h index 829756958..270171235 100644 --- a/src/hci.h +++ b/src/hci.h @@ -1165,6 +1165,7 @@ typedef struct { #ifdef ENABLE_LE_EXTENDED_ADVERTISING btstack_linked_list_t le_periodic_advertiser_list; uint16_t le_periodic_terminate_sync_handle; + // Periodic Advertising Sync parameters uint8_t le_periodic_sync_options; uint8_t le_periodic_sync_advertising_sid; @@ -1175,6 +1176,13 @@ typedef struct { uint8_t le_periodic_sync_cte_type; le_connecting_state_t le_periodic_sync_state; le_connecting_state_t le_periodic_sync_request; + + // Periodic Advertising Sync Transfer (PAST) + bool le_past_set_default_params; + uint8_t le_past_mode; + uint16_t le_past_skip; + uint16_t le_past_sync_timeout; + uint8_t le_past_cte_type; #endif #endif