Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host: Add support for LE Set Data Related Address change command #1599

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions nimble/host/include/host/ble_gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since behavior is different if legacy commands are used I'd split this into two separate APIs and make parameters name follow other adv api conventions:

struct ble_gap_adv_addr_change_params {
      unsigned int on_adv_data_change : 1;
      unsigned int on_scan_rsp_change : 1;
}

int ble_gap_ext_adv_set_data_related_addr_change(uint8_t instance,
                                                 const struct ble_gap_adv_addr_change_param *params);

int ble_gap_adv_set_data_related_addr_change(const struct ble_gap_adv_addr_change_param *params);

and put them under proper ifdef sections in headers and source code.
Legacy variant can skipped as it is unlikely to be used anyway with legacy HCI.


#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions nimble/host/src/ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6756,3 +6756,9 @@ ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle,
return BLE_HS_ENOTSUP;
#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);
}
1 change: 1 addition & 0 deletions nimble/host/src/ble_hs_hci_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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
Expand Down
14 changes: 14 additions & 0 deletions nimble/host/src/ble_hs_hci_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 6 additions & 0 deletions nimble/include/nimble/hci_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading