From c31a54a792638e5d97e68585c8ccec5ae78edfee Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 31 Jan 2019 14:26:44 +0100 Subject: [PATCH 1/3] nimble/ll: Move CSA2 and channel map functions to utils Those will be also used in periodic advertising. --- .../include/controller/ble_ll_utils.h | 26 ++ nimble/controller/src/ble_ll_conn.c | 263 +---------------- nimble/controller/src/ble_ll_conn_hci.c | 3 +- nimble/controller/src/ble_ll_conn_priv.h | 1 - nimble/controller/src/ble_ll_utils.c | 273 ++++++++++++++++++ 5 files changed, 308 insertions(+), 258 deletions(-) create mode 100644 nimble/controller/include/controller/ble_ll_utils.h create mode 100644 nimble/controller/src/ble_ll_utils.c diff --git a/nimble/controller/include/controller/ble_ll_utils.h b/nimble/controller/include/controller/ble_ll_utils.h new file mode 100644 index 000000000..bf560d741 --- /dev/null +++ b/nimble/controller/include/controller/ble_ll_utils.h @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include + +uint32_t ble_ll_utils_calc_access_addr(void); +uint8_t ble_ll_utils_remapped_channel(uint8_t remap_index, const uint8_t *chanmap); +uint8_t ble_ll_utils_calc_dci_csa2(uint16_t event_cntr, uint16_t channel_id, + uint8_t num_used_chans, const uint8_t *chanmap); +uint8_t ble_ll_utils_calc_num_used_chans(const uint8_t *chanmap); diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c index 296da902f..5cdc3c585 100644 --- a/nimble/controller/src/ble_ll_conn.c +++ b/nimble/controller/src/ble_ll_conn.c @@ -40,6 +40,7 @@ #include "controller/ble_ll_trace.h" #include "controller/ble_phy.h" #include "controller/ble_hw.h" +#include "controller/ble_ll_utils.h" #include "ble_ll_conn_priv.h" #if (BLETEST_THROUGHPUT_TEST == 1) @@ -462,257 +463,6 @@ ble_ll_conn_calc_window_widening(struct ble_ll_conn_sm *connsm) return window_widening; } -/** - * Calculates the number of used channels in the channel map - * - * @param chmap - * - * @return uint8_t Number of used channels - */ -uint8_t -ble_ll_conn_calc_used_chans(uint8_t *chmap) -{ - int i; - int j; - uint8_t mask; - uint8_t chanbyte; - uint8_t used_channels; - - used_channels = 0; - for (i = 0; i < BLE_LL_CONN_CHMAP_LEN; ++i) { - chanbyte = chmap[i]; - if (chanbyte) { - if (chanbyte == 0xff) { - used_channels += 8; - } else { - mask = 0x01; - for (j = 0; j < 8; ++j) { - if (chanbyte & mask) { - ++used_channels; - } - mask <<= 1; - } - } - } - } - return used_channels; -} - -static uint32_t -ble_ll_conn_calc_access_addr(void) -{ - uint32_t aa; - uint16_t aa_low; - uint16_t aa_high; - uint32_t temp; - uint32_t mask; - uint32_t prev_bit; - uint8_t bits_diff; - uint8_t consecutive; - uint8_t transitions; - uint8_t ones; - int tmp; - - /* Calculate a random access address */ - aa = 0; - while (1) { - /* Get two, 16-bit random numbers */ - aa_low = rand() & 0xFFFF; - aa_high = rand() & 0xFFFF; - - /* All four bytes cannot be equal */ - if (aa_low == aa_high) { - continue; - } - - /* Upper 6 bits must have 2 transitions */ - tmp = (int16_t)aa_high >> 10; - if (__builtin_popcount(tmp ^ (tmp >> 1)) < 2) { - continue; - } - - /* Cannot be access address or be 1 bit different */ - aa = aa_high; - aa = (aa << 16) | aa_low; - bits_diff = 0; - temp = aa ^ BLE_ACCESS_ADDR_ADV; - for (mask = 0x00000001; mask != 0; mask <<= 1) { - if (mask & temp) { - ++bits_diff; - if (bits_diff > 1) { - break; - } - } - } - if (bits_diff <= 1) { - continue; - } - - /* Cannot have more than 24 transitions */ - transitions = 0; - consecutive = 1; - ones = 0; - mask = 0x00000001; - while (mask < 0x80000000) { - prev_bit = aa & mask; - mask <<= 1; - if (mask & aa) { - if (prev_bit == 0) { - ++transitions; - consecutive = 1; - } else { - ++consecutive; - } - } else { - if (prev_bit == 0) { - ++consecutive; - } else { - ++transitions; - consecutive = 1; - } - } - - if (prev_bit) { - ones++; - } - - /* 8 lsb should have at least three 1 */ - if (mask == 0x00000100 && ones < 3) { - break; - } - - /* 16 lsb should have no more than 11 transitions */ - if (mask == 0x00010000 && transitions > 11) { - break; - } - - /* This is invalid! */ - if (consecutive > 6) { - /* Make sure we always detect invalid sequence below */ - mask = 0; - break; - } - } - - /* Invalid sequence found */ - if (mask != 0x80000000) { - continue; - } - - /* Cannot be more than 24 transitions */ - if (transitions > 24) { - continue; - } - - /* We have a valid access address */ - break; - } - return aa; -} - -static uint8_t -ble_ll_conn_remapped_channel(uint8_t remap_index, const uint8_t *chanmap) -{ - uint8_t cntr; - uint8_t mask; - uint8_t usable_chans; - uint8_t chan; - int i, j; - - /* NOTE: possible to build a map but this would use memory. For now, - we just calculate */ - /* Iterate through channel map to find this channel */ - chan = 0; - cntr = 0; - for (i = 0; i < BLE_LL_CONN_CHMAP_LEN; i++) { - usable_chans = chanmap[i]; - if (usable_chans != 0) { - mask = 0x01; - for (j = 0; j < 8; j++) { - if (usable_chans & mask) { - if (cntr == remap_index) { - return (chan + j); - } - ++cntr; - } - mask <<= 1; - } - } - chan += 8; - } - - /* we should never reach here */ - BLE_LL_ASSERT(0); - return 0; -} - -#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) -static uint16_t -ble_ll_conn_csa2_perm(uint16_t in) -{ - uint16_t out = 0; - int i; - - for (i = 0; i < 8; i++) { - out |= ((in >> i) & 0x00000001) << (7 - i); - } - - for (i = 8; i < 16; i++) { - out |= ((in >> i) & 0x00000001) << (15 + 8 - i); - } - - return out; -} - -static uint16_t -ble_ll_conn_csa2_prng(uint16_t counter, uint16_t ch_id) -{ - uint16_t prn_e; - - prn_e = counter ^ ch_id; - - prn_e = ble_ll_conn_csa2_perm(prn_e); - prn_e = (prn_e * 17) + ch_id; - - prn_e = ble_ll_conn_csa2_perm(prn_e); - prn_e = (prn_e * 17) + ch_id; - - prn_e = ble_ll_conn_csa2_perm(prn_e); - prn_e = (prn_e * 17) + ch_id; - - prn_e = prn_e ^ ch_id; - - return prn_e; -} - -static uint8_t -ble_ll_conn_calc_dci_csa2(struct ble_ll_conn_sm *conn) -{ - uint16_t channel_unmapped; - uint8_t remap_index; - - uint16_t prn_e; - uint8_t bitpos; - - prn_e = ble_ll_conn_csa2_prng(conn->event_cntr, conn->channel_id); - - channel_unmapped = prn_e % 37; - - /* - * If unmapped channel is the channel index of a used channel it is used - * as channel index. - */ - bitpos = 1 << (channel_unmapped & 0x07); - if (conn->chanmap[channel_unmapped >> 3] & bitpos) { - return channel_unmapped; - } - - remap_index = (conn->num_used_chans * prn_e) / 0x10000; - - return ble_ll_conn_remapped_channel(remap_index, conn->chanmap); -} -#endif - static uint8_t ble_ll_conn_calc_dci_csa1(struct ble_ll_conn_sm *conn) { @@ -738,7 +488,7 @@ ble_ll_conn_calc_dci_csa1(struct ble_ll_conn_sm *conn) /* Calculate remap index */ remap_index = curchan % conn->num_used_chans; - return ble_ll_conn_remapped_channel(remap_index, conn->chanmap); + return ble_ll_utils_remapped_channel(remap_index, conn->chanmap); } /** @@ -757,7 +507,8 @@ ble_ll_conn_calc_dci(struct ble_ll_conn_sm *conn, uint16_t latency) #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) if (CONN_F_CSA2_SUPP(conn)) { - return ble_ll_conn_calc_dci_csa2(conn); + return ble_ll_utils_calc_dci_csa2(conn->event_cntr, conn->channel_id, + conn->num_used_chans, conn->chanmap); } #endif @@ -1722,7 +1473,7 @@ ble_ll_conn_master_common_init(struct ble_ll_conn_sm *connsm) BLE_LL_CONN_CHMAP_LEN); /* Calculate random access address and crc initialization value */ - connsm->access_addr = ble_ll_conn_calc_access_addr(); + connsm->access_addr = ble_ll_utils_calc_access_addr(); connsm->crcinit = rand() & 0xffffff; /* Set initial schedule callback */ @@ -2322,7 +2073,7 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm) * transmitted update request. Would end up killing connection on slave side. Could ignore it or see if still enqueued. */ connsm->num_used_chans = - ble_ll_conn_calc_used_chans(connsm->req_chanmap); + ble_ll_utils_calc_num_used_chans(connsm->req_chanmap); memcpy(connsm->chanmap, connsm->req_chanmap, BLE_LL_CONN_CHMAP_LEN); connsm->csmflags.cfbit.chanmap_update_scheduled = 0; @@ -4281,7 +4032,7 @@ ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr, connsm->peer_addr_type = pat; /* Calculate number of used channels; make sure it meets min requirement */ - connsm->num_used_chans = ble_ll_conn_calc_used_chans(connsm->chanmap); + connsm->num_used_chans = ble_ll_utils_calc_num_used_chans(connsm->chanmap); if (connsm->num_used_chans < 2) { goto err_slave_start; } diff --git a/nimble/controller/src/ble_ll_conn_hci.c b/nimble/controller/src/ble_ll_conn_hci.c index 1a8d3a03f..4467a3ea9 100644 --- a/nimble/controller/src/ble_ll_conn_hci.c +++ b/nimble/controller/src/ble_ll_conn_hci.c @@ -27,6 +27,7 @@ #include "nimble/hci_common.h" #include "nimble/ble_hci_trans.h" #include "controller/ble_ll.h" +#include "controller/ble_ll_utils.h" #include "controller/ble_ll_hci.h" #include "controller/ble_ll_conn.h" #include "controller/ble_ll_ctrl.h" @@ -1234,7 +1235,7 @@ ble_ll_conn_hci_set_chan_class(uint8_t *cmdbuf) * I will not allow this command if there are less than 2 channels masked. */ rc = BLE_ERR_SUCCESS; - num_used_chans = ble_ll_conn_calc_used_chans(cmdbuf); + num_used_chans = ble_ll_utils_calc_num_used_chans(cmdbuf); if ((num_used_chans < 2) || ((cmdbuf[4] & 0xe0) != 0)) { rc = BLE_ERR_INV_HCI_CMD_PARMS; } diff --git a/nimble/controller/src/ble_ll_conn_priv.h b/nimble/controller/src/ble_ll_conn_priv.h index bde7efac0..29a2056dd 100644 --- a/nimble/controller/src/ble_ll_conn_priv.h +++ b/nimble/controller/src/ble_ll_conn_priv.h @@ -136,7 +136,6 @@ void ble_ll_conn_init_wfr_timer_exp(void); int ble_ll_conn_is_lru(struct ble_ll_conn_sm *s1, struct ble_ll_conn_sm *s2); uint32_t ble_ll_conn_get_ce_end_time(void); void ble_ll_conn_event_halt(void); -uint8_t ble_ll_conn_calc_used_chans(uint8_t *chmap); void ble_ll_conn_reset_pending_aux_conn_rsp(void); bool ble_ll_conn_init_pending_aux_conn_rsp(void); /* HCI */ diff --git a/nimble/controller/src/ble_ll_utils.c b/nimble/controller/src/ble_ll_utils.c new file mode 100644 index 000000000..2daf57a38 --- /dev/null +++ b/nimble/controller/src/ble_ll_utils.c @@ -0,0 +1,273 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +#include "nimble/ble.h" +#include "controller/ble_ll.h" +#include "controller/ble_ll_utils.h" + +/* 37 bits require 5 bytes */ +#define BLE_LL_CHMAP_LEN (5) + +uint32_t +ble_ll_utils_calc_access_addr(void) +{ + uint32_t aa; + uint16_t aa_low; + uint16_t aa_high; + uint32_t temp; + uint32_t mask; + uint32_t prev_bit; + uint8_t bits_diff; + uint8_t consecutive; + uint8_t transitions; + uint8_t ones; + int tmp; + + /* Calculate a random access address */ + aa = 0; + while (1) { + /* Get two, 16-bit random numbers */ + aa_low = rand() & 0xFFFF; + aa_high = rand() & 0xFFFF; + + /* All four bytes cannot be equal */ + if (aa_low == aa_high) { + continue; + } + + /* Upper 6 bits must have 2 transitions */ + tmp = (int16_t)aa_high >> 10; + if (__builtin_popcount(tmp ^ (tmp >> 1)) < 2) { + continue; + } + + /* Cannot be access address or be 1 bit different */ + aa = aa_high; + aa = (aa << 16) | aa_low; + bits_diff = 0; + temp = aa ^ BLE_ACCESS_ADDR_ADV; + for (mask = 0x00000001; mask != 0; mask <<= 1) { + if (mask & temp) { + ++bits_diff; + if (bits_diff > 1) { + break; + } + } + } + if (bits_diff <= 1) { + continue; + } + + /* Cannot have more than 24 transitions */ + transitions = 0; + consecutive = 1; + ones = 0; + mask = 0x00000001; + while (mask < 0x80000000) { + prev_bit = aa & mask; + mask <<= 1; + if (mask & aa) { + if (prev_bit == 0) { + ++transitions; + consecutive = 1; + } else { + ++consecutive; + } + } else { + if (prev_bit == 0) { + ++consecutive; + } else { + ++transitions; + consecutive = 1; + } + } + + if (prev_bit) { + ones++; + } + + /* 8 lsb should have at least three 1 */ + if (mask == 0x00000100 && ones < 3) { + break; + } + + /* 16 lsb should have no more than 11 transitions */ + if (mask == 0x00010000 && transitions > 11) { + break; + } + + /* This is invalid! */ + if (consecutive > 6) { + /* Make sure we always detect invalid sequence below */ + mask = 0; + break; + } + } + + /* Invalid sequence found */ + if (mask != 0x80000000) { + continue; + } + + /* Cannot be more than 24 transitions */ + if (transitions > 24) { + continue; + } + + /* We have a valid access address */ + break; + } + return aa; +} + +uint8_t +ble_ll_utils_remapped_channel(uint8_t remap_index, const uint8_t *chanmap) +{ + uint8_t cntr; + uint8_t mask; + uint8_t usable_chans; + uint8_t chan; + int i, j; + + /* NOTE: possible to build a map but this would use memory. For now, + * we just calculate + * Iterate through channel map to find this channel + */ + chan = 0; + cntr = 0; + for (i = 0; i < BLE_LL_CHMAP_LEN; i++) { + usable_chans = chanmap[i]; + if (usable_chans != 0) { + mask = 0x01; + for (j = 0; j < 8; j++) { + if (usable_chans & mask) { + if (cntr == remap_index) { + return (chan + j); + } + ++cntr; + } + mask <<= 1; + } + } + chan += 8; + } + + /* we should never reach here */ + BLE_LL_ASSERT(0); + return 0; +} + +uint8_t +ble_ll_utils_calc_num_used_chans(const uint8_t *chmap) +{ + int i; + int j; + uint8_t mask; + uint8_t chanbyte; + uint8_t used_channels; + + used_channels = 0; + for (i = 0; i < BLE_LL_CHMAP_LEN; ++i) { + chanbyte = chmap[i]; + if (chanbyte) { + if (chanbyte == 0xff) { + used_channels += 8; + } else { + mask = 0x01; + for (j = 0; j < 8; ++j) { + if (chanbyte & mask) { + ++used_channels; + } + mask <<= 1; + } + } + } + } + return used_channels; +} + +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) +static uint16_t +ble_ll_utils_csa2_perm(uint16_t in) +{ + uint16_t out = 0; + int i; + + for (i = 0; i < 8; i++) { + out |= ((in >> i) & 0x00000001) << (7 - i); + } + + for (i = 8; i < 16; i++) { + out |= ((in >> i) & 0x00000001) << (15 + 8 - i); + } + + return out; +} + +static uint16_t +ble_ll_utils_csa2_prng(uint16_t counter, uint16_t ch_id) +{ + uint16_t prn_e; + + prn_e = counter ^ ch_id; + + prn_e = ble_ll_utils_csa2_perm(prn_e); + prn_e = (prn_e * 17) + ch_id; + + prn_e = ble_ll_utils_csa2_perm(prn_e); + prn_e = (prn_e * 17) + ch_id; + + prn_e = ble_ll_utils_csa2_perm(prn_e); + prn_e = (prn_e * 17) + ch_id; + + prn_e = prn_e ^ ch_id; + + return prn_e; +} + +uint8_t +ble_ll_utils_calc_dci_csa2(uint16_t event_cntr, uint16_t channel_id, + uint8_t num_used_chans, const uint8_t *chanmap) +{ + uint16_t channel_unmapped; + uint8_t remap_index; + + uint16_t prn_e; + uint8_t bitpos; + + prn_e = ble_ll_utils_csa2_prng(event_cntr, channel_id); + + channel_unmapped = prn_e % 37; + + /* + * If unmapped channel is the channel index of a used channel it is used + * as channel index. + */ + bitpos = 1 << (channel_unmapped & 0x07); + if (chanmap[channel_unmapped >> 3] & bitpos) { + return channel_unmapped; + } + + remap_index = (num_used_chans * prn_e) / 0x10000; + + return ble_ll_utils_remapped_channel(remap_index, chanmap); +} +#endif From 4e378fa40f42503e15f5fd27e5b9dff5e5de3bf2 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Thu, 31 Jan 2019 16:06:19 +0100 Subject: [PATCH 2/3] ninble/ll: Use CSA2 for secondary advertising channel selection When CSA2 support is enabled it is used for channel selection for auxilary advertising PDUs. --- nimble/controller/src/ble_ll_adv.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/nimble/controller/src/ble_ll_adv.c b/nimble/controller/src/ble_ll_adv.c index d423a6088..348a41222 100644 --- a/nimble/controller/src/ble_ll_adv.c +++ b/nimble/controller/src/ble_ll_adv.c @@ -38,6 +38,7 @@ #include "controller/ble_ll_whitelist.h" #include "controller/ble_ll_resolv.h" #include "controller/ble_ll_trace.h" +#include "controller/ble_ll_utils.h" #include "ble_ll_conn_priv.h" /* XXX: TODO @@ -111,6 +112,10 @@ struct ble_ll_adv_sm uint8_t *conn_comp_ev; struct ble_npl_event adv_txdone_ev; struct ble_ll_sched_item adv_sch; +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) + uint16_t channel_id; + uint16_t event_cntr; +#endif #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) uint8_t aux_active : 1; uint8_t aux_index : 1; @@ -1131,10 +1136,14 @@ ble_ll_adv_aux_calculate(struct ble_ll_adv_sm *advsm, aux->payload_len = 0; aux->ext_hdr = 0; - /* TODO we could use CSA2 for this - * (will be needed for periodic advertising anyway) - */ +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) + aux->chan = ble_ll_utils_calc_dci_csa2(advsm->event_cntr++, + advsm->channel_id, + g_ble_ll_conn_params.num_used_chans, + g_ble_ll_conn_params.master_chan_map); +#else aux->chan = rand() % BLE_PHY_NUM_DATA_CHANS; +#endif rem_aux_data_len = AUX_DATA_LEN(advsm) - aux_data_offset; chainable = !(advsm->props & BLE_HCI_LE_SET_EXT_ADV_PROP_CONNECTABLE); @@ -1776,6 +1785,9 @@ ble_ll_adv_sm_start(struct ble_ll_adv_sm *advsm) uint8_t adv_chan; uint8_t *addr; uint8_t *evbuf; +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) + uint32_t access_addr; +#endif /* only clear flags that are not set from HCI */ advsm->flags &= ~BLE_LL_ADV_SM_FLAG_TX_ADD; @@ -1839,6 +1851,13 @@ ble_ll_adv_sm_start(struct ble_ll_adv_sm *advsm) /* Set flag telling us that advertising is enabled */ advsm->adv_enabled = 1; +#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_CSA2) == 1) + advsm->event_cntr = 0; + access_addr = ble_ll_utils_calc_access_addr(); + advsm->channel_id = ((access_addr & 0xffff0000) >> 16) ^ + (access_addr & 0x0000ffff); +#endif + /* Determine the advertising interval we will use */ if (advsm->props & BLE_HCI_LE_SET_EXT_ADV_PROP_HD_DIRECTED) { /* Set it to max. allowed for high duty cycle advertising */ From 93f9078748be03c11eba3ebaefba90da2d21e9c8 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 1 Feb 2019 11:57:31 +0100 Subject: [PATCH 3/3] nimble/ll: Don't use blacklisted channels for advertising without CSA2 Remap randomized advertising secondary channels to avodi using channels marked as bad. Signed-off-by: Szymon Janc --- nimble/controller/src/ble_ll_adv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nimble/controller/src/ble_ll_adv.c b/nimble/controller/src/ble_ll_adv.c index 348a41222..536a7b050 100644 --- a/nimble/controller/src/ble_ll_adv.c +++ b/nimble/controller/src/ble_ll_adv.c @@ -1142,7 +1142,8 @@ ble_ll_adv_aux_calculate(struct ble_ll_adv_sm *advsm, g_ble_ll_conn_params.num_used_chans, g_ble_ll_conn_params.master_chan_map); #else - aux->chan = rand() % BLE_PHY_NUM_DATA_CHANS; + aux->chan = ble_ll_utils_remapped_channel(rand() % BLE_PHY_NUM_DATA_CHANS, + g_ble_ll_conn_params.master_chan_map); #endif rem_aux_data_len = AUX_DATA_LEN(advsm) - aux_data_offset;