mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
components/bt: Add API and EVT for BLE set channels(BLE)
This commit is contained in:
parent
eaf5f6a319
commit
ed984cc9b5
@ -717,6 +717,20 @@ esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_pa
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
esp_err_t esp_gap_ble_set_channels(esp_gap_ble_channels channels)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_SET_AFH_CHANNELS;
|
||||
|
||||
memcpy(&arg.set_channels.channels, channels, ESP_GAP_BLE_CHANNELS_LEN);
|
||||
arg.set_channels.channels[ESP_GAP_BLE_CHANNELS_LEN -1] &= 0x1F;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -143,31 +143,36 @@ typedef enum {
|
||||
ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */
|
||||
ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When start advertising complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When start scan complete, the event comes */
|
||||
ESP_GAP_BLE_AUTH_CMPL_EVT, /* Authentication complete indication. */
|
||||
ESP_GAP_BLE_KEY_EVT, /* BLE key event for peer device keys */
|
||||
ESP_GAP_BLE_SEC_REQ_EVT, /* BLE security request */
|
||||
ESP_GAP_BLE_PASSKEY_NOTIF_EVT, /* passkey notification event */
|
||||
ESP_GAP_BLE_PASSKEY_REQ_EVT, /* passkey request event */
|
||||
ESP_GAP_BLE_OOB_REQ_EVT, /* OOB request event */
|
||||
ESP_GAP_BLE_LOCAL_IR_EVT, /* BLE local IR event */
|
||||
ESP_GAP_BLE_LOCAL_ER_EVT, /* BLE local ER event */
|
||||
ESP_GAP_BLE_NC_REQ_EVT, /* Numeric Comparison request event */
|
||||
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */
|
||||
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt length complete, the event comes */
|
||||
ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When Enable/disable privacy on the local device complete, the event comes */
|
||||
ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When remove the bond device complete, the event comes */
|
||||
ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clear the bond device clear complete, the event comes */
|
||||
ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */
|
||||
ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT, /*!< When update duplicate exceptional list complete, the event comes */
|
||||
ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When starting advertising complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When starting scan complete, the event comes */
|
||||
ESP_GAP_BLE_AUTH_CMPL_EVT, /*!< Authentication complete indication. */
|
||||
ESP_GAP_BLE_KEY_EVT, /*!< BLE key event for peer device keys */
|
||||
ESP_GAP_BLE_SEC_REQ_EVT, /*!< BLE security request */
|
||||
ESP_GAP_BLE_PASSKEY_NOTIF_EVT, /*!< passkey notification event */
|
||||
ESP_GAP_BLE_PASSKEY_REQ_EVT, /*!< passkey request event */
|
||||
ESP_GAP_BLE_OOB_REQ_EVT, /*!< OOB request event */
|
||||
ESP_GAP_BLE_LOCAL_IR_EVT, /*!< BLE local IR event */
|
||||
ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER event */
|
||||
ESP_GAP_BLE_NC_REQ_EVT, /*!< Numeric Comparison request event */
|
||||
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stopping adv complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stopping scan complete, the event comes */
|
||||
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When setting the static rand address complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When updating connection parameters complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When setting pkt length complete, the event comes */
|
||||
ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When enabling/disabling privacy on the local device complete, the event comes */
|
||||
ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When removing the bond device complete, the event comes */
|
||||
ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clearing the bond device clear complete, the event comes */
|
||||
ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When getting the bond device list complete, the event comes */
|
||||
ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When reading the rssi complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When adding or removing whitelist complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT, /*!< When updating duplicate exceptional list complete, the event comes */
|
||||
ESP_GAP_BLE_SET_CHANNELS_EVT, /*!< When setting BLE channels complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX,
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
#define ESP_GAP_BLE_CHANNELS_LEN 5
|
||||
typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN];
|
||||
|
||||
/// This is the old name, just for backwards compatibility
|
||||
#define ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT
|
||||
|
||||
@ -780,6 +785,12 @@ typedef union {
|
||||
uint16_t length; /*!< The length of device_info */
|
||||
esp_duplicate_info_t device_info; /*!< device information, when subcode is ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_CLEAN, the value is invalid */
|
||||
} update_duplicate_exceptional_list_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_CHANNELS_EVT
|
||||
*/
|
||||
struct ble_set_channels_evt_param {
|
||||
esp_bt_status_t stat; /*!< BLE set channel status */
|
||||
} ble_set_channels; /*!< Event parameter of ESP_GAP_BLE_SET_CHANNELS_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -1266,6 +1277,22 @@ esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device);
|
||||
*/
|
||||
esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_params_t *conn_params);
|
||||
|
||||
/**
|
||||
* @brief BLE set channels
|
||||
*
|
||||
* @param[in] channels : The n th such field (in the range 0 to 36) contains the value for the link layer channel index n.
|
||||
* 0 means channel n is bad.
|
||||
* 1 means channel n is unknown.
|
||||
* The most significant bits are reserved and shall be set to 0.
|
||||
* At least one channel shall be marked as unknown.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_gap_ble_set_channels(esp_gap_ble_channels channels);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -323,7 +323,7 @@ typedef union {
|
||||
*/
|
||||
struct set_afh_channels_param {
|
||||
esp_bt_status_t stat; /*!< set AFH channel status */
|
||||
} set_afh_channels;
|
||||
} set_afh_channels; /*!< set AFH channel parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -652,18 +652,18 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
|
||||
/**
|
||||
* @brief Set the AFH channels
|
||||
*
|
||||
* @param[in] channles : The n th such field (in the range 0 to 78) contains the value for channel n :
|
||||
* Channel n is bad = 0
|
||||
* Channel n is unknown = 1
|
||||
* The most significant bit is reserved and shall be set to 0
|
||||
* At least 20 channels shall be marked as unknown
|
||||
* @param[in] channels : The n th such field (in the range 0 to 78) contains the value for channel n :
|
||||
* 0 means channel n is bad.
|
||||
* 1 means channel n is unknown.
|
||||
* The most significant bit is reserved and shall be set to 0.
|
||||
* At least 20 channels shall be marked as unknown.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channles);
|
||||
esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -722,6 +722,23 @@ void bta_dm_config_eir (tBTA_DM_MSG *p_data)
|
||||
bta_dm_set_eir(NULL);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_set_afh_channels
|
||||
**
|
||||
** Description Sets AFH channels
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
BTM_BleSetChannels (p_data->ble_set_channels.channels, p_data->ble_set_channels.set_channels_cb);
|
||||
#endif /// BLE_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_update_white_list(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
|
@ -255,6 +255,33 @@ void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb)
|
||||
#endif /// CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetChannels
|
||||
**
|
||||
** Description This function sets BLE channels
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSetChannels(const uint8_t *channels, tBTA_CMPL_CB *set_channels_cb)
|
||||
{
|
||||
|
||||
tBTA_DM_API_BLE_SET_CHANNELS *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_BLE_SET_CHANNELS *) osi_malloc(sizeof(tBTA_DM_API_BLE_SET_CHANNELS))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_SET_CHANNELS_EVT;
|
||||
|
||||
p_msg->set_channels_cb = set_channels_cb;
|
||||
memcpy(p_msg->channels, channels, BLE_CHANNELS_LEN);
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_ADD_WHITELIST_CBACK *add_wl_cb)
|
||||
{
|
||||
tBTA_DM_API_UPDATE_WHITE_LIST *p_msg;
|
||||
|
@ -158,6 +158,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
|
||||
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
|
||||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
bta_dm_ble_set_channels, /* BTA_DM_API_BLE_SET_CHANNELS_EVT */
|
||||
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
|
||||
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
|
||||
bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_READ_RSSI_EVT */
|
||||
|
@ -155,6 +155,7 @@ enum {
|
||||
BTA_DM_API_EXECUTE_CBACK_EVT,
|
||||
BTA_DM_API_REMOVE_ALL_ACL_EVT,
|
||||
BTA_DM_API_REMOVE_DEVICE_EVT,
|
||||
BTA_DM_API_BLE_SET_CHANNELS_EVT,
|
||||
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
|
||||
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
|
||||
BTA_DM_API_BLE_READ_RSSI_EVT,
|
||||
@ -214,6 +215,13 @@ typedef struct {
|
||||
}tBTA_DM_API_SET_AFH_CHANNELS;
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/* data type for BTA_DM_API_BLE_SET_CHANNELS_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
AFH_CHANNELS channels;
|
||||
tBTA_CMPL_CB *set_channels_cb;
|
||||
}tBTA_DM_API_BLE_SET_CHANNELS;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN add_remove;
|
||||
@ -816,6 +824,7 @@ typedef union {
|
||||
tBTA_DM_API_SET_AFH_CHANNELS set_afh_channels;
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBTA_DM_API_BLE_SET_CHANNELS ble_set_channels;
|
||||
tBTA_DM_API_UPDATE_WHITE_LIST white_list;
|
||||
tBTA_DM_API_READ_ADV_TX_POWER read_tx_power;
|
||||
tBTA_DM_API_READ_RSSI rssi;
|
||||
@ -1273,6 +1282,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data);
|
||||
|
@ -434,7 +434,7 @@ typedef tBTM_TX_POWER_RESULTS tBTA_TX_POWER_RESULTS;
|
||||
typedef tBTM_RSSI_RESULTS tBTA_RSSI_RESULTS;
|
||||
|
||||
typedef tBTM_SET_AFH_CHANNELS_RESULTS tBTA_SET_AFH_CHANNELS_RESULTS;
|
||||
|
||||
typedef tBTM_BLE_SET_CHANNELS_RESULTS tBTA_BLE_SET_CHANNELS_RESULTS;
|
||||
/* advertising channel map */
|
||||
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
||||
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
||||
@ -1488,6 +1488,18 @@ extern void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config);
|
||||
void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetChannels
|
||||
**
|
||||
** Description This function sets BLE channels
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSetChannels(const uint8_t *channels, tBTA_CMPL_CB *set_channels_cb);
|
||||
|
||||
extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_ADD_WHITELIST_CBACK *add_wl_cb);
|
||||
|
||||
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
|
||||
|
@ -704,6 +704,27 @@ static void btc_set_pkt_length_callback(UINT8 status, tBTM_LE_SET_PKT_DATA_LENGT
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gap_ble_set_channels_cmpl_callback(void *p_data)
|
||||
{
|
||||
tBTA_BLE_SET_CHANNELS_RESULTS *result = (tBTA_BLE_SET_CHANNELS_RESULTS *)p_data;
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SET_CHANNELS_EVT;
|
||||
|
||||
param.ble_set_channels.stat = btc_btm_status_to_esp_status(result->status);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION wl_opration)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
@ -897,6 +918,12 @@ static void btc_ble_disconnect(BD_ADDR bd_addr)
|
||||
BTA_DmBleDisconnect(bd_addr);
|
||||
}
|
||||
|
||||
static void btc_gap_ble_set_channels(esp_gap_ble_channels channels)
|
||||
{
|
||||
BTA_DmBleSetChannels(channels, btc_gap_ble_set_channels_cmpl_callback);
|
||||
}
|
||||
|
||||
|
||||
void btc_gap_ble_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_gap_cb_param_t *param = (esp_ble_gap_cb_param_t *)msg->arg;
|
||||
@ -1264,6 +1291,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
case BTC_GAP_BLE_DISCONNECT_EVT:
|
||||
btc_ble_disconnect(arg->disconnect.remote_device);
|
||||
break;
|
||||
case BTC_GAP_BLE_SET_AFH_CHANNELS:
|
||||
btc_gap_ble_set_channels(arg->set_channels.channels);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ typedef enum {
|
||||
BTC_GAP_BLE_REMOVE_BOND_DEV_EVT,
|
||||
BTC_GAP_BLE_OOB_REQ_REPLY_EVT,
|
||||
BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST,
|
||||
BTC_GAP_BLE_SET_AFH_CHANNELS,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@ -179,6 +180,10 @@ typedef union {
|
||||
struct read_rssi_args {
|
||||
esp_bd_addr_t remote_addr;
|
||||
} read_rssi;
|
||||
// BTC_GAP_BLE_SET_AFH_CHANNELS
|
||||
struct set_channels_args {
|
||||
esp_gap_ble_channels channels;
|
||||
} set_channels;
|
||||
} btc_ble_gap_args_t;
|
||||
|
||||
void btc_gap_ble_call_handler(btc_msg_t *msg);
|
||||
|
@ -1040,7 +1040,7 @@ tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_chann
|
||||
**
|
||||
** Function btm_set_afh_channels_complete
|
||||
**
|
||||
** Description This function is called when set AFH channels complete.
|
||||
** Description This function is called when setting AFH channels complete.
|
||||
** message is received from the HCI.
|
||||
**
|
||||
** Returns void
|
||||
@ -1053,7 +1053,7 @@ void btm_set_afh_channels_complete (UINT8 *p)
|
||||
|
||||
btu_free_timer (&btm_cb.devcb.afh_channels_timer);
|
||||
|
||||
/* If there was a callback address for set AFH channels, call it */
|
||||
/* If there is a callback address for setting AFH channels, call it */
|
||||
btm_cb.devcb.p_afh_channels_cmpl_cb = NULL;
|
||||
|
||||
if (p_cb) {
|
||||
@ -1074,4 +1074,77 @@ void btm_set_afh_channels_complete (UINT8 *p)
|
||||
(*p_cb)(&results);
|
||||
}
|
||||
}
|
||||
#endif /// CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif /// CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleSetChannels
|
||||
**
|
||||
** Description This function is called to set BLE channels
|
||||
**
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback)
|
||||
{
|
||||
if (!controller_get_interface()->get_is_ready()) {
|
||||
return (BTM_DEV_RESET);
|
||||
}
|
||||
|
||||
/* Check if set afh already in progress */
|
||||
if (btm_cb.devcb.p_ble_channels_cmpl_cb) {
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
|
||||
/* Save callback */
|
||||
btm_cb.devcb.p_ble_channels_cmpl_cb = p_ble_channels_cmpl_cback;
|
||||
|
||||
if (!btsnd_hcic_ble_set_channels (channels)) {
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
|
||||
btu_start_timer (&btm_cb.devcb.ble_channels_timer, BTU_TTYPE_BTM_ACL, BTM_DEV_REPLY_TIMEOUT);
|
||||
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_set_afh_channels_complete
|
||||
**
|
||||
** Description This function is called when setting AFH channels complete.
|
||||
** message is received from the HCI.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_set_channels_complete (UINT8 *p)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_ble_channels_cmpl_cb;
|
||||
tBTM_BLE_SET_CHANNELS_RESULTS results;
|
||||
|
||||
btu_free_timer (&btm_cb.devcb.ble_channels_timer);
|
||||
|
||||
/* If there is a callback address for setting AFH channels, call it */
|
||||
btm_cb.devcb.p_ble_channels_cmpl_cb = NULL;
|
||||
|
||||
if (p_cb) {
|
||||
STREAM_TO_UINT8 (results.hci_status, p);
|
||||
|
||||
switch (results.hci_status){
|
||||
case HCI_SUCCESS:
|
||||
results.status = BTM_SUCCESS;
|
||||
break;
|
||||
case HCI_ERR_UNSUPPORTED_VALUE:
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
results.status = BTM_ILLEGAL_VALUE;
|
||||
break;
|
||||
default:
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
break;
|
||||
}
|
||||
(*p_cb)(&results);
|
||||
}
|
||||
}
|
||||
#endif /// BLE_INCLUDED == TRUE
|
@ -173,6 +173,10 @@ DEV_CLASS dev_class; /* Local device class
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
||||
TIMER_LIST_ENT ble_channels_timer;
|
||||
tBTM_CMPL_CB *p_ble_channels_cmpl_cb; /* Callback function to be called When
|
||||
ble set host channels is completed */
|
||||
|
||||
tBTM_CMPL_CB *p_le_test_cmd_cmpl_cb; /* Callback function to be called when
|
||||
LE test mode command has been sent successfully */
|
||||
|
||||
@ -1074,6 +1078,7 @@ void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len);
|
||||
void btm_delete_stored_link_key_complete (UINT8 *p);
|
||||
void btm_report_device_status (tBTM_DEV_STATUS status);
|
||||
void btm_set_afh_channels_complete (UINT8 *p);
|
||||
void btm_ble_set_channels_complete (UINT8 *p);
|
||||
|
||||
/* Internal functions provided by btm_dev.c
|
||||
**********************************************
|
||||
|
@ -918,7 +918,10 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/* BLE Commands sComplete*/
|
||||
/* BLE Commands Complete*/
|
||||
case HCI_BLE_SET_HOST_CHNL_CLASS:
|
||||
btm_ble_set_channels_complete(p);
|
||||
break;
|
||||
case HCI_BLE_ADD_WHITE_LIST:
|
||||
btm_ble_add_2_white_list_complete(*p);
|
||||
break;
|
||||
|
@ -1023,5 +1023,28 @@ BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_SET_CHANNELS)) == NULL) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_CHANNELS;
|
||||
p->offset = 0;
|
||||
|
||||
UINT16_TO_STREAM (pp, HCI_BLE_SET_HOST_CHNL_CLASS);
|
||||
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_CHANNELS);
|
||||
|
||||
ARRAY_TO_STREAM (pp, channels, HCIC_PARAM_SIZE_BLE_SET_CHANNELS);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -356,6 +356,8 @@ typedef UINT8 COF[COF_LEN]; /* ciphering offset number */
|
||||
|
||||
#define AFH_CHANNELS_LEN 10
|
||||
typedef UINT8 AFH_CHANNELS[AFH_CHANNELS_LEN];
|
||||
#define BLE_CHANNELS_LEN 5
|
||||
typedef UINT8 BLE_CHANNELS[BLE_CHANNELS_LEN];
|
||||
|
||||
typedef struct {
|
||||
UINT8 qos_flags; /* TBD */
|
||||
@ -690,8 +692,6 @@ typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...);
|
||||
typedef uint8_t BD_ADDR[BD_ADDR_LEN];
|
||||
#endif
|
||||
|
||||
/* */
|
||||
|
||||
// From bd.c
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -806,6 +806,14 @@ typedef struct {
|
||||
UINT8 hci_status;
|
||||
} tBTM_SET_AFH_CHANNELS_RESULTS;
|
||||
|
||||
/* Structure returned with set BLE channels event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_BleSetChannels call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
} tBTM_BLE_SET_CHANNELS_RESULTS;
|
||||
|
||||
/* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadInquiryRspTxPower call.
|
||||
*/
|
||||
@ -4118,6 +4126,17 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_channels_cmpl_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleSetChannels
|
||||
**
|
||||
** Description This function is called to set BLE channels
|
||||
**
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback);
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -523,6 +523,8 @@ BOOLEAN btsnd_hcic_change_name(BD_NAME name);
|
||||
/* set AFH channels */
|
||||
BOOLEAN btsnd_hcic_set_afh_channels (AFH_CHANNELS channels);
|
||||
#define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
|
||||
BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels);
|
||||
#define HCIC_PARAM_SIZE_BLE_SET_CHANNELS 5
|
||||
|
||||
BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */
|
||||
BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */
|
||||
|
Loading…
x
Reference in New Issue
Block a user