forked from espressif/esp-idf
component bt:Change the profile & app interface to new API
This commit is contained in:
@@ -1324,7 +1324,7 @@ extern void BTA_DmBleBroadcast (BOOLEAN start)
|
|||||||
{
|
{
|
||||||
tBTA_DM_API_BLE_OBSERVE *p_msg;
|
tBTA_DM_API_BLE_OBSERVE *p_msg;
|
||||||
|
|
||||||
APPL_TRACE_API("BTA_DmBleBroadcast: start = %d ", start);
|
APPL_TRACE_API("BTA_DmBleBroadcast: start = %d \n", start);
|
||||||
|
|
||||||
if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
|
if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
|
||||||
{
|
{
|
||||||
|
@@ -60,7 +60,7 @@ void BTA_GATTC_Disable(void)
|
|||||||
|
|
||||||
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
|
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
|
||||||
{
|
{
|
||||||
APPL_TRACE_WARNING("GATTC Module not enabled/already disabled");
|
APPL_TRACE_WARNING("GATTC Module not enabled/already disabled\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "bta_api.h"
|
#include "bta_api.h"
|
||||||
#include "bta_gatt_api.h"
|
#include "bta_gatt_api.h"
|
||||||
#include "bta_gatts_int.h"
|
#include "bta_gatts_int.h"
|
||||||
|
#include "bt_app_api.h"
|
||||||
#include "button_pro.h"
|
#include "button_pro.h"
|
||||||
|
|
||||||
#include "prf_defs.h"
|
#include "prf_defs.h"
|
||||||
@@ -92,11 +93,11 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP));
|
memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP));
|
||||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||||
rsp.attr_value.len = 2;
|
rsp.attr_value.len = 2;
|
||||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
API_Ble_GattsSendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||||
p_data->req_data.status,&rsp);
|
p_data->req_data.status,&rsp);
|
||||||
break;
|
break;
|
||||||
case BTA_GATTS_WRITE_EVT:
|
case BTA_GATTS_WRITE_EVT:
|
||||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
API_Ble_GattsSendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||||
p_data->req_data.status,NULL);
|
p_data->req_data.status,NULL);
|
||||||
LOG_ERROR("Received button data:");
|
LOG_ERROR("Received button data:");
|
||||||
for(int i = 0; i < p_data->req_data.p_data->write_req.len; i++){
|
for(int i = 0; i < p_data->req_data.p_data->write_req.len; i++){
|
||||||
@@ -138,9 +139,9 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
button_cb_env.is_primery = p_data->create.is_primary;
|
button_cb_env.is_primery = p_data->create.is_primary;
|
||||||
//uuid = {LEN_UUID_16, {ATT_CHAR_BUTTON_WIT}};
|
//uuid = {LEN_UUID_16, {ATT_CHAR_BUTTON_WIT}};
|
||||||
//start the button service after created
|
//start the button service after created
|
||||||
BTA_GATTS_StartService(p_data->create.service_id,BTA_GATT_TRANSPORT_LE);
|
API_Ble_GattsStartService(p_data->create.service_id,BTA_GATT_TRANSPORT_LE);
|
||||||
//add the frist button characteristic --> write characteristic
|
//add the frist button characteristic --> write characteristic
|
||||||
BTA_GATTS_AddCharacteristic(button_cb_env.clcb.cur_srvc_id,&uuid,
|
API_Ble_GattsAddCharacteristic(button_cb_env.clcb.cur_srvc_id,&uuid,
|
||||||
(GATT_PERM_WRITE|GATT_PERM_READ),
|
(GATT_PERM_WRITE|GATT_PERM_READ),
|
||||||
(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE));
|
(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE));
|
||||||
break;
|
break;
|
||||||
@@ -154,13 +155,13 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
//save the att handle to the env
|
//save the att handle to the env
|
||||||
button_cb_env.button_inst.but_wirt_hdl = p_data->add_result.attr_id;
|
button_cb_env.button_inst.but_wirt_hdl = p_data->add_result.attr_id;
|
||||||
//add the frist button characteristic --> Notify characteristic
|
//add the frist button characteristic --> Notify characteristic
|
||||||
BTA_GATTS_AddCharacteristic(button_cb_env.clcb.cur_srvc_id,&uuid,
|
API_Ble_GattsAddCharacteristic(button_cb_env.clcb.cur_srvc_id,&uuid,
|
||||||
GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY));
|
GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY));
|
||||||
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_NTF){ // add the gattc config descriptor to the notify charateristic
|
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_NTF){ // add the gattc config descriptor to the notify charateristic
|
||||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
||||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||||
button_cb_env.button_inst.but_ntf_hdl = p_data->add_result.attr_id;
|
button_cb_env.button_inst.but_ntf_hdl = p_data->add_result.attr_id;
|
||||||
BTA_GATTS_AddCharDescriptor (button_cb_env.clcb.cur_srvc_id,
|
API_Ble_GattsAddCharDescriptor (button_cb_env.clcb.cur_srvc_id,
|
||||||
(GATT_PERM_WRITE|GATT_PERM_WRITE),
|
(GATT_PERM_WRITE|GATT_PERM_WRITE),
|
||||||
&uuid);
|
&uuid);
|
||||||
}
|
}
|
||||||
@@ -181,6 +182,8 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
button_cb_env.clcb.connected = false;
|
button_cb_env.clcb.connected = false;
|
||||||
break;
|
break;
|
||||||
case BTA_GATTS_OPEN_EVT:
|
case BTA_GATTS_OPEN_EVT:
|
||||||
|
///stop the advertising after connected
|
||||||
|
API_Ble_AppStopAdvertising();
|
||||||
break;
|
break;
|
||||||
case BTA_GATTS_CLOSE_EVT:
|
case BTA_GATTS_CLOSE_EVT:
|
||||||
if(button_cb_env.clcb.connected && (button_cb_env.clcb.conn_id == p_data->conn.conn_id))
|
if(button_cb_env.clcb.connected && (button_cb_env.clcb.conn_id == p_data->conn.conn_id))
|
||||||
@@ -220,7 +223,7 @@ void Button_CreateService(void)
|
|||||||
//{
|
//{
|
||||||
// LOG_ERROR("button service added error.");
|
// LOG_ERROR("button service added error.");
|
||||||
//}
|
//}
|
||||||
BTA_GATTS_CreateService(server_if,&uuid,inst,num_handle,true);
|
API_Ble_GattsCreateService(server_if,&uuid,inst,num_handle,true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +335,7 @@ tGATT_STATUS button_init (tBU_CBACK *call_back)
|
|||||||
|
|
||||||
|
|
||||||
/* register the button profile to the BTA_GATTS module*/
|
/* register the button profile to the BTA_GATTS module*/
|
||||||
BTA_GATTS_AppRegister(&app_uuid,button_profile_cb);
|
API_Ble_GattsAppRegister(&app_uuid,button_profile_cb);
|
||||||
|
|
||||||
button_cb_env.enabled = TRUE;
|
button_cb_env.enabled = TRUE;
|
||||||
|
|
||||||
@@ -358,7 +361,7 @@ void button_msg_notify(UINT8 len, UINT8 *button_msg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BTA_GATTS_HandleValueIndication (conn_id, attr_id, len,
|
API_Ble_GattsHandleValueIndication (conn_id, attr_id, len,
|
||||||
button_msg, rsp);
|
button_msg, rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -158,8 +158,8 @@ static void bas_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
|||||||
bas_service_cmpl(p_data->srvc_oper.service_id, p_data->srvc_oper.status);
|
bas_service_cmpl(p_data->srvc_oper.service_id, p_data->srvc_oper.status);
|
||||||
|
|
||||||
/*start advertising*/
|
/*start advertising*/
|
||||||
if(p_data->srvc_oper.status == GATT_SUCCESS)
|
//if(p_data->srvc_oper.status == GATT_SUCCESS)
|
||||||
BTA_GATTS_Listen(server_if, true, NULL);
|
// BTA_GATTS_Listen(server_if, true, NULL);
|
||||||
// BTA_GATTC_Broadcast(client_if, true); //non-connectable
|
// BTA_GATTC_Broadcast(client_if, true); //non-connectable
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "hid_le_prf.h"
|
#include "hid_le_prf.h"
|
||||||
|
|
||||||
|
#include "bt_app_api.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "hcimsgs.h"
|
#include "hcimsgs.h"
|
||||||
@@ -78,6 +80,18 @@ UINT8 wechat_manu[] = {0x00,0x00,0x18,0xfe,0x34,0x6a,0x86,0x2e};
|
|||||||
tBTA_BLE_MANU p_ijiazu_manu = {sizeof(ijiazu_manu),ijiazu_manu}; /* manufacturer data */
|
tBTA_BLE_MANU p_ijiazu_manu = {sizeof(ijiazu_manu),ijiazu_manu}; /* manufacturer data */
|
||||||
tBTA_BLE_MANU p_wechat_manu = {sizeof(wechat_manu),wechat_manu};
|
tBTA_BLE_MANU p_wechat_manu = {sizeof(wechat_manu),wechat_manu};
|
||||||
|
|
||||||
|
tESP_API_BLE_ADV_PARAMS_ALL adv_params =
|
||||||
|
{
|
||||||
|
.adv_int_min = BTM_BLE_ADV_INT_MIN + 0x100,
|
||||||
|
.adv_int_max = BTM_BLE_ADV_INT_MIN + 0x100,
|
||||||
|
.adv_type = API_GEN_DISCOVERABLE,
|
||||||
|
.addr_type_own = API_PUBLIC_ADDR,
|
||||||
|
.channel_map = API_BLE_ADV_CHNL_MAP,
|
||||||
|
.adv_filter_policy = API_ADV_UNDIRECT,
|
||||||
|
{API_PUBLIC_ADDR,NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
BD_ADDR rand_ijiazu_addr = {0x00,0x02,0x5B,0x00,0x32,0x55};
|
BD_ADDR rand_ijiazu_addr = {0x00,0x02,0x5B,0x00,0x32,0x55};
|
||||||
|
|
||||||
tESP_BLE_ADV_DATA ijiazu_adv_data[ADV_SCAN_IDX_MAX] =
|
tESP_BLE_ADV_DATA ijiazu_adv_data[ADV_SCAN_IDX_MAX] =
|
||||||
@@ -254,6 +268,8 @@ static void bta_gatts_set_adv_data_cback(tBTA_STATUS call_status)
|
|||||||
#if (WX_AIRSYNC_CFG)
|
#if (WX_AIRSYNC_CFG)
|
||||||
AirSync_Init(NULL);
|
AirSync_Init(NULL);
|
||||||
#endif ///WX_AIRSYNC_CFG
|
#endif ///WX_AIRSYNC_CFG
|
||||||
|
|
||||||
|
API_Ble_AppStartAdvertising(&adv_params);
|
||||||
/*start advetising*/
|
/*start advetising*/
|
||||||
// BTA_GATTS_Listen(server_if, true, NULL);
|
// BTA_GATTS_Listen(server_if, true, NULL);
|
||||||
}
|
}
|
||||||
@@ -272,10 +288,8 @@ void bta_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data)
|
|||||||
|
|
||||||
LOG_ERROR("set advertising parameters\n");
|
LOG_ERROR("set advertising parameters\n");
|
||||||
//set the advertising data to the btm layer
|
//set the advertising data to the btm layer
|
||||||
ESP_AppBleConfigadvData(&wechat_adv_data[BLE_ADV_DATA_IDX],
|
API_Ble_AppConfigAdvData(&wechat_adv_data[BLE_ADV_DATA_IDX],
|
||||||
bta_gatts_set_adv_data_cback);
|
bta_gatts_set_adv_data_cback);
|
||||||
//set the adversting data to the btm layer
|
|
||||||
ESP_AppBleSetScanRsp(&wechat_adv_data[BLE_SCAN_RSP_DATA_IDX],NULL);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -325,7 +339,7 @@ static void ble_server_appRegister(void)
|
|||||||
btif_to_bta_uuid(&t_uuid, &uuid);
|
btif_to_bta_uuid(&t_uuid, &uuid);
|
||||||
|
|
||||||
LOG_ERROR("register gatts application\n");
|
LOG_ERROR("register gatts application\n");
|
||||||
BTA_GATTS_AppRegister(&t_uuid, bta_gatts_callback);
|
API_Ble_GattsAppRegister(&t_uuid, bta_gatts_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gatts_server_test(void)
|
void gatts_server_test(void)
|
||||||
|
@@ -1,8 +1,20 @@
|
|||||||
|
|
||||||
|
#ifndef _BT_APP_DEFS_H__
|
||||||
|
#define _BT_APP_DEFS_H__
|
||||||
|
|
||||||
|
|
||||||
#include "bta_api.h"
|
#include "bta_api.h"
|
||||||
#include "btm_ble_api.h"
|
#include "btm_ble_api.h"
|
||||||
|
|
||||||
#define API_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
#define API_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||||
|
|
||||||
|
#define API_BLE_ADV_CHNL_MAP (API_BLE_ADV_CHNL_37|API_BLE_ADV_CHNL_38|API_BLE_ADV_CHNL_39)
|
||||||
|
|
||||||
|
/* advertising channel map */
|
||||||
|
#define API_BLE_ADV_CHNL_37 (0x01 << 0)
|
||||||
|
#define API_BLE_ADV_CHNL_38 (0x01 << 1)
|
||||||
|
#define API_BLE_ADV_CHNL_39 (0x01 << 2)
|
||||||
|
|
||||||
|
|
||||||
#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == API_BLE_CONN_PARAM_UNDEF))
|
#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == API_BLE_CONN_PARAM_UNDEF))
|
||||||
|
|
||||||
@@ -39,6 +51,24 @@ enum api_adv_filter
|
|||||||
API_ADV_DIRECT
|
API_ADV_DIRECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Own BD address source of the device
|
||||||
|
enum api_own_addr_src
|
||||||
|
{
|
||||||
|
/// Public Address
|
||||||
|
API_PUBLIC_ADDR,
|
||||||
|
/// Provided random address
|
||||||
|
API_PROVIDED_RND_ADDR,
|
||||||
|
/// Provided static random address
|
||||||
|
API_GEN_STATIC_RND_ADDR,
|
||||||
|
/// Generated resolvable private random address
|
||||||
|
API_GEN_RSLV_ADDR,
|
||||||
|
/// Generated non-resolvable private random address
|
||||||
|
API_GEN_NON_RSLV_ADDR,
|
||||||
|
/// Provided Reconnection address
|
||||||
|
API_PROVIDED_RECON_ADDR,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -81,3 +111,6 @@ extern void ESP_AppBleSetScanRsp(tESP_BLE_ADV_DATA *scan_rsp_data,
|
|||||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
|
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif ///_BT_APP_DEFS_H__
|
Reference in New Issue
Block a user