bluedroid: add periodic adv sync transfer API and EVT

This commit is contained in:
chenjianhua 2023-01-18 16:50:27 +08:00
parent 97dd2dc88e
commit e451b967d6
21 changed files with 778 additions and 74 deletions

View File

@ -1143,3 +1143,10 @@ config BT_BLE_42_FEATURES_SUPPORTED
default n
help
This enables BLE 4.2 features.
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
bool "Enable BLE periodic advertising sync transfer feature"
depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && SOC_ESP_NIMBLE_CONTROLLER)
default n
help
This enables BLE periodic advertising sync transfer feature

View File

@ -1370,3 +1370,95 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
}
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
esp_err_t esp_ble_gap_periodic_adv_recv_enable(uint16_t sync_handle, uint8_t enable)
{
btc_msg_t msg;
btc_ble_5_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_PERIODIC_ADV_RECV_ENABLE;
arg.periodic_adv_recv_en.sync_handle = sync_handle;
arg.periodic_adv_recv_en.enable = enable;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_sync_trans(esp_bd_addr_t addr, uint16_t service_data, uint16_t sync_handle)
{
btc_msg_t msg;
btc_ble_5_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (addr == NULL) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_PERIODIC_ADV_SYNC_TRANS;
memcpy(arg.periodic_adv_sync_trans.addr, addr, sizeof(esp_bd_addr_t));
arg.periodic_adv_sync_trans.service_data = service_data;
arg.periodic_adv_sync_trans.sync_handle = sync_handle;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_set_info_trans(esp_bd_addr_t addr, uint16_t service_data, uint8_t adv_handle)
{
btc_msg_t msg;
btc_ble_5_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (addr == NULL) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS;
memcpy(arg.periodic_adv_set_info_trans.addr, addr, sizeof(esp_bd_addr_t));
arg.periodic_adv_set_info_trans.service_data = service_data;
arg.periodic_adv_set_info_trans.adv_handle = adv_handle;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_periodic_adv_sync_trans_params(esp_bd_addr_t addr, const esp_ble_gap_past_params_t *params)
{
btc_msg_t msg;
btc_ble_5_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (params == NULL) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS;
if (addr) {
memcpy(arg.set_periodic_adv_sync_trans_params.addr, addr, sizeof(esp_bd_addr_t));
} else {
memset(arg.set_periodic_adv_sync_trans_params.addr, 0, sizeof(esp_bd_addr_t));
}
memcpy(&arg.set_periodic_adv_sync_trans_params.params, params, sizeof(esp_ble_gap_past_params_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -202,6 +202,12 @@ typedef enum {
ESP_GAP_BLE_SC_OOB_REQ_EVT, /*!< Secure Connection OOB request event */
ESP_GAP_BLE_SC_CR_LOC_OOB_EVT, /*!< Secure Connection create OOB data complete event */
ESP_GAP_BLE_GET_DEV_NAME_COMPLETE_EVT, /*!< When getting BT device name complete, the event comes */
//BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
ESP_GAP_BLE_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT, /*!< when set periodic advertising receive enable complete, the event comes */
ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT, /*!< when periodic advertising sync transfer complete, the event comes */
ESP_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT, /*!< when periodic advertising set info transfer complete, the event comes */
ESP_GAP_BLE_SET_PAST_PARAMS_COMPLETE_EVT, /*!< when set periodic advertising sync transfer params complete, the event comes */
ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_RECV_EVT, /*!< when periodic advertising sync transfer received, the event comes */
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
} esp_gap_ble_cb_event_t;
@ -910,6 +916,25 @@ typedef struct {
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/// Periodic advertising sync trans mode
#define ESP_BLE_GAP_PAST_MODE_NO_SYNC_EVT (0x00) /*!< No attempt is made to sync and no periodic adv sync transfer received event */
#define ESP_BLE_GAP_PAST_MODE_NO_REPORT_EVT (0x01) /*!< An periodic adv sync transfer received event and no periodic adv report events */
#define ESP_BLE_GAP_PAST_MODE_DUP_FILTER_DISABLED (0x02) /*!< Periodic adv report events will be enabled with duplicate filtering disabled */
#define ESP_BLE_GAP_PAST_MODE_DUP_FILTER_ENABLED (0x03) /*!< Periodic adv report events will be enabled with duplicate filtering enabled */
typedef uint8_t esp_ble_gap_past_mode_t;
/**
* @brief periodic adv sync transfer parameters
*/
typedef struct {
esp_ble_gap_past_mode_t mode; /*!< periodic advertising sync transfer mode */
uint16_t skip; /*!< the number of periodic advertising packets that can be skipped */
uint16_t sync_timeout; /*!< synchronization timeout for the periodic advertising train */
uint8_t cte_type; /*!< periodic advertising sync transfer CET type */
} esp_ble_gap_past_params_t;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/**
* @brief Gap callback parameters union
*/
@ -1308,6 +1333,50 @@ typedef union {
esp_ble_gap_periodic_adv_report_t params; /*!< periodic advertising report parameters */
} period_adv_report; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT */
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/**
* @brief ESP_GAP_BLE_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT
*/
struct ble_periodic_adv_recv_enable_cmpl_param {
esp_bt_status_t status; /*!< Set periodic advertising receive enable status */
} period_adv_recv_enable; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT
*/
struct ble_periodic_adv_sync_trans_cmpl_param {
esp_bt_status_t status; /*!< Periodic advertising sync transfer status */
esp_bd_addr_t bda; /*!< The remote device address */
} period_adv_sync_trans; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT
*/
struct ble_periodic_adv_set_info_trans_cmpl_param {
esp_bt_status_t status; /*!< Periodic advertising set info transfer status */
esp_bd_addr_t bda; /*!< The remote device address */
} period_adv_set_info_trans; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_PAST_PARAMS_COMPLETE_EVT
*/
struct ble_set_past_params_cmpl_param {
esp_bt_status_t status; /*!< Set periodic advertising sync transfer params status */
esp_bd_addr_t bda; /*!< The remote device address */
} set_past_params; /*!< Event parameter of ESP_GAP_BLE_SET_PAST_PARAMS_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_RECV_EVT
*/
struct ble_periodic_adv_sync_trans_recv_param {
esp_bt_status_t status; /*!< Periodic advertising sync transfer received status */
esp_bd_addr_t bda; /*!< The remote device address */
uint16_t service_data; /*!< The value provided by the peer device */
uint16_t sync_handle; /*!< Periodic advertising sync handle */
uint8_t adv_sid; /*!< Periodic advertising set id */
uint8_t adv_addr_type; /*!< Periodic advertiser address type */
esp_bd_addr_t adv_addr; /*!< Periodic advertiser address */
esp_ble_gap_phy_t adv_phy; /*!< Periodic advertising PHY */
uint16_t adv_interval; /*!< Periodic advertising interval */
uint8_t adv_clk_accuracy; /*!< Periodic advertising clock accuracy */
} past_received; /*!< Event parameter of ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_RECV_EVT */
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
} esp_ble_gap_cb_param_t;
/**
@ -2197,6 +2266,61 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/**
* @brief This function is used to set periodic advertising receive enable
*
* @param[in] sync_handle : Handle of periodic advertising sync
* @param[in] enable : Determines whether reporting and duplicate filtering are enabled or disabled
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_periodic_adv_recv_enable(uint16_t sync_handle, uint8_t enable);
/**
* @brief This function is used to transfer periodic advertising sync
*
* @param[in] addr : Peer device address
* @param[in] service_data : Service data used by Host
* @param[in] sync_handle : Handle of periodic advertising sync
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_periodic_adv_sync_trans(esp_bd_addr_t addr,
uint16_t service_data, uint16_t sync_handle);
/**
* @brief This function is used to transfer periodic advertising set info
*
* @param[in] addr : Peer device address
* @param[in] service_data : Service data used by Host
* @param[in] adv_handle : Handle of advertising set
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_periodic_adv_set_info_trans(esp_bd_addr_t addr,
uint16_t service_data, uint8_t adv_handle);
/**
* @brief This function is used to set periodic advertising sync transfer params
*
* @param[in] addr : Peer device address
* @param[in] params : Params of periodic advertising sync transfer
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_set_periodic_adv_sync_trans_params(esp_bd_addr_t addr,
const esp_ble_gap_past_params_t *params);
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#ifdef __cplusplus
}
#endif

View File

@ -5820,6 +5820,37 @@ void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data)
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
void bta_dm_ble_gap_periodic_adv_recv_enable(tBTA_DM_MSG *p_data)
{
BTM_BlePeriodicAdvRecvEnable(p_data->ble_periodic_adv_recv_enable.sync_handle,
p_data->ble_periodic_adv_recv_enable.enable);
}
void bta_dm_ble_gap_periodic_adv_sync_trans(tBTA_DM_MSG *p_data)
{
BTM_BlePeriodicAdvSyncTrans(p_data->ble_periodic_adv_sync_trans.addr,
p_data->ble_periodic_adv_sync_trans.service_data,
p_data->ble_periodic_adv_sync_trans.sync_handle);
}
void bta_dm_ble_gap_periodic_adv_set_info_trans(tBTA_DM_MSG *p_data)
{
BTM_BlePeriodicAdvSetInfoTrans(p_data->ble_periodic_adv_set_info_trans.addr,
p_data->ble_periodic_adv_set_info_trans.service_data,
p_data->ble_periodic_adv_set_info_trans.adv_hanlde);
}
void bta_dm_ble_gap_set_periodic_adv_sync_trans_params(tBTA_DM_MSG *p_data)
{
BTM_BleSetPeriodicAdvSyncTransParams(p_data->ble_set_past_params.addr,
p_data->ble_set_past_params.params.mode,
p_data->ble_set_past_params.params.skip,
p_data->ble_set_past_params.params.sync_timeout,
p_data->ble_set_past_params.params.cte_type);
}
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/*******************************************************************************
**
** Function bta_dm_ble_setup_storage

View File

@ -3162,16 +3162,70 @@ void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_add
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
uint8_t BTA_DmBlePeriodicAdvSetInfoTrans(uint8_t addr[6], uint16_t service_data, uint8_t adv_handle)
void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable)
{
BTM_BlePeriodicAdvSetInfoTrans(addr, service_data, adv_handle);
return 0;
tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE *p_msg;
p_msg = (tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE));
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT;
p_msg->sync_handle = sync_handle;
p_msg->enable = enable;
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
uint8_t BTA_DmBleSetPeriodicAdvSyncTransParams(uint8_t addr[6], uint8_t mode, uint16_t skip, uint16_t sync_timeout)
void BTA_DmBleGapPeriodicAdvSyncTrans(BD_ADDR peer_addr, UINT16 service_data, UINT16 sync_handle)
{
BTM_BleSetPeriodicAdvSyncTransParams(addr, mode, skip, sync_timeout, 0);
return 0;
tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS *p_msg;
p_msg = (tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS));
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_TRANS_EVT;
memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR));
p_msg->service_data = service_data;
p_msg->sync_handle = sync_handle;
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvSetInfoTrans(BD_ADDR peer_addr, UINT16 service_data, UINT8 adv_handle)
{
tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS *p_msg;
p_msg = (tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS));
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS_EVT;
memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR));
p_msg->service_data = service_data;
p_msg->adv_hanlde = adv_handle;
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapSetPeriodicAdvSyncTransParams(BD_ADDR peer_addr, tBTA_DM_BLE_PAST_PARAMS *params)
{
tBTA_DM_API_SET_PAST_PARAMS *p_msg;
p_msg = (tBTA_DM_API_SET_PAST_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_SET_PAST_PARAMS));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_PAST_PARAMS));
p_msg->hdr.event = BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT;
memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR));
memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_PAST_PARAMS));
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -202,7 +202,14 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_ble_gap_set_ext_scan_params, /* BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT */
bta_dm_ble_gap_ext_scan, /* BTA_DM_API_START_EXT_SCAN_EVT */
bta_dm_ble_gap_set_prefer_ext_conn_params, /* BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT */
NULL, /* BTA_DM_API_EXT_CONN_EVT */
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
bta_dm_ble_gap_periodic_adv_recv_enable, /* BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT */
bta_dm_ble_gap_periodic_adv_sync_trans, /* BTA_DM_API_PERIODIC_ADV_SYNC_TRANS_EVT */
bta_dm_ble_gap_periodic_adv_set_info_trans, /* BTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS_EVT */
bta_dm_ble_gap_set_periodic_adv_sync_trans_params, /* BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT */
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
};

View File

@ -200,6 +200,12 @@ enum {
BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT,
BTA_DM_API_EXT_CONN_EVT,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT,
BTA_DM_API_PERIODIC_ADV_SYNC_TRANS_EVT,
BTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS_EVT,
BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT,
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
BTA_DM_MAX_EVT
};
@ -1031,6 +1037,35 @@ typedef struct {
BD_ADDR peer_addr;
} tBTA_DM_API_EXT_CONN;
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef struct {
BT_HDR hdr;
UINT16 sync_handle;
UINT8 enable;
} tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE;
typedef struct {
BT_HDR hdr;
BD_ADDR addr;
UINT16 service_data;
UINT16 sync_handle;
} tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS;
typedef struct {
BT_HDR hdr;
BD_ADDR addr;
UINT16 service_data;
UINT8 adv_hanlde;
} tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS;
typedef struct {
BT_HDR hdr;
BD_ADDR addr;
tBTA_DM_BLE_PAST_PARAMS params;
} tBTA_DM_API_SET_PAST_PARAMS;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/* union of all data types */
typedef union {
/* event buffer header */
@ -1171,6 +1206,12 @@ typedef union {
tBTA_DM_API_EXT_SCAN ble_ext_scan;
tBTA_DM_API_SET_PER_EXT_CONN_PARAMS ble_set_per_ext_conn_params;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE ble_periodic_adv_recv_enable;
tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS ble_periodic_adv_sync_trans;
tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS ble_periodic_adv_set_info_trans;
tBTA_DM_API_SET_PAST_PARAMS ble_set_past_params;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#endif
tBTA_DM_API_REMOVE_ACL remove_acl;
@ -1727,4 +1768,14 @@ extern void bta_dm_ble_gap_ext_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
extern void bta_dm_ble_gap_periodic_adv_recv_enable(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_sync_trans(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_set_info_trans(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_periodic_adv_sync_trans_params(tBTA_DM_MSG *p_data);
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#endif /* BTA_DM_INT_H */

View File

@ -1597,7 +1597,14 @@ typedef struct {
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT
#define BTA_DM_BLE_5_GAP_UNKNOWN_EVT BTM_BLE_5_GAP_UNKNOWN_EVT
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define BTA_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT
#define BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT
#define BTA_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT
#define BTA_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT
#define BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define BTA_DM_BLE_5_GAP_UNKNOWN_EVT BTM_BLE_5_GAP_UNKNOWN_EVT
typedef tBTM_BLE_5_GAP_EVENT tBTA_DM_BLE_5_GAP_EVENT;
typedef tBTM_BLE_5_GAP_CB_PARAMS tBTA_DM_BLE_5_GAP_CB_PARAMS;
@ -1607,6 +1614,15 @@ extern tBTM_BLE_5_HCI_CBACK ble_5_hci_cb;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef struct {
UINT8 mode;
UINT16 skip;
UINT16 sync_timeout;
UINT8 cte_type;
} tBTA_DM_BLE_PAST_PARAMS;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/*****************************************************************************
** External Function Declarations
*****************************************************************************/
@ -3015,6 +3031,16 @@ extern void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr,
extern void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_addr);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
extern void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable);
extern void BTA_DmBleGapPeriodicAdvSyncTrans(BD_ADDR peer_addr, UINT16 service_data, UINT16 sync_handle);
extern void BTA_DmBleGapPeriodicAdvSetInfoTrans(BD_ADDR peer_addr, UINT16 service_data, UINT8 adv_handle);
extern void BTA_DmBleGapSetPeriodicAdvSyncTransParams(BD_ADDR peer_addr, tBTA_DM_BLE_PAST_PARAMS *params);
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#endif
enum {

View File

@ -1099,6 +1099,40 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
param.periodic_adv_sync_estab.adv_clk_accuracy = params->sync_estab.adv_clk_accuracy;
break;
}
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
case BTA_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT;
param.period_adv_recv_enable.status = btc_btm_status_to_esp_status(params->per_adv_recv_enable.status);
break;
case BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT;
param.period_adv_sync_trans.status = btc_btm_status_to_esp_status(params->per_adv_sync_trans.status);
memcpy(param.period_adv_sync_trans.bda, params->per_adv_sync_trans.addr, sizeof(BD_ADDR));
break;
case BTA_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT;
param.period_adv_set_info_trans.status = btc_btm_status_to_esp_status(params->per_adv_set_info_trans.status);
memcpy(param.period_adv_set_info_trans.bda, params->per_adv_set_info_trans.addr, sizeof(BD_ADDR));
break;
case BTA_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_SET_PAST_PARAMS_COMPLETE_EVT;
param.set_past_params.status = btc_btm_status_to_esp_status(params->set_past_params.status);
memcpy(param.set_past_params.bda, params->set_past_params.addr, sizeof(BD_ADDR));
break;
case BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT:
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SYNC_TRANS_RECV_EVT;
param.past_received.status = btc_btm_status_to_esp_status(params->past_recv.status);
memcpy(param.past_received.bda, params->past_recv.addr, sizeof(BD_ADDR));
param.past_received.service_data = params->past_recv.service_data;
param.past_received.sync_handle = params->past_recv.sync_handle;
param.past_received.adv_sid = params->past_recv.adv_sid;
param.past_received.adv_addr_type = params->past_recv.adv_addr_type;
memcpy(param.past_received.adv_addr, params->past_recv.adv_addr, sizeof(BD_ADDR));
param.past_received.adv_phy = params->past_recv.adv_phy;
param.past_received.adv_interval = params->past_recv.adv_interval;
param.past_received.adv_clk_accuracy = params->past_recv.adv_clk_accuracy;
break;
#endif
default:
break;
}
@ -1960,6 +1994,30 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
(const tBTA_DM_BLE_CONN_PARAMS *)&arg_5->set_ext_conn_params.phy_coded_conn_params);
break;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
case BTC_GAP_BLE_PERIODIC_ADV_RECV_ENABLE:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_RECV_ENABLE");
BTA_DmBleGapPeriodicAdvRecvEnable(arg_5->periodic_adv_recv_en.sync_handle,
arg_5->periodic_adv_recv_en.enable);
break;
case BTC_GAP_BLE_PERIODIC_ADV_SYNC_TRANS:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_SYNC_TRANS");
BTA_DmBleGapPeriodicAdvSyncTrans(arg_5->periodic_adv_sync_trans.addr,
arg_5->periodic_adv_sync_trans.service_data,
arg_5->periodic_adv_sync_trans.sync_handle);
break;
case BTC_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS");
BTA_DmBleGapPeriodicAdvSetInfoTrans(arg_5->periodic_adv_set_info_trans.addr,
arg_5->periodic_adv_set_info_trans.service_data,
arg_5->periodic_adv_set_info_trans.adv_handle);
break;
case BTC_GAP_BLE_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS:
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS");
BTA_DmBleGapSetPeriodicAdvSyncTransParams(arg_5->set_periodic_adv_sync_trans_params.addr,
(tBTA_DM_BLE_PAST_PARAMS *)&arg_5->set_periodic_adv_sync_trans_params.params);
break;
#endif
default:
break;
}

View File

@ -86,6 +86,12 @@ typedef enum {
BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_GET_DEV_NAME,
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
BTC_GAP_BLE_PERIODIC_ADV_RECV_ENABLE,
BTC_GAP_BLE_PERIODIC_ADV_SYNC_TRANS,
BTC_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS,
BTC_GAP_BLE_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS,
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
} btc_gap_ble_act_t;
/* btc_ble_gap_args_t */
@ -342,6 +348,30 @@ typedef union {
esp_bd_addr_t peer_addr;
} ext_conn;
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
struct periodic_adv_recv_en_args {
uint16_t sync_handle;
uint8_t enable;
} periodic_adv_recv_en;
struct periodic_adv_sync_trans_args {
esp_bd_addr_t addr;
uint16_t service_data;
uint16_t sync_handle;
} periodic_adv_sync_trans;
struct periodic_adv_set_info_trans_args {
esp_bd_addr_t addr;
uint16_t service_data;
uint16_t adv_handle;
} periodic_adv_set_info_trans;
struct set_periodic_adv_sync_trans_params_args {
esp_bd_addr_t addr;
esp_ble_gap_past_params_t params;
} set_periodic_adv_sync_trans_params;
#endif
} btc_ble_5_gap_args_t;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)

View File

@ -131,6 +131,12 @@
#define UC_BT_BLE_42_FEATURES_SUPPORTED FALSE
#endif
#ifdef CONFIG_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
#define UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER CONFIG_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
#else
#define UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER FALSE
#endif
//GATTS
#ifdef CONFIG_BT_GATTS_ENABLE
#define UC_BT_GATTS_ENABLE CONFIG_BT_GATTS_ENABLE

View File

@ -192,6 +192,12 @@
#define BLE_42_FEATURE_SUPPORT FALSE
#endif
#if (UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER TRUE
#else
#define BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER FALSE
#endif
#if (UC_BT_BLE_RPA_SUPPORTED == TRUE)
#define CONTROLLER_RPA_LIST_ENABLE TRUE
#else
@ -2315,13 +2321,6 @@ The maximum number of payload octets that the local device can receive in a sing
#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE
#endif
// TODO: add menuconfig and api for periodic adv sync transfer
#if (BLE_50_FEATURE_SUPPORT)
#define BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER TRUE
#else
#define BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER FALSE
#endif
#include "common/bt_trace.h"
#endif /* BT_TARGET_H */

View File

@ -30,7 +30,7 @@
#include "device/version.h"
#include "osi/future.h"
#if (BLE_50_FEATURE_SUPPORT == TRUE)
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x0f\xff\xff" };
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\xff\xff\xff" };
#else
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" };
#endif

View File

@ -1284,31 +1284,142 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
void btm_ble_periodic_adv_sync_trans_complete(UINT16 op_code, UINT8 hci_status, UINT16 conn_handle)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
UINT8 evt = BTM_BLE_5_GAP_UNKNOWN_EVT;
tL2C_LCB *p_lcb = l2cu_find_lcb_by_handle(conn_handle);
switch (op_code) {
case HCI_BLE_PERIOD_ADV_SYNC_TRANS:
evt = BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT;
break;
case HCI_BLE_PERIOD_ADV_SET_INFO_TRANS:
evt = BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT;
break;
case HCI_BLE_SET_PAST_PARAMS:
evt = BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT;
break;
default:
return;
}
cb_params.per_adv_sync_trans.status = BTM_SUCCESS;
if(hci_status != HCI_SUCCESS) {
cb_params.per_adv_sync_trans.status = BTM_ILLEGAL_VALUE;
BTM_TRACE_ERROR("%s error status %d", __func__, hci_status);
}
if(p_lcb) {
memcpy(cb_params.per_adv_sync_trans.addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
}
BTM_ExtBleCallbackTrigger(evt, &cb_params);
}
void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable)
{
tHCI_STATUS err = HCI_SUCCESS;
tBTM_STATUS status = BTM_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((err = btsnd_hcic_ble_set_periodic_adv_recv_enable(sync_handle, enable)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("%s cmd err=0x%x", __func__, err);
status = BTM_ILLEGAL_VALUE;
}
cb_params.status = status;
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT, &cb_params);
}
void BTM_BlePeriodicAdvSyncTrans(BD_ADDR bd_addr, UINT16 service_data, UINT16 sync_handle)
{
tBTM_STATUS status = BTM_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
if (!p_lcb) {
BTM_TRACE_ERROR("%s, invalid parameters", __func__);
status = BTM_ILLEGAL_VALUE;
}
if (status != BTM_SUCCESS) {
cb_params.per_adv_sync_trans.status = status;
memcpy(cb_params.per_adv_sync_trans.addr, bd_addr, sizeof(BD_ADDR));
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT, &cb_params);
return;
}
btsnd_hcic_ble_periodic_adv_sync_trans(p_lcb->handle, service_data, sync_handle);
}
void BTM_BlePeriodicAdvSetInfoTrans(BD_ADDR bd_addr, UINT16 service_data, UINT8 adv_handle)
{
tBTM_STATUS status = BTM_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
if (!p_lcb) {
BTM_TRACE_ERROR("%s, invalid parameters", __func__);
status = BTM_ILLEGAL_VALUE;
}
if (status != BTM_SUCCESS) {
cb_params.per_adv_sync_trans.status = status;
memcpy(cb_params.per_adv_sync_trans.addr, bd_addr, sizeof(BD_ADDR));
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT, &cb_params);
return;
}
if (!btsnd_hcic_ble_periodic_adv_set_info_trans(p_lcb->handle, service_data, adv_handle)) {
BTM_TRACE_ERROR("%s, hci cmd error", __func__);
}
btsnd_hcic_ble_periodic_adv_set_info_trans(p_lcb->handle, service_data, adv_handle);
}
void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type)
{
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
tBTM_STATUS status = BTM_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if (!p_lcb) {
BTM_TRACE_ERROR("%s, invalid parameters", __func__);
// Set default past params
if (bdaddr_is_empty((bt_bdaddr_t *)bd_addr)) {
tHCI_STATUS err = HCI_SUCCESS;
if ((err = btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(mode, skip, sync_timeout, cte_type)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("%s cmd err=0x%x", __func__, err);
status = BTM_ILLEGAL_VALUE;
}
cb_params.set_past_params.status = status;
memset(cb_params.set_past_params.addr, 0, sizeof(BD_ADDR));
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT, &cb_params);
return;
}
if (!btsnd_hcic_ble_set_periodic_adv_sync_trans_params(p_lcb->handle, mode, skip, sync_timeout, cte_type)) {
BTM_TRACE_ERROR("%s, hci cmd error", __func__);
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
if (!p_lcb) {
BTM_TRACE_ERROR("%s, invalid parameters", __func__);
status = BTM_ILLEGAL_VALUE;
}
if (status != BTM_SUCCESS) {
cb_params.set_past_params.status = status;
memcpy(cb_params.set_past_params.addr, bd_addr, sizeof(BD_ADDR));
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT, &cb_params);
return;
}
btsnd_hcic_ble_set_periodic_adv_sync_trans_params(p_lcb->handle, mode, skip, sync_timeout, cte_type);
}
void btm_ble_periodic_adv_sync_trans_recv_evt(tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV *params)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if (!params) {
BTM_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
memcpy(&cb_params.past_recv, params, sizeof(tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV));
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT, &cb_params);
}
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -533,6 +533,10 @@ void btm_ble_periodic_adv_sync_lost_evt(tBTM_BLE_PERIOD_ADV_SYNC_LOST *params);
void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *params);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
void btm_ble_periodic_adv_sync_trans_recv_evt(tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV *params);
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/*
#ifdef __cplusplus
}

View File

@ -1085,6 +1085,9 @@ void btm_create_sync_callback(UINT8 status);
void btm_set_phy_callback(UINT8 status);
void btm_read_phy_callback(uint8_t hci_status, uint16_t conn_handle, uint8_t tx_phy, uint8_t rx_phy);
#endif
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
void btm_ble_periodic_adv_sync_trans_complete(UINT16 op_code, UINT8 hci_status, UINT16 conn_handle);
#endif
/* Internal functions provided by btm_sco.c
********************************************
*/

View File

@ -1117,6 +1117,21 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
btm_ble_test_command_complete(p);
break;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
case HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE:
case HCI_BLE_SET_DEFAULT_PAST_PARAMS:
break;
case HCI_BLE_PERIOD_ADV_SYNC_TRANS:
case HCI_BLE_PERIOD_ADV_SET_INFO_TRANS:
case HCI_BLE_SET_PAST_PARAMS: {
UINT8 status;
UINT16 conn_handle;
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT16(conn_handle, p);
btm_ble_periodic_adv_sync_trans_complete(opcode, status, conn_handle);
break;
}
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#endif
#endif /* (BLE_INCLUDED == TRUE) */
@ -2317,20 +2332,32 @@ static void btu_ble_scan_req_received_evt(UINT8 *p)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p)
{
tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV recv = {0};
UINT16 conn_handle;
tL2C_LCB *p_lcb = NULL;
tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV past_recv = {0};
STREAM_TO_UINT8(recv.status, p);
STREAM_TO_UINT16(recv.conn_handle, p);
STREAM_TO_UINT16(recv.service_data, p);
STREAM_TO_UINT16(recv.sync_handle, p);
STREAM_TO_UINT8(recv.adv_sid, p);
STREAM_TO_UINT8(recv.adv_addr_type, p);
STREAM_TO_BDADDR(recv.adv_addr, p);
STREAM_TO_UINT8(recv.adv_phy, p);
STREAM_TO_UINT16(recv.period_adv_interval, p);
STREAM_TO_UINT8(recv.adv_clk_accuracy, p);
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
HCI_TRACE_DEBUG("%s status %x, conn handle %x, sync handle %x", recv.status, recv.conn_handle, recv.sync_handle);
STREAM_TO_UINT8(past_recv.status, p);
STREAM_TO_UINT16(conn_handle, p);
STREAM_TO_UINT16(past_recv.service_data, p);
STREAM_TO_UINT16(past_recv.sync_handle, p);
STREAM_TO_UINT8(past_recv.adv_sid, p);
STREAM_TO_UINT8(past_recv.adv_addr_type, p);
STREAM_TO_BDADDR(past_recv.adv_addr, p);
STREAM_TO_UINT8(past_recv.adv_phy, p);
STREAM_TO_UINT16(past_recv.adv_interval, p);
STREAM_TO_UINT8(past_recv.adv_clk_accuracy, p);
p_lcb = l2cu_find_lcb_by_handle(conn_handle);
if(p_lcb) {
memcpy(past_recv.addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
}
btm_ble_periodic_adv_sync_trans_recv_evt(&past_recv);
}
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -1783,12 +1783,12 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_recv_enable(UINT16 sync_handle, UINT8 enab
BT_HDR *p;
UINT8 *pp;
HCIC_BLE_CMD_CREATED(p, pp, 3);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_RECV_ENABLE);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE);
UINT8_TO_STREAM(pp, 3);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_RECV_ENABLE);
UINT16_TO_STREAM(pp, sync_handle);
UINT8_TO_STREAM(pp, enable);
@ -1796,59 +1796,61 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_recv_enable(UINT16 sync_handle, UINT8 enab
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_periodic_adv_sync_trans(UINT16 conn_handle, UINT16 service_data, UINT16 sync_handle)
BOOLEAN btsnd_hcic_ble_periodic_adv_sync_trans(UINT16 conn_handle, UINT16 service_data, UINT16 sync_handle)
{
BT_HDR *p;
UINT8 *pp;
HCIC_BLE_CMD_CREATED(p, pp, 6);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_SYNC_TRANS);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_SYNC_TRANS);
UINT8_TO_STREAM(pp, 6);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_SYNC_TRANS);
UINT16_TO_STREAM(pp, conn_handle);
UINT16_TO_STREAM(pp, service_data);
UINT16_TO_STREAM(pp, sync_handle);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
UINT8 btsnd_hcic_ble_periodic_adv_set_info_trans(UINT16 conn_handle, UINT16 service_data, UINT8 adv_handle)
BOOLEAN btsnd_hcic_ble_periodic_adv_set_info_trans(UINT16 conn_handle, UINT16 service_data, UINT8 adv_handle)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("%s conn handle %x, adv handle %x", __func__, conn_handle, adv_handle);
HCIC_BLE_CMD_CREATED(p, pp, 5);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_SET_INFO_TRANS);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_SET_INFO_TRANS);
UINT8_TO_STREAM(pp, 5);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_SET_INFO_TRANS);
UINT16_TO_STREAM(pp, conn_handle);
UINT16_TO_STREAM(pp, service_data);
UINT8_TO_STREAM(pp, adv_handle);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
UINT8 btsnd_hcic_ble_set_periodic_adv_sync_trans_params(UINT16 conn_handle, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type)
BOOLEAN btsnd_hcic_ble_set_periodic_adv_sync_trans_params(UINT16 conn_handle, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("%s conn handle %x, mode %x, sync timeout %x", __func__, conn_handle, mode, sync_timeout);
HCIC_BLE_CMD_CREATED(p, pp, 8);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PAST_PARAMS);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS);
UINT8_TO_STREAM(pp, 8);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PAST_PARAMS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PAST_PARAMS);
UINT16_TO_STREAM(pp, conn_handle);
UINT8_TO_STREAM(pp, mode);
@ -1856,6 +1858,29 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_sync_trans_params(UINT16 conn_handle, UINT
UINT16_TO_STREAM(pp, sync_timeout);
UINT8_TO_STREAM(pp, cte_type);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
UINT8 btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("%s mode %x, skip %x, sync timeout %x", __func__, mode, skip, sync_timeout);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_PAST_PARAMS);
pp = (UINT8 *)(p + 1);
UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_PAST_PARAMS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_DEFAULT_PAST_PARAMS);
UINT8_TO_STREAM(pp, mode);
UINT16_TO_STREAM(pp, skip);
UINT16_TO_STREAM(pp, sync_timeout);
UINT8_TO_STREAM(pp, cte_type);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -1031,7 +1031,14 @@ typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS st
#define BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT 32
#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT 33
#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT 34
#define BTM_BLE_5_GAP_UNKNOWN_EVT 35
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT 35
#define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT 36
#define BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT 37
#define BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT 38
#define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT 39
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define BTM_BLE_5_GAP_UNKNOWN_EVT 40
typedef UINT8 tBTM_BLE_5_GAP_EVENT;
#define BTM_BLE_EXT_ADV_DATA_COMPLETE 0x00
@ -1241,6 +1248,39 @@ typedef struct {
UINT16 max_ce_len;
} tBTM_BLE_CONN_PARAMS;
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL;
typedef struct {
UINT8 status;
BD_ADDR addr;
} tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL;
typedef struct {
UINT8 status;
BD_ADDR addr;
} tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL;
typedef struct {
UINT8 status;
BD_ADDR addr;
} tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL;
typedef struct {
UINT8 status;
BD_ADDR addr;
UINT16 service_data;
UINT16 sync_handle;
UINT8 adv_sid;
UINT8 adv_addr_type;
BD_ADDR adv_addr;
UINT8 adv_phy;
UINT16 adv_interval;
UINT8 adv_clk_accuracy;
} tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV;
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef union {
UINT8 status;
@ -1275,6 +1315,13 @@ typedef union {
tBTM_PERIOD_ADV_REPORT period_adv_report;
tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost;
tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab;
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL per_adv_recv_enable;
tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL per_adv_sync_trans;
tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL per_adv_set_info_trans;
tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL set_past_params;
tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV past_recv;
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
} tBTM_BLE_5_GAP_CB_PARAMS;
typedef struct {
@ -1288,21 +1335,6 @@ typedef void (*tBTM_BLE_5_HCI_CBACK)(tBTM_BLE_5_GAP_EVENT event, tBTM_BLE_5_GAP_
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
typedef struct {
UINT8 status;
UINT16 conn_handle;
UINT16 service_data;
UINT16 sync_handle;
UINT8 adv_sid;
UINT8 adv_addr_type;
BD_ADDR adv_addr;
UINT8 adv_phy;
UINT16 period_adv_interval;
UINT8 adv_clk_accuracy;
} tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV;
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
/*****************************************************************************
** EXTERNAL FUNCTION DECLARATIONS
*****************************************************************************/
@ -2655,6 +2687,10 @@ void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *pa
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable);
void BTM_BlePeriodicAdvSyncTrans(BD_ADDR bd_addr, UINT16 service_data, UINT16 sync_handle);
void BTM_BlePeriodicAdvSetInfoTrans(BD_ADDR bd_addr, UINT16 service_data, UINT8 adv_handle);
void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);

View File

@ -389,7 +389,8 @@
#define HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE (0x0059 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_PERIOD_ADV_SYNC_TRANS (0x005A | HCI_GRP_BLE_CMDS)
#define HCI_BLE_PERIOD_ADV_SET_INFO_TRANS (0x005B | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS (0x005C | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PAST_PARAMS (0x005C | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_DEFAULT_PAST_PARAMS (0x005D | HCI_GRP_BLE_CMDS)
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
// Vendor OGF define
#define HCI_VENDOR_OGF 0x3F

View File

@ -1033,18 +1033,30 @@ UINT8 btsnd_hcic_ble_read_rf_path_compensation(void);
UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_path);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
UINT8 btsnd_hcic_ble_set_periodic_adv_recv_enable(UINT16 sync_handle, UINT8 enable);
UINT8 btsnd_hcic_ble_periodic_adv_sync_trans(UINT16 conn_handle, UINT16 service_data, UINT16 sync_handle);
UINT8 btsnd_hcic_ble_periodic_adv_set_info_trans(UINT16 conn_handle, UINT16 service_data, UINT8 adv_handle);
UINT8 btsnd_hcic_ble_set_periodic_adv_sync_trans_params(UINT16 conn_handle, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#define HCIC_PARAM_SIZE_PERIODIC_ADV_RECV_ENABLE 3
#define HCI_PERIODIC_ADV_RECV_REPORT_EN 1
#define HCI_PERIODIC_ADV_RECV_DUP_FILTER_EN 2
#define HCIC_PARAM_SIZE_PERIODIC_ADV_SYNC_TRANS 6
#define HCIC_PARAM_SIZE_PERIODIC_ADV_SET_INFO_TRANS 5
#define HCIC_PARAM_SIZE_SET_PAST_PARAMS 8
#define HCIC_PARAM_SIZE_SET_DEFAULT_PAST_PARAMS 6
UINT8 btsnd_hcic_ble_set_periodic_adv_recv_enable(UINT16 sync_handle, UINT8 enable);
BOOLEAN btsnd_hcic_ble_periodic_adv_sync_trans(UINT16 conn_handle, UINT16 service_data, UINT16 sync_handle);
BOOLEAN btsnd_hcic_ble_periodic_adv_set_info_trans(UINT16 conn_handle, UINT16 service_data, UINT8 adv_handle);
BOOLEAN btsnd_hcic_ble_set_periodic_adv_sync_trans_params(UINT16 conn_handle, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
UINT8 btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type);
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
#endif