feat: add vs cmd support for adv constant did and scan adi filter

This commit is contained in:
cjin
2025-12-11 20:27:49 +08:00
committed by Rahul Tank
parent d9a6fa8630
commit 886039b39b
4 changed files with 79 additions and 0 deletions
+34
View File
@@ -279,6 +279,40 @@ int ble_gap_set_chan_select(uint8_t select);
*/
int ble_gap_set_scan_chan(uint8_t state, uint8_t *bitmap);
#if MYNEWT_VAL(BLE_ADV_SEND_CONSTANT_DID)
/**
* This API is used to make extended adv send with specific DID
*
* @param handle
* @param enable
* @param did
* @return int
*/
int ble_gap_set_adv_constant_did(uint16_t handle, uint8_t enable, uint16_t did);
#endif // MYNEWT_VAL(BLE_ADV_SEND_CONSTANT_DID)
#if MYNEWT_VAL(BLE_SCAN_ALLOW_ENH_ADI_FILTER)
struct ble_gap_adi_filter_entry {
uint8_t sid;
uint16_t did_cnt;
uint16_t did[0];
};
/**
* This API is used to configure the ADI filter options for the extended scan.
*
* @param enable 0: Disable ADI filtering
* 1: Enable ADI filter
* @param did_filter 0: Enable filter of SID only
* 1: Enable filter of both DID and SID
* @param sid_cnt Number of SID to allow receiving
* @param filter_list Array of filter list pointers to store the SID
* and DID combinations allowed for reception
* @return int
*/
int ble_gap_config_ext_scan_adi_filter(uint8_t enable, uint8_t did_filter, uint8_t sid_cnt, struct ble_gap_adi_filter_entry *filter_list[]);
#endif // MYNEWT_VAL(BLE_SCAN_ALLOW_ENH_ADI_FILTER)
#endif
/**
+8
View File
@@ -2686,6 +2686,14 @@ struct ble_gap_set_periodic_adv_subev_data_params {
};
#endif
#if MYNEWT_VAL(BLE_ADV_SEND_CONSTANT_DID)
struct ble_gap_adv_const_did_cmd_params {
uint16_t handle;
uint8_t enable;
uint16_t did;
};
#endif // MYNEWT_VAL(BLE_ADV_SEND_CONSTANT_DID)
/**
* Configure periodic advertising for specified advertising instance
*
+35
View File
@@ -10338,6 +10338,41 @@ int ble_gap_set_scan_chan(uint8_t state, uint8_t *bitmap)
return ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_SET_SCAN_CHAN,
&vs_cmd, sizeof(vs_cmd), NULL, 0);
}
#if MYNEWT_VAL(BLE_ADV_SEND_CONSTANT_DID)
int ble_gap_set_adv_constant_did(uint16_t handle, uint8_t enable, uint16_t did)
{
struct ble_gap_adv_const_did_cmd_params vs_cmd;
vs_cmd.handle = handle;
vs_cmd.enable = enable;
vs_cmd.did = did;
return ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_SET_ADV_DID,
&vs_cmd, sizeof(vs_cmd), NULL, 0);
}
#endif // MYNEWT_VAL(BLE_ADV_SEND_CONSTANT_DID)
#if MYNEWT_VAL(BLE_SCAN_ALLOW_ENH_ADI_FILTER)
/* filter list in format struct ble_gap_adi_filter_entry */
int ble_gap_config_ext_scan_adi_filter(uint8_t enable, uint8_t did_filter, uint8_t sid_cnt,
struct ble_gap_adi_filter_entry *filter_list[])
{
uint8_t vs_cmd[64];
memset(vs_cmd, 0x0, sizeof(vs_cmd));
if (sid_cnt > 15) {
return BLE_HS_EINVAL;
}
vs_cmd[0] = enable;
vs_cmd[1] = did_filter;
vs_cmd[2] = sid_cnt;
memcpy(&vs_cmd[3], filter_list, sid_cnt * sizeof(struct ble_gap_adi_filter_entry *));
return ble_hs_hci_send_vs_cmd(BLE_HCI_OCF_VS_SET_SCAN_SID,
&vs_cmd, sid_cnt * sizeof(struct ble_gap_adi_filter_entry *) + 3, NULL, 0);
}
#endif // MYNEWT_VAL(BLE_SCAN_ALLOW_ENH_ADI_FILTER)
#endif
#if MYNEWT_VAL(BLE_UTIL_API)
+2
View File
@@ -1663,6 +1663,8 @@ struct ble_hci_vs_duplicate_exception_list_cp {
#define BLE_HCI_OCF_VS_SET_EVT_MASK (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0116))
#define BLE_HCI_OCF_VS_SET_SCAN_CHAN (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0119))
#define BLE_HCI_OCF_VS_SET_ADV_DID (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x012A))
#define BLE_HCI_OCF_VS_SET_SCAN_SID (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x012B))
struct ble_hci_vs_set_event_mask_cp {
uint32_t event_mask;