From 2cea783ca1639df0b2ffe80d2f421234175ff80f Mon Sep 17 00:00:00 2001 From: Yulong Date: Wed, 2 Nov 2016 02:21:31 -0400 Subject: [PATCH] component bt:Added the app_button event process function to the bt project --- .../profiles/esp/include/button_pro.h | 26 ++++++------ .../app_sample_button/app_button.c | 41 +++++++++++++++++++ .../bluedroid_demos/include/app_button_int.h | 14 +++++++ 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/components/bt/bluedroid/profiles/esp/include/button_pro.h b/components/bt/bluedroid/profiles/esp/include/button_pro.h index 08ca83cd19..8e95a0d99b 100644 --- a/components/bt/bluedroid/profiles/esp/include/button_pro.h +++ b/components/bt/bluedroid/profiles/esp/include/button_pro.h @@ -65,30 +65,30 @@ enum typedef struct { - BD_ADDR remote_bda; - BOOLEAN need_rsp; - UINT16 clt_cfg; + BD_ADDR remote_bda; + BOOLEAN need_rsp; + uint16_t clt_cfg; }but_write_data_t; typedef struct { BOOLEAN in_use; BOOLEAN congest; - UINT16 conn_id; + uint16_t conn_id; BOOLEAN connected; BD_ADDR remote_bda; - UINT32 trans_id; - UINT8 cur_srvc_id; + uint32_t trans_id; + uint8_t cur_srvc_id; }but_clcb_t; typedef struct { - UINT8 app_id; - UINT16 but_wirt_hdl; - UINT16 but_ntf_hdl; - UINT16 but_cfg_hdl; + uint8_t app_id; + uint16_t but_wirt_hdl; + uint16_t but_ntf_hdl; + uint16_t but_cfg_hdl; but_prf_cb_t p_cback; @@ -99,11 +99,11 @@ typedef struct typedef struct { but_clcb_t clcb; /* connection link*/ - tGATT_IF gatt_if; + esp_gatt_if_t gatt_if; BOOLEAN enabled; BOOLEAN is_primery; - but_inst_t button_inst; - UINT8 inst_id; + but_inst_t button_inst; + uint8_t inst_id; }button_env_cb_t; void Button_CreateService(void); diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c index c685e8e445..c224e7031d 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_profiles/app_sample_button/app_button.c @@ -41,6 +41,13 @@ #include "button_pro.h" #include "app_button_int.h" +static const tBTA_SYS_REG bta_gatts_reg = +{ + ble_but_prf_hdl_event, + ble_but_prf_disable +}; + + /******************************************************************************* ** @@ -82,6 +89,40 @@ BOOLEAN ble_but_prf_hdl_event(BT_HDR *msg_data) } +/******************************************************************************* +** +** Function ble_but_prf_disable +** +** Description This function is called to disable the button profile modlue +** +** Parameters None. +** +** Returns None +** +*******************************************************************************/ +void ble_but_prf_disable(void) +{ + BT_HDR *p_buf; + + if (bt_prf_sys_is_register(PRF_ID_BUT_LE) == FALSE) + { + APPL_TRACE_WARNING("button profile Module not enabled/already disabled"); + return; + } + + if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) + { + p_buf->event = BTA_GATTS_API_DISABLE_EVT; + bta_sys_sendmsg(p_buf); + } + bta_sys_deregister(PRF_ID_BUT_LE); + +} + + + + + #endif ///BUT_PROFILE_CFG diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/include/app_button_int.h b/examples/06_bluedroid_demos/components/bluedroid_demos/include/app_button_int.h index 5bfb430fde..bfd7c47086 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/include/app_button_int.h +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/include/app_button_int.h @@ -105,10 +105,24 @@ typedef struct uint16_t conhdl; }tBUT_DISABLE_IND; +typedef union +{ + uint16_t conhdl; + tBUT_CRT_DB_REQ but_crt_db_req; + tBUT_CRT_DB_CFM but_crt_db_cfm; + tBUT_CFG_NTF_IND but_cfg_ntf_ind; + tBUT_SND_CHAR_VAL_REQ but_snd_char_val_req; + tBUT_ENABLE_REQ but_enable_req; + tBUT_VAL_SND_CFM but_val_snd_cfm; + tBUT_DISABLE_IND but_disable_ind; +}tBUT_PRF_MSG; + BOOLEAN ble_but_prf_hdl_event(BT_HDR *msg_data); +void ble_but_prf_disable(void); + #endif ///BUT_PROFILE_CFG -- 2.40.0