Skip to content

Commit dc8ba53

Browse files
m-goreckiandrzej-kaczmarek
authored andcommitted
nimble/ll: Advertising Coding Selection support
1 parent 8bb2437 commit dc8ba53

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

nimble/controller/include/controller/ble_ll.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
285285
#define BLE_LL_FEAT_CONN_SUBRATING (0x0002000000000)
286286
#define BLE_LL_FEAT_CONN_SUBRATING_HOST (0x0004000000000)
287287
#define BLE_LL_FEAT_CHANNEL_CLASS (0x0008000000000)
288+
#define BLE_LL_FEAT_ADV_CODING_SEL (0x0010000000000)
289+
#define BLE_LL_FEAT_ADV_CODING_SEL_HOST (0x0020000000000)
288290
#define BLE_LL_FEAT_CS (0x0400000000000)
289291
#define BLE_LL_FEAT_CS_HOST_SUPPORT (0x0800000000000)
290292
#define BLE_LL_FEAT_CS_PCT_QUALITY_IND (0x1000000000000)
@@ -298,8 +300,9 @@ extern STATS_SECT_DECL(ble_ll_stats) ble_ll_stats;
298300
#define BLE_LL_CONN_CLEAR_FEATURE(connsm, feature) (connsm->conn_features &= ~(feature))
299301

300302
/* All the features which can be controlled by the Host */
301-
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
302-
#define BLE_LL_HOST_CONTROLLED_FEATURES (BLE_LL_FEAT_CONN_SUBRATING_HOST)
303+
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE) | \
304+
MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
305+
#define BLE_LL_HOST_CONTROLLED_FEATURES (1)
303306
#else
304307
#define BLE_LL_HOST_CONTROLLED_FEATURES (0)
305308
#endif

nimble/controller/src/ble_ll.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ static int8_t g_ble_ll_tx_power_phy_current;
8686
int8_t g_ble_ll_tx_power_compensation;
8787
int8_t g_ble_ll_rx_power_compensation;
8888

89+
#if BLE_LL_HOST_CONTROLLED_FEATURES
90+
static const uint64_t g_ble_ll_host_controlled_features =
91+
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_ENHANCED_CONN_UPDATE)
92+
BLE_LL_FEAT_CONN_SUBRATING_HOST |
93+
#endif
94+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
95+
BLE_LL_FEAT_ADV_CODING_SEL_HOST |
96+
#endif
97+
0;
98+
#endif
99+
89100
/* Supported states */
90101
#if MYNEWT_VAL(BLE_LL_ROLE_BROADCASTER)
91102
#define BLE_LL_S_NCA ((uint64_t)1 << 0)
@@ -1491,7 +1502,7 @@ ble_ll_set_host_feat(const uint8_t *cmdbuf, uint8_t len)
14911502
}
14921503

14931504
mask = (uint64_t)1 << (cmd->bit_num);
1494-
if (!(mask & BLE_LL_HOST_CONTROLLED_FEATURES)) {
1505+
if (!(mask & g_ble_ll_host_controlled_features)) {
14951506
return BLE_ERR_UNSUPPORTED;
14961507
}
14971508

@@ -1947,6 +1958,10 @@ ble_ll_init(void)
19471958
features |= BLE_LL_FEAT_PERIODIC_ADV_ADI;
19481959
#endif
19491960

1961+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
1962+
features |= BLE_LL_FEAT_ADV_CODING_SEL;
1963+
#endif
1964+
19501965
lldata->ll_supp_features = features;
19511966

19521967
/* Initialize random number generation */

nimble/controller/src/ble_ll_scan_aux.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ struct ble_ll_scan_aux_data {
8484
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
8585
int8_t rpa_index;
8686
#endif
87+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
88+
uint8_t pri_phy_mode;
89+
#endif
8790
};
8891

8992
#define AUX_MEMPOOL_SIZE (OS_MEMPOOL_SIZE( \
@@ -216,7 +219,8 @@ ble_ll_scan_aux_need_truncation(struct ble_ll_scan_aux_data *aux)
216219
}
217220

218221
static struct ble_hci_ev *
219-
ble_ll_hci_ev_alloc_ext_adv_report_for_aux(struct ble_ll_scan_addr_data *addrd,
222+
ble_ll_hci_ev_alloc_ext_adv_report_for_aux(struct ble_mbuf_hdr_rxinfo *rxinfo,
223+
struct ble_ll_scan_addr_data *addrd,
220224
struct ble_ll_scan_aux_data *aux)
221225
{
222226
struct ble_hci_ev_le_subev_ext_adv_rpt *hci_subev;
@@ -257,6 +261,16 @@ ble_ll_hci_ev_alloc_ext_adv_report_for_aux(struct ble_ll_scan_addr_data *addrd,
257261
report->tx_power = 0x7f;
258262
report->rssi = 0x7f;
259263
report->periodic_itvl = 0;
264+
265+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
266+
if (aux->pri_phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
267+
report->pri_phy = 0x04;
268+
}
269+
if (rxinfo->phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
270+
report->sec_phy = 0x04;
271+
}
272+
#endif
273+
260274
if (addrd->targeta) {
261275
report->evt_type |= BLE_HCI_ADV_DIRECT_MASK;
262276
report->dir_addr_type = addrd->targeta_type;
@@ -326,6 +340,12 @@ ble_ll_hci_ev_update_ext_adv_report_from_aux(struct ble_hci_ev *hci_ev,
326340
}
327341
report->sec_phy = rxhdr->rxinfo.phy;
328342

343+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
344+
if (rxhdr->rxinfo.phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
345+
report->sec_phy = 0x04;
346+
}
347+
#endif
348+
329349
/* Strip PDU header and ext header, leave only AD */
330350
os_mbuf_adj(rxpdu, 3 + eh_len);
331351

@@ -419,6 +439,12 @@ ble_ll_hci_ev_update_ext_adv_report_from_ext(struct ble_hci_ev *hci_ev,
419439
report->periodic_itvl = 0;
420440
report->data_len = 0;
421441

442+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
443+
if (rxinfo->phy_mode == BLE_PHY_MODE_CODED_500KBPS) {
444+
report->pri_phy = 0x04;
445+
}
446+
#endif
447+
422448
/* Now parse extended header... */
423449

424450
if (eh_flags & (1 << BLE_LL_EXT_ADV_ADVA_BIT)) {
@@ -609,7 +635,7 @@ ble_ll_hci_ev_send_ext_adv_report_for_aux(struct os_mbuf *rxpdu,
609635
hci_ev = aux->hci_ev;
610636
aux->hci_ev = NULL;
611637
} else {
612-
hci_ev = ble_ll_hci_ev_alloc_ext_adv_report_for_aux(addrd, aux);
638+
hci_ev = ble_ll_hci_ev_alloc_ext_adv_report_for_aux(&rxhdr->rxinfo, addrd, aux);
613639
if (!hci_ev) {
614640
aux->hci_state = BLE_LL_SCAN_AUX_H_DONE;
615641
return -1;
@@ -1077,6 +1103,10 @@ ble_ll_scan_aux_rx_isr_end_on_ext(struct ble_ll_scan_sm *scansm,
10771103
aux->pri_phy = rxinfo->phy;
10781104
aux->aux_ptr = aux_ptr;
10791105

1106+
#if MYNEWT_VAL(BLE_LL_ADV_CODING_SELECTION)
1107+
aux->pri_phy_mode = rxinfo->phy_mode;
1108+
#endif
1109+
10801110
if (addrd.adva) {
10811111
memcpy(aux->adva, addrd.adva, 6);
10821112
aux->adva_type = addrd.adva_type;

nimble/controller/syscfg.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,13 @@ syscfg.defs:
357357
restrictions:
358358
- '(BLE_VERSION >= 53) if 1'
359359

360+
BLE_LL_ADV_CODING_SELECTION:
361+
description: >
362+
Enables support Advertising Coding Selection.
363+
value: 0
364+
restrictions:
365+
- '(BLE_VERSION >= 54) if 1'
366+
360367
BLE_LL_PERIODIC_ADV_SYNC_BIGINFO_REPORTS:
361368
description: >
362369
This option is used to enable/disable support for

0 commit comments

Comments
 (0)