Skip to content

Commit

Permalink
nimble/host: Add support for ext adv param v2 HCI command
Browse files Browse the repository at this point in the history
  • Loading branch information
rahult-github committed Aug 14, 2024
1 parent 49db784 commit a24f87f
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 2 deletions.
8 changes: 8 additions & 0 deletions nimble/host/include/host/ble_gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand Down
18 changes: 16 additions & 2 deletions nimble/host/src/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions nimble/include/nimble/hci_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/linux/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/linux_blemesh/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions porting/examples/nuttx/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions porting/nimble/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions porting/npl/riot/include/syscfg/syscfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a24f87f

Please sign in to comment.