component bt: Added the param len & connect API to the bt project

This commit is contained in:
yulong 2016-10-25 09:12:10 -04:00
parent 78d1fd5306
commit 86dc0ae808
3 changed files with 107 additions and 0 deletions

View File

@ -14,6 +14,8 @@
#include "bt_app_api.h" #include "bt_app_api.h"
#include "btm_ble_api.h" #include "btm_ble_api.h"
//#include "btm_ble_int.h"
void API_Ble_AppConfigAdvData(tESP_BLE_ADV_DATA *adv_data, void API_Ble_AppConfigAdvData(tESP_BLE_ADV_DATA *adv_data,
tAPI_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback) tAPI_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
@ -69,6 +71,99 @@ void API_Ble_AppStartAdvertising(tESP_API_BLE_ADV_PARAMS_ALL *ble_adv_params)
} }
void API_Ble_SetScanParams (tESP_BLE_SCAN_PARAMS *scan_params, tGATT_IF client_if,
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
{
if (API_BLE_ISVALID_PARAM(scan_params->scan_intv, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) &&
API_BLE_ISVALID_PARAM(scan_params->scan_win, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) &&
(scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS))
{
BTA_DmSetBleScanFilterParams(client_if,
scan_params->scan_intv,
scan_params->scan_win,
scan_params->scan_type,
scan_params->scan_fil_policy,
scan_params->addr_type_own,
scan_param_setup_cback);
}
}
void API_Ble_StartScanning (UINT8 duration, tBTA_DM_SEARCH_CBACK *p_results_cb)
{
if((duration != 0) && (p_results_cb != NULL))
{
///Start scan the device
BTA_DmBleObserve(true, duration, p_results_cb);
}else{
LOG_ERROR("The scan duration or p_results_cb invalid\n");
}
}
void API_Ble_AppStopAdvertising(void)
{
bool stop_adv = true;
BTA_DmBleBroadcast(stop_adv);
}
void API_Ble_AppUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
UINT16 max_int, UINT16 latency, UINT16 timeout)
{
if (min_int > max_int){
min_int = max_int;
}
if (min_int < BTM_BLE_CONN_INT_MIN || max_int > BTM_BLE_CONN_INT_MAX){
LOG_ERROR("Invalid interval value.\n");
}
BTA_DmBleUpdateConnectionParams(bd_addr, min_int, max_int,
latency, timeout);
}
void API_Ble_SetPacketDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
{
if (tx_data_length > BTM_BLE_DATA_SIZE_MAX){
tx_data_length = BTM_BLE_DATA_SIZE_MAX;
}else if (tx_data_length < BTM_BLE_DATA_SIZE_MIN){
tx_data_length = BTM_BLE_DATA_SIZE_MIN;
}
BTA_DmBleSetDataLength(remote_device, tx_data_length);
}
void API_Ble_SetRandAddress(BD_ADDR rand_addr)
{
if (rand_addr != NULL){
BTA_DmSetRandAddress(rand_addr);
}else{
LOG_ERROR("Invalid randrom address.\n");
}
}
void API_Ble_ConfigLocalPrivacy(BOOLEAN privacy_enable)
{
BTA_DmBleConfigLocalPrivacy(privacy_enable);
}
void API_Ble_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
{
if (p_app_uuid != NULL)
{
BTA_GATTC_AppRegister(p_app_uuid, *p_client_cb);
}else{
LOG_ERROR("The app uuid invalid.\n");
}
}

View File

@ -14,6 +14,7 @@
#include "bt_types.h" #include "bt_types.h"
#include "bt_app_defs.h" #include "bt_app_defs.h"
#include "bta_gatt_api.h"
typedef tBTA_SET_ADV_DATA_CMPL_CBACK tAPI_SET_ADV_DATA_CMPL_CBACK ; typedef tBTA_SET_ADV_DATA_CMPL_CBACK tAPI_SET_ADV_DATA_CMPL_CBACK ;
typedef tBTA_STATUS tAPI_STATUS; typedef tBTA_STATUS tAPI_STATUS;
@ -42,5 +43,7 @@ extern void API_Ble_SetRandAddress(BD_ADDR rand_addr);
extern void API_Ble_ConfigLocalPrivacy(BOOLEAN privacy_enable); extern void API_Ble_ConfigLocalPrivacy(BOOLEAN privacy_enable);
extern void API_Ble_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb);
void API_Ble_PrfEnable(); void API_Ble_PrfEnable();

View File

@ -64,6 +64,15 @@ typedef struct
tBLE_BD_ADDR *p_dir_bda; tBLE_BD_ADDR *p_dir_bda;
}tESP_API_BLE_ADV_PARAMS_ALL; }tESP_API_BLE_ADV_PARAMS_ALL;
typedef struct
{
UINT8 scan_type;
UINT16 scan_intv;
UINT16 scan_win;
UINT8 addr_type_own;
UINT8 scan_fil_policy;
}tESP_BLE_SCAN_PARAMS;
extern void ESP_AppBleConfigadvData(tESP_BLE_ADV_DATA *adv_data, extern void ESP_AppBleConfigadvData(tESP_BLE_ADV_DATA *adv_data,
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);