From b8d073bcb0ece6edcd1e71b52ed9f31b73397da5 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Fri, 18 Aug 2023 15:25:49 +0530 Subject: [PATCH] Add support for LE Set Data Related Address change command --- nimble/host/include/host/ble_gap.h | 11 +++++++++++ nimble/host/src/ble_gap.c | 6 ++++++ nimble/host/src/ble_hs_hci_priv.h | 1 + nimble/host/src/ble_hs_hci_util.c | 14 ++++++++++++++ nimble/include/nimble/hci_common.h | 6 ++++++ 5 files changed, 38 insertions(+) diff --git a/nimble/host/include/host/ble_gap.h b/nimble/host/include/host/ble_gap.h index 5bc77cc81..57887e146 100644 --- a/nimble/host/include/host/ble_gap.h +++ b/nimble/host/include/host/ble_gap.h @@ -2672,6 +2672,17 @@ int ble_gap_set_path_loss_reporting_param(uint16_t conn_handle, uint8_t high_thr uint8_t high_hysteresis, uint8_t low_threshold, uint8_t low_hysteresis, uint16_t min_time_spent); #endif + +/** + * Set Data Related Address Changes Param + * + * @param adv_handle Advertising handle + * @param change_reason Reasons for refreshing addresses + * + * @return 0 on success; nonzero on failure. + */ +int ble_gap_set_data_related_addr_change_param(uint8_t adv_handle, uint8_t change_reason); + #ifdef __cplusplus } #endif diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c index 216902a8f..f100e1a43 100644 --- a/nimble/host/src/ble_gap.c +++ b/nimble/host/src/ble_gap.c @@ -7317,6 +7317,12 @@ ble_gap_set_auto_pcl_param(struct ble_gap_set_auto_pcl_params *params) } #endif +int +ble_gap_set_data_related_addr_change_param(uint8_t adv_handle, uint8_t change_reason) +{ + return ble_hs_hci_util_set_data_addr_change(adv_handle, change_reason); +} + void ble_gap_deinit(void) { diff --git a/nimble/host/src/ble_hs_hci_priv.h b/nimble/host/src/ble_hs_hci_priv.h index 49bdd1f0d..693154103 100644 --- a/nimble/host/src/ble_hs_hci_priv.h +++ b/nimble/host/src/ble_hs_hci_priv.h @@ -125,6 +125,7 @@ int ble_hs_hci_acl_tx(struct ble_hs_conn *conn, struct os_mbuf **om); int ble_hs_hci_frag_num_mbufs(void); int ble_hs_hci_frag_num_mbufs_free(void); +int ble_hs_hci_util_set_data_addr_change(uint8_t adv_handle, uint8_t change_reason); #ifdef __cplusplus } #endif diff --git a/nimble/host/src/ble_hs_hci_util.c b/nimble/host/src/ble_hs_hci_util.c index 95108a77a..7154632d9 100644 --- a/nimble/host/src/ble_hs_hci_util.c +++ b/nimble/host/src/ble_hs_hci_util.c @@ -277,3 +277,17 @@ ble_hs_hci_set_chan_class(const uint8_t *chan_map) BLE_HCI_OCF_LE_SET_HOST_CHAN_CLASS), &cmd, sizeof(cmd), NULL, 0); } + +int +ble_hs_hci_util_set_data_addr_change(uint8_t adv_handle, uint8_t change_reason) +{ + struct ble_hci_le_set_data_addr_change_cp cmd; + uint16_t opcode; + + opcode = BLE_HCI_OP(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_DATA_ADDR_CHANGE); + + cmd.adv_handle = adv_handle; + cmd.change_reason = change_reason; + + return ble_hs_hci_cmd_tx(opcode, &cmd, sizeof(cmd), NULL, 0); +} diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h index 63b4e24ba..fa85deda9 100644 --- a/nimble/include/nimble/hci_common.h +++ b/nimble/include/nimble/hci_common.h @@ -1130,6 +1130,12 @@ struct ble_hci_le_set_transmit_power_report_enable_cp { uint8_t remote_enable; } __attribute__((packed)); +#define BLE_HCI_OCF_LE_SET_DATA_ADDR_CHANGE (0x007C) +struct ble_hci_le_set_data_addr_change_cp { + uint8_t adv_handle; + uint8_t change_reason; +} __attribute__((packed)); + #define BLE_HCI_OCF_LE_SET_DEFAULT_SUBRATE (0x007D) struct ble_hci_le_set_default_subrate_cp { uint16_t subrate_min;