From 139fbb0f4d9c3b0faafa0dc5d8a8b68807d2a09d Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Mon, 17 Aug 2020 12:49:40 +0530 Subject: [PATCH] Bluetooth: controller: Add sync info structure fill function Refactor out into function the filling of sync info structure in the common extended advertising payload format header. Signed-off-by: Vinayak Kariappa Chettimada --- .../bluetooth/controller/ll_sw/ull_adv_aux.c | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c index 58bd4755b4f..4d4d12c296b 100644 --- a/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c +++ b/subsys/bluetooth/controller/ll_sw/ull_adv_aux.c @@ -42,6 +42,8 @@ static int init_reset(void); static inline struct ll_adv_aux_set *aux_acquire(void); static inline void aux_release(struct ll_adv_aux_set *aux); static inline uint8_t aux_handle_get(struct ll_adv_aux_set *aux); +static inline void sync_info_fill(struct lll_adv_sync *lll_sync, + uint8_t **dptr); static void mfy_aux_offset_get(void *param); static void ticker_cb(uint32_t ticks_at_expire, uint32_t remainder, uint16_t lazy, void *param); @@ -558,25 +560,7 @@ uint8_t ull_adv_aux_hdr_set_clear(struct ll_adv_set *adv, sec_dptr_prev -= sizeof(struct pdu_adv_sync_info); } if (sec_hdr->sync_info) { - struct lll_adv_sync *lll_sync; - struct ll_adv_sync_set *sync; - struct pdu_adv_sync_info *si; - - sec_dptr -= sizeof(*si); - - lll_sync = lll->sync; - sync = (void *)HDR_LLL2EVT(lll_sync); - - si = (void *)sec_dptr; - si->offs = 0U; /* NOTE: Filled by secondary prepare */ - si->offs_units = 0U; - si->interval = sys_cpu_to_le16(sync->interval); - memcpy(si->sca_chm, lll_sync->data_chan_map, - sizeof(si->sca_chm)); - memcpy(&si->aa, lll_sync->access_addr, sizeof(si->aa)); - memcpy(si->crc_init, lll_sync->crc_init, sizeof(si->crc_init)); - - si->evt_cntr = 0U; /* TODO: Implementation defined */ + sync_info_fill(lll->sync, &sec_dptr); } /* AuxPtr */ @@ -862,6 +846,28 @@ static inline uint8_t aux_handle_get(struct ll_adv_aux_set *aux) sizeof(struct ll_adv_aux_set)); } +static inline void sync_info_fill(struct lll_adv_sync *lll_sync, + uint8_t **dptr) +{ + struct ll_adv_sync_set *sync; + struct pdu_adv_sync_info *si; + + *dptr -= sizeof(*si); + + sync = (void *)HDR_LLL2EVT(lll_sync); + + si = (void *)*dptr; + si->offs = 0U; /* NOTE: Filled by secondary prepare */ + si->offs_units = 0U; /* TODO: implementation defined */ + si->interval = sys_cpu_to_le16(sync->interval); + memcpy(si->sca_chm, lll_sync->data_chan_map, + sizeof(si->sca_chm)); + memcpy(&si->aa, lll_sync->access_addr, sizeof(si->aa)); + memcpy(si->crc_init, lll_sync->crc_init, sizeof(si->crc_init)); + + si->evt_cntr = 0U; /* NOTE: Filled by secondary prepare */ +} + static void mfy_aux_offset_get(void *param) { struct ll_adv_set *adv = param;