From 30903d4893d8b2448c769bac4df6df8318f3f4e8 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Wed, 14 Aug 2024 15:05:37 +0530 Subject: [PATCH] nimble/host: Add support for ext adv param v2 HCI command --- nimble/host/include/host/ble_gap.h | 8 +++++++ nimble/host/src/ble_gap.c | 18 ++++++++++++++-- nimble/include/nimble/hci_common.h | 21 +++++++++++++++++++ .../examples/linux/include/syscfg/syscfg.h | 4 ++++ .../linux_blemesh/include/syscfg/syscfg.h | 4 ++++ .../examples/nuttx/include/syscfg/syscfg.h | 4 ++++ porting/nimble/include/syscfg/syscfg.h | 4 ++++ porting/npl/riot/include/syscfg/syscfg.h | 4 ++++ 8 files changed, 65 insertions(+), 2 deletions(-) diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index e842ae29a..152ec5ddf 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -1582,6 +1582,14 @@ struct ble_gap_ext_adv_params { /** Advertising Set ID */ uint8_t sid; + +#if MYNEWT_VAL(BLE_EXT_ADV_V2) + /** Primary phy options */ + uint8_t pri_phy_opt; + + /** Secondary phy options */ + uint8_t sec_phy_opt; +#endif }; /** diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 38da71200..3f1ac7d15 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -3129,8 +3129,14 @@ ble_gap_ext_adv_params_tx(uint8_t instance, int8_t *selected_tx_power) { +#if MYNEWT_VAL(BLE_EXT_ADV_V2) + struct ble_hci_le_set_ext_adv_params_v2_cp cmd; +#else struct ble_hci_le_set_ext_adv_params_cp cmd; +#endif + struct ble_hci_le_set_ext_adv_params_rp rsp; + uint16_t opcode; int rc; memset(&cmd, 0, sizeof(cmd)); @@ -3207,8 +3213,16 @@ ble_gap_ext_adv_params_tx(uint8_t instance, cmd.sid = params->sid; cmd.scan_req_notif = params->scan_req_notif; - rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE, - BLE_HCI_OCF_LE_SET_EXT_ADV_PARAM), +#if MYNEWT_VAL(BLE_EXT_ADV_V2) + cmd.pri_phy_opt = params->pri_phy_opt; + cmd.sec_phy_opt = params->sec_phy_opt; + + opcode = BLE_HCI_OCF_LE_SET_EXT_ADV_PARAM_V2; +#else + opcode = BLE_HCI_OCF_LE_SET_EXT_ADV_PARAM; +#endif + + rc = ble_hs_hci_cmd_tx(BLE_HCI_OP(BLE_HCI_OGF_LE, opcode), &cmd, sizeof(cmd), &rsp, sizeof(rsp)); if (rc != 0) { diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h index b1f626126..34b9102e6 100644 --- a/nimble/include/nimble/hci_common.h +++ b/nimble/include/nimble/hci_common.h @@ -597,6 +597,27 @@ struct ble_hci_le_set_ext_adv_params_rp { int8_t tx_power; } __attribute__((packed)); +#define BLE_HCI_OCF_LE_SET_EXT_ADV_PARAM_V2 (0x007F) +struct ble_hci_le_set_ext_adv_params_v2_cp { + uint8_t adv_handle; + uint16_t props; + uint8_t pri_itvl_min[3]; + uint8_t pri_itvl_max[3]; + uint8_t pri_chan_map; + uint8_t own_addr_type; + uint8_t peer_addr_type; + uint8_t peer_addr[6]; + uint8_t filter_policy; + int8_t tx_power; + uint8_t pri_phy; + uint8_t sec_max_skip; + uint8_t sec_phy; + uint8_t sid; + uint8_t scan_req_notif; + uint8_t pri_phy_opt; + uint8_t sec_phy_opt; +} __attribute__((packed)); + #define BLE_HCI_OCF_LE_SET_EXT_ADV_DATA (0x0037) struct ble_hci_le_set_ext_adv_data_cp { uint8_t adv_handle; diff --git a/porting/examples/linux/include/syscfg/syscfg.h b/porting/examples/linux/include/syscfg/syscfg.h index 9c3680da4..5c8f9d90b 100644 --- a/porting/examples/linux/include/syscfg/syscfg.h +++ b/porting/examples/linux/include/syscfg/syscfg.h @@ -433,6 +433,10 @@ #define MYNEWT_VAL_BLE_EXT_ADV (0) #endif +#ifndef MYNEWT_VAL_BLE_EXT_ADV_V2 +#define MYNEWT_VAL_BLE_EXT_ADV_V2 (0) +#endif + #ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) #endif diff --git a/porting/examples/linux_blemesh/include/syscfg/syscfg.h b/porting/examples/linux_blemesh/include/syscfg/syscfg.h index 1bd9f4271..1ac52f824 100644 --- a/porting/examples/linux_blemesh/include/syscfg/syscfg.h +++ b/porting/examples/linux_blemesh/include/syscfg/syscfg.h @@ -433,6 +433,10 @@ #define MYNEWT_VAL_BLE_EXT_ADV (0) #endif +#ifndef MYNEWT_VAL_BLE_EXT_ADV_V2 +#define MYNEWT_VAL_BLE_EXT_ADV_V2 (0) +#endif + #ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) #endif diff --git a/porting/examples/nuttx/include/syscfg/syscfg.h b/porting/examples/nuttx/include/syscfg/syscfg.h index f9a75854c..9c191d1ea 100644 --- a/porting/examples/nuttx/include/syscfg/syscfg.h +++ b/porting/examples/nuttx/include/syscfg/syscfg.h @@ -433,6 +433,10 @@ #define MYNEWT_VAL_BLE_EXT_ADV (0) #endif +#ifndef MYNEWT_VAL_BLE_EXT_ADV_V2 +#define MYNEWT_VAL_BLE_EXT_ADV_V2 (0) +#endif + #ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) #endif diff --git a/porting/nimble/include/syscfg/syscfg.h b/porting/nimble/include/syscfg/syscfg.h index 4b32ec556..79ec447fb 100644 --- a/porting/nimble/include/syscfg/syscfg.h +++ b/porting/nimble/include/syscfg/syscfg.h @@ -433,6 +433,10 @@ #define MYNEWT_VAL_BLE_EXT_ADV (0) #endif +#ifndef MYNEWT_VAL_BLE_EXT_ADV_V2 +#define MYNEWT_VAL_BLE_EXT_ADV_V2 (0) +#endif + #ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) #endif diff --git a/porting/npl/riot/include/syscfg/syscfg.h b/porting/npl/riot/include/syscfg/syscfg.h index de90aae2b..ffaea53e6 100644 --- a/porting/npl/riot/include/syscfg/syscfg.h +++ b/porting/npl/riot/include/syscfg/syscfg.h @@ -1081,6 +1081,10 @@ #define MYNEWT_VAL_BLE_EXT_ADV (0) #endif +#ifndef MYNEWT_VAL_BLE_EXT_ADV_V2 +#define MYNEWT_VAL_BLE_EXT_ADV_V2 (0) +#endif + #ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE #define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31) #endif