From 3b704d2f3a5d514f57db416cb8460eb8cdf2ce88 Mon Sep 17 00:00:00 2001 From: baohongde Date: Mon, 25 Nov 2019 15:16:39 +0800 Subject: [PATCH] components/bt: Add API and EVT for set AFH channels(BR/EDR) --- components/bt/bluedroid/api/esp_gap_bt_api.c | 18 +++++ .../api/include/api/esp_gap_bt_api.h | 27 +++++++ components/bt/bluedroid/bta/dm/bta_dm_act.c | 17 +++++ components/bt/bluedroid/bta/dm/bta_dm_api.c | 29 ++++++++ components/bt/bluedroid/bta/dm/bta_dm_main.c | 1 + .../bt/bluedroid/bta/dm/include/bta_dm_int.h | 13 +++- .../bt/bluedroid/bta/include/bta/bta_api.h | 18 ++++- components/bt/bluedroid/btc/core/btc_util.c | 3 + .../btc/profile/std/gap/btc_gap_bt.c | 36 ++++++++++ .../btc/profile/std/include/btc_gap_bt.h | 7 ++ .../bt/bluedroid/stack/btm/btm_devctl.c | 72 +++++++++++++++++++ .../bt/bluedroid/stack/btm/include/btm_int.h | 8 ++- components/bt/bluedroid/stack/btu/btu_hcif.c | 7 ++ components/bt/bluedroid/stack/hcic/hcicmds.c | 25 +++++++ .../bluedroid/stack/include/stack/bt_types.h | 3 + .../bluedroid/stack/include/stack/btm_api.h | 21 ++++++ .../bluedroid/stack/include/stack/hcimsgs.h | 2 + 17 files changed, 303 insertions(+), 4 deletions(-) diff --git a/components/bt/bluedroid/api/esp_gap_bt_api.c b/components/bt/bluedroid/api/esp_gap_bt_api.c index ac0326e11f..f62bc10c10 100644 --- a/components/bt/bluedroid/api/esp_gap_bt_api.c +++ b/components/bt/bluedroid/api/esp_gap_bt_api.c @@ -347,4 +347,22 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept) #endif /*(BT_SSP_INCLUDED == TRUE)*/ +esp_err_t esp_bt_gap_set_afh_channels(esp_bt_gap_afh_channels channels) +{ + btc_msg_t msg; + btc_gap_bt_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_BT; + msg.act = BTC_GAP_BT_ACT_SET_AFH_CHANNELS; + + memcpy(&arg.set_afh_channels.channels, channels, ESP_BT_GAP_AFH_CHANNELS_LEN); + arg.set_afh_channels.channels[ESP_BT_GAP_AFH_CHANNELS_LEN -1] &= 0x7F; + return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + #endif /* #if BTC_GAP_BT_INCLUDED == TRUE */ diff --git a/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h b/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h index f5b2c8f15a..986187827f 100644 --- a/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h +++ b/components/bt/bluedroid/api/include/api/esp_gap_bt_api.h @@ -45,6 +45,9 @@ typedef enum { ESP_BT_INIT_COD = 0x0a, /*!< overwrite major, minor, and service class */ } esp_bt_cod_mode_t; +#define ESP_BT_GAP_AFH_CHANNELS_LEN 10 +typedef uint8_t esp_bt_gap_afh_channels[ESP_BT_GAP_AFH_CHANNELS_LEN]; + /// Discoverability and Connectability mode typedef enum { ESP_BT_SCAN_MODE_NONE = 0, /*!< Neither discoverable nor connectable */ @@ -174,6 +177,7 @@ typedef enum { ESP_BT_GAP_KEY_NOTIF_EVT, /*!< Simple Pairing Passkey Notification */ ESP_BT_GAP_KEY_REQ_EVT, /*!< Simple Pairing Passkey request */ ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */ + ESP_BT_GAP_SET_AFH_CHANNELS_EVT, /*!< set AFH channels event */ ESP_BT_GAP_EVT_MAX, } esp_bt_gap_cb_event_t; @@ -271,6 +275,13 @@ typedef union { struct key_req_param { esp_bd_addr_t bda; /*!< remote bluetooth device address*/ } key_req; /*!< passkey request parameter struct */ + + /** + * @brief ESP_BT_GAP_SET_AFH_CHANNELS_EVT + */ + struct set_afh_channels_param { + esp_bt_status_t stat; /*!< set AFH channel status */ + } set_afh_channels; } esp_bt_gap_cb_param_t; /** @@ -581,6 +592,22 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept); #endif /*(BT_SSP_INCLUDED == TRUE)*/ +/** +* @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 +* +* @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); + #ifdef __cplusplus } #endif diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 5ded9a7f95..caa6f98047 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -593,6 +593,23 @@ void bta_dm_set_dev_name (tBTA_DM_MSG *p_data) bta_dm_set_eir ((char *)p_data->set_name.name); } +/******************************************************************************* +** +** Function bta_dm_set_afh_channels +** +** Description Sets AFH channels +** +** +** Returns void +** +*******************************************************************************/ +void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data) +{ +#if CLASSIC_BT_INCLUDED + BTM_SetAfhChannels (p_data->set_afh_channels.channels, p_data->set_afh_channels.set_afh_cb); +#endif /// CLASSIC_BT_INCLUDED +} + void bta_dm_update_white_list(tBTA_DM_MSG *p_data) { BTM_BleUpdateAdvWhitelist(p_data->white_list.add_remove, p_data->white_list.remote_addr, p_data->white_list.add_wl_cb); diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index c5d5440fc5..b86ddb77a6 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -183,6 +183,35 @@ void BTA_DmSetDeviceName(const char *p_name) } +#if (CLASSIC_BT_INCLUDED == TRUE) +/******************************************************************************* +** +** Function BTA_DmSetAfhChannels +** +** Description This function sets the AFH channels +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb) +{ + + tBTA_DM_API_SET_AFH_CHANNELS *p_msg; + + if ((p_msg = (tBTA_DM_API_SET_AFH_CHANNELS *) osi_malloc(sizeof(tBTA_DM_API_SET_AFH_CHANNELS))) != NULL) { + p_msg->hdr.event = BTA_DM_API_SET_AFH_CHANNELS_EVT; + + p_msg->set_afh_cb = set_afh_cb; + memcpy(p_msg->channels, channels, AFH_CHANNELS_LEN); + + bta_sys_sendmsg(p_msg); + } + + +} +#endif /// CLASSIC_BT_INCLUDED == TRUE + void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA_ADD_WHITELIST_CBACK *add_wl_cb) { tBTA_DM_API_UPDATE_WHITE_LIST *p_msg; diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index 0f45dfbe97..fbc876a6ba 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -56,6 +56,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */ bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */ bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */ + bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */ bta_dm_set_visibility, /* BTA_DM_API_SET_VISIBILITY_EVT */ bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */ bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */ diff --git a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h index 6e962d5d5a..e29b579ef3 100644 --- a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h @@ -52,6 +52,7 @@ enum { BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_API_DISABLE_EVT, BTA_DM_API_SET_NAME_EVT, + BTA_DM_API_SET_AFH_CHANNELS_EVT, BTA_DM_API_SET_VISIBILITY_EVT, BTA_DM_ACL_CHANGE_EVT, @@ -188,6 +189,13 @@ typedef struct { BD_NAME name; /* max 248 bytes name, plus must be Null terminated */ } tBTA_DM_API_SET_NAME; +/* data type for BTA_DM_API_SET_AFH_CHANNELS_EVT */ +typedef struct { + BT_HDR hdr; + AFH_CHANNELS channels; + tBTA_CMPL_CB *set_afh_cb; +}tBTA_DM_API_SET_AFH_CHANNELS; + typedef struct { BT_HDR hdr; BOOLEAN add_remove; @@ -477,7 +485,7 @@ typedef struct { typedef struct { BT_HDR hdr; - BOOLEAN add; + BOOLEAN add; UINT32 static_passkey; } tBTA_DM_API_SET_DEFAULT_PASSKEY; @@ -784,6 +792,8 @@ typedef union { tBTA_DM_API_SET_NAME set_name; + tBTA_DM_API_SET_AFH_CHANNELS set_afh_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; @@ -1221,6 +1231,7 @@ extern void bta_dm_search_sm_disable( void ); extern void bta_dm_enable (tBTA_DM_MSG *p_data); 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_set_afh_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); diff --git a/components/bt/bluedroid/bta/include/bta/bta_api.h b/components/bt/bluedroid/bta/include/bta/bta_api.h index f384edeb45..36b26d0589 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_api.h @@ -422,6 +422,8 @@ 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; + /* 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 @@ -1450,6 +1452,18 @@ extern void BTA_DisableTestMode(void); *******************************************************************************/ extern void BTA_DmSetDeviceName(const char *p_name); +/******************************************************************************* +** +** Function BTA_DmSetAfhChannels +** +** Description This function sets the AFH channels +** +** +** Returns void +** +*******************************************************************************/ +void BTA_DmSetAfhChannels(const uint8_t *channels, tBTA_CMPL_CB *set_afh_cb); + extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA_ADD_WHITELIST_CBACK *add_wl_cb); extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb); @@ -2292,8 +2306,8 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l ** Returns None ** *******************************************************************************/ -extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, - BD_ADDR device_info, +extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type, + BD_ADDR device_info, tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback); /******************************************************************************* diff --git a/components/bt/bluedroid/btc/core/btc_util.c b/components/bt/bluedroid/btc/core/btc_util.c index 633b03c60d..96fa30f696 100644 --- a/components/bt/bluedroid/btc/core/btc_util.c +++ b/components/bt/bluedroid/btc/core/btc_util.c @@ -224,6 +224,9 @@ esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status) case BTM_NO_RESOURCES: esp_status = ESP_BT_STATUS_NOMEM; break; + case BTM_ILLEGAL_VALUE: + esp_status = ESP_BT_STATUS_PARM_INVALID; + break; case BTM_ERR_PROCESSING: esp_status = ESP_BT_STATUS_PENDING; break; diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c index a5af828e1a..29e3e893d9 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_bt.c @@ -686,6 +686,31 @@ static void btc_gap_bt_ssp_confirm(btc_gap_bt_args_t *arg) #endif ///BT_SSP_INCLUDED == TRUE +static void btc_gap_bt_set_afh_channels_cmpl_callback(void *p_data) +{ + tBTA_SET_AFH_CHANNELS_RESULTS *result = (tBTA_SET_AFH_CHANNELS_RESULTS *)p_data; + esp_bt_gap_cb_param_t param; + bt_status_t ret; + btc_msg_t msg; + msg.sig = BTC_SIG_API_CB; + msg.pid = BTC_PID_GAP_BT; + msg.act = BTC_GAP_BT_SET_AFH_CHANNELS_EVT; + + param.set_afh_channels.stat = btc_btm_status_to_esp_status(result->status); + + ret = btc_transfer_context(&msg, ¶m, + sizeof(esp_bt_gap_cb_param_t), NULL); + + if (ret != BT_STATUS_SUCCESS) { + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + } +} + +static void btc_gap_bt_set_afh_channels(btc_gap_bt_args_t *arg) +{ + BTA_DmSetAfhChannels(arg->set_afh_channels.channels, btc_gap_bt_set_afh_channels_cmpl_callback); +} + void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) { switch (msg->act) { @@ -740,6 +765,7 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg) case BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE: case BTC_GAP_BT_ACT_PIN_REPLY: case BTC_GAP_BT_ACT_SET_PIN_TYPE: + case BTC_GAP_BT_ACT_SET_AFH_CHANNELS: break; #if (BT_SSP_INCLUDED == TRUE) case BTC_GAP_BT_ACT_PASSKEY_REPLY: @@ -815,6 +841,11 @@ void btc_gap_bt_call_handler(btc_msg_t *msg) } #endif ///BT_SSP_INCLUDED == TRUE + case BTC_GAP_BT_ACT_SET_AFH_CHANNELS: { + btc_gap_bt_set_afh_channels(arg); + break; + } + default: break; } @@ -849,6 +880,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg) case BTC_GAP_BT_READ_RSSI_DELTA_EVT: case BTC_GAP_BT_AUTH_CMPL_EVT: case BTC_GAP_BT_PIN_REQ_EVT: + case BTC_GAP_BT_SET_AFH_CHANNELS_EVT: #if (BT_SSP_INCLUDED == TRUE) case BTC_GAP_BT_CFM_REQ_EVT: case BTC_GAP_BT_KEY_NOTIF_EVT: @@ -902,6 +934,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg) break; } #endif ///BT_SSP_INCLUDED == TRUE + case BTC_GAP_BT_SET_AFH_CHANNELS_EVT:{ + btc_gap_bt_cb_to_app(ESP_BT_GAP_SET_AFH_CHANNELS_EVT, (esp_bt_gap_cb_param_t *)msg->arg); + break; + } default: BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act); break; diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h b/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h index 67e03cb3f9..87622a51d9 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_gap_bt.h @@ -32,6 +32,7 @@ typedef enum { BTC_GAP_BT_KEY_NOTIF_EVT, BTC_GAP_BT_KEY_REQ_EVT, BTC_GAP_BT_READ_RSSI_DELTA_EVT, + BTC_GAP_BT_SET_AFH_CHANNELS_EVT, }btc_gap_bt_evt_t; typedef enum { @@ -48,6 +49,7 @@ typedef enum { BTC_GAP_BT_ACT_SET_SECURITY_PARAM, BTC_GAP_BT_ACT_PASSKEY_REPLY, BTC_GAP_BT_ACT_CONFIRM_REPLY, + BTC_GAP_BT_ACT_SET_AFH_CHANNELS, } btc_gap_bt_act_t; /* btc_bt_gap_args_t */ @@ -123,6 +125,11 @@ typedef union { bt_bdaddr_t bda; bool accept; } confirm_reply; + + // BTC_GAP_BT_ACT_SET_AFH_CHANNELS + struct set_afh_channels_args { + esp_bt_gap_afh_channels channels; + } set_afh_channels; } btc_gap_bt_args_t; void btc_gap_bt_call_handler(btc_msg_t *msg); diff --git a/components/bt/bluedroid/stack/btm/btm_devctl.c b/components/bt/bluedroid/stack/btm/btm_devctl.c index dfd2c3bf60..1bf1486221 100644 --- a/components/bt/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/bluedroid/stack/btm/btm_devctl.c @@ -1001,4 +1001,76 @@ void btm_report_device_status (tBTM_DEV_STATUS status) } } +#if (CLASSIC_BT_INCLUDED == TRUE) +/******************************************************************************* +** +** Function BTM_SetAfhChannels +** +** Description This function is called to set AFH channels +** +** Returns status of the operation +** +*******************************************************************************/ +tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_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_afh_channels_cmpl_cb) { + return (BTM_NO_RESOURCES); + } + + /* Save callback */ + btm_cb.devcb.p_afh_channels_cmpl_cb = p_afh_channels_cmpl_cback; + + if (!btsnd_hcic_set_afh_channels (channels)) { + return (BTM_NO_RESOURCES); + } + + btu_start_timer (&btm_cb.devcb.afh_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 set AFH channels complete. +** message is received from the HCI. +** +** Returns void +** +*******************************************************************************/ +void btm_set_afh_channels_complete (UINT8 *p) +{ + tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_afh_channels_cmpl_cb; + tBTM_SET_AFH_CHANNELS_RESULTS results; + + btu_free_timer (&btm_cb.devcb.afh_channels_timer); + + /* If there was a callback address for set AFH channels, call it */ + btm_cb.devcb.p_afh_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 /// CLASSIC_BT_INCLUDED == TRUE diff --git a/components/bt/bluedroid/stack/btm/include/btm_int.h b/components/bt/bluedroid/stack/btm/include/btm_int.h index 47ddfd3449..66e12045c3 100644 --- a/components/bt/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/bluedroid/stack/btm/include/btm_int.h @@ -162,6 +162,12 @@ tBTM_CMPL_CB *p_switch_role_cb; /* Callback function to be called when TIMER_LIST_ENT tx_power_timer; tBTM_CMPL_CB *p_tx_power_cmpl_cb;/* Callback function to be called */ +#if CLASSIC_BT_INCLUDED == TRUE +TIMER_LIST_ENT afh_channels_timer; +tBTM_CMPL_CB *p_afh_channels_cmpl_cb; /* Callback function to be called When */ +/* set AFH channels is completed */ +#endif + DEV_CLASS dev_class; /* Local device class */ #if BLE_INCLUDED == TRUE @@ -1057,7 +1063,7 @@ void btm_inq_db_reset (void); 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); /* Internal functions provided by btm_dev.c ********************************************** diff --git a/components/bt/bluedroid/stack/btu/btu_hcif.c b/components/bt/bluedroid/stack/btu/btu_hcif.c index 7f0395a5b3..057495bff0 100644 --- a/components/bt/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/bluedroid/stack/btu/btu_hcif.c @@ -912,6 +912,13 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_read_linq_tx_power_complete (p); break; +#if (CLASSIC_BT_INCLUDED == TRUE) + case HCI_SET_AFH_CHANNELS: + btm_set_afh_channels_complete(p); + break; +#endif + + #if (BLE_INCLUDED == TRUE) /* BLE Commands sComplete*/ case HCI_BLE_ADD_WHITE_LIST: diff --git a/components/bt/bluedroid/stack/hcic/hcicmds.c b/components/bt/bluedroid/stack/hcic/hcicmds.c index 69944315ed..80517dcdb2 100644 --- a/components/bt/bluedroid/stack/hcic/hcicmds.c +++ b/components/bt/bluedroid/stack/hcic/hcicmds.c @@ -1876,3 +1876,28 @@ void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len, btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); } + +#if (CLASSIC_BT_INCLUDED == TRUE) +BOOLEAN btsnd_hcic_set_afh_channels (AFH_CHANNELS channels) +{ + BT_HDR *p; + UINT8 *pp; + + if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL) { + return (FALSE); + } + + pp = (UINT8 *)(p + 1); + + p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS; + p->offset = 0; + + UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS); + UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS); + + ARRAY_TO_STREAM (pp, channels, HCIC_PARAM_SIZE_SET_AFH_CHANNELS); + + btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); + return (TRUE); +} +#endif /// CLASSIC_BT_INCLUDED == TRUE diff --git a/components/bt/bluedroid/stack/include/stack/bt_types.h b/components/bt/bluedroid/stack/include/stack/bt_types.h index 52385cb513..cbce6dc371 100644 --- a/components/bt/bluedroid/stack/include/stack/bt_types.h +++ b/components/bt/bluedroid/stack/include/stack/bt_types.h @@ -361,6 +361,9 @@ typedef UINT8 ACO[ACO_LEN]; /* Authenticated ciphering offset */ #define COF_LEN 12 typedef UINT8 COF[COF_LEN]; /* ciphering offset number */ +#define AFH_CHANNELS_LEN 10 +typedef UINT8 AFH_CHANNELS[AFH_CHANNELS_LEN]; + typedef struct { UINT8 qos_flags; /* TBD */ UINT8 service_type; /* see below */ diff --git a/components/bt/bluedroid/stack/include/stack/btm_api.h b/components/bt/bluedroid/stack/include/stack/btm_api.h index 6aa833c036..691251d96e 100644 --- a/components/bt/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/bluedroid/stack/include/stack/btm_api.h @@ -795,6 +795,14 @@ typedef struct { BD_ADDR rem_bda; } tBTM_LINK_QUALITY_RESULTS; +/* Structure returned with set AFH channels event (in tBTM_CMPL_CB callback function) +** in response to BTM_SetAfhChannels call. +*/ +typedef struct { + tBTM_STATUS status; + UINT8 hci_status; +} tBTM_SET_AFH_CHANNELS_RESULTS; + /* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function) ** in response to BTM_ReadInquiryRspTxPower call. */ @@ -4093,6 +4101,19 @@ void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb); *******************************************************************************/ //extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void); + +/******************************************************************************* +** +** Function BTM_SetAfhChannels +** +** Description This function is called to set AFH channels +** +** Returns status of the operation +** +*******************************************************************************/ +tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_channels_cmpl_cback); + + /* #ifdef __cplusplus } diff --git a/components/bt/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/bluedroid/stack/include/stack/hcimsgs.h index 6a86dc6249..f5002d967b 100644 --- a/components/bt/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/bluedroid/stack/include/stack/hcimsgs.h @@ -520,6 +520,8 @@ BOOLEAN btsnd_hcic_change_name(BD_NAME name); #define HCIC_WRITE_PARAM3_PARAM_OFF 0 +/* set AFH channels */ +BOOLEAN btsnd_hcic_set_afh_channels (AFH_CHANNELS channels); #define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10 BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */