diff --git a/components/bt/bluedroid/bta/sys/bta_sys_main.c b/components/bt/bluedroid/bta/sys/bta_sys_main.c index 36901e39d..b78b4116e 100755 --- a/components/bt/bluedroid/bta/sys/bta_sys_main.c +++ b/components/bt/bluedroid/bta/sys/bta_sys_main.c @@ -318,7 +318,7 @@ void bta_sys_hw_error(tBTA_SYS_HW_MSG *p_sys_hw_msg) UINT8 module_index; UNUSED(p_sys_hw_msg); - APPL_TRACE_DEBUG("%s", __FUNCTION__); + APPL_TRACE_DEBUG("%s\n", __FUNCTION__); for (module_index = 0; module_index < BTA_SYS_MAX_HW_MODULES; module_index++) { @@ -377,7 +377,7 @@ void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg ) bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]( BTA_SYS_HW_ON_EVT ); } - APPL_TRACE_EVENT ("bta_sys_hw_api_enable for %d, active modules 0x%04X", + APPL_TRACE_EVENT ("bta_sys_hw_api_enable for %d, active modules 0x%04X\n", p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active); } @@ -394,7 +394,7 @@ void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg ) *******************************************************************************/ void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg) { - APPL_TRACE_DEBUG("bta_sys_hw_api_disable for %d, active modules: 0x%04X", + APPL_TRACE_DEBUG("bta_sys_hw_api_disable for %d, active modules: 0x%04X\n", p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active ); /* make sure the related SW blocks were stopped */ @@ -442,7 +442,7 @@ void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg) *******************************************************************************/ void bta_sys_hw_evt_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg) { - APPL_TRACE_EVENT("bta_sys_hw_evt_enabled for %i", p_sys_hw_msg->hw_module); + APPL_TRACE_EVENT("bta_sys_hw_evt_enabled for %i\n", p_sys_hw_msg->hw_module); BTM_DeviceReset( NULL ); } @@ -461,7 +461,7 @@ void bta_sys_hw_evt_disabled(tBTA_SYS_HW_MSG *p_sys_hw_msg) { UINT8 hw_module_index; - APPL_TRACE_DEBUG("bta_sys_hw_evt_disabled - module 0x%X", p_sys_hw_msg->hw_module); + APPL_TRACE_DEBUG("bta_sys_hw_evt_disabled - module 0x%X\n", p_sys_hw_msg->hw_module); for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++) { @@ -485,7 +485,7 @@ void bta_sys_hw_evt_stack_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg) UINT8 hw_module_index; UNUSED(p_sys_hw_msg); - APPL_TRACE_DEBUG(" bta_sys_hw_evt_stack_enabled!notify the callers"); + APPL_TRACE_DEBUG(" bta_sys_hw_evt_stack_enabled!notify the callers\n"); for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++ ) { diff --git a/components/bt/bluedroid/profiles/core/bt_prf_sys_main.c b/components/bt/bluedroid/profiles/core/bt_prf_sys_main.c index d2eb922d7..48b2825eb 100644 --- a/components/bt/bluedroid/profiles/core/bt_prf_sys_main.c +++ b/components/bt/bluedroid/profiles/core/bt_prf_sys_main.c @@ -107,6 +107,7 @@ void bt_prf_sys_register(UINT8 id, const tBT_PRF_SYS_REG *p_reg) *******************************************************************************/ void bt_prf_sys_deregister(UINT8 id) { + bt_prf_sys_cb.reg[id] = NULL; bt_prf_sys_cb.is_reg[id] = FALSE; } diff --git a/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c b/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c index 1806d4e9a..a19856d17 100644 --- a/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c +++ b/components/bt/bluedroid/profiles/esp/ble_button/button_pro.c @@ -36,20 +36,20 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) -tBUTTON_CB_ENV button_cb_env; + button_env_cb_t button_cb_env; tBLE_BD_ADDR p_peer_bda = { .type = API_PUBLIC_ADDR, .bda = {0} }; -tESP_API_BLE_ADV_PARAMS_ALL adv_params = +esp_ble_adv_params_all_t adv_params = { .adv_int_min = BTM_BLE_ADV_INT_MIN + 0x100, .adv_int_max = BTM_BLE_ADV_INT_MIN + 0x100, .adv_type = API_NON_DISCOVERABLE, .addr_type_own = API_PUBLIC_ADDR, - .channel_map = API_BLE_ADV_CHNL_MAP, + .channel_map = ESP_BLE_ADV_CHNL_MAP, .adv_filter_policy = ADV_ALLOW_SCAN_ANY_CON_ANY, .p_dir_bda = &p_peer_bda }; @@ -59,7 +59,7 @@ tESP_API_BLE_ADV_PARAMS_ALL adv_params = /***************************************************************************** ** Constants *****************************************************************************/ -static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); +static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data); /******************************************************************************* @@ -71,14 +71,14 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data); ** Returns NULL ** *******************************************************************************/ -static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) +static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data) { - tBTA_GATTS_RSP rsp; - tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; - tBUT_INST *p_inst = &button_cb_env.button_inst; - UINT8 net_event = 0xff; - UINT8 len = 0; - UINT8 *p_rec_data = NULL; + esp_gatts_rsp_t rsp; + esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; + but_inst_t *p_inst = &button_cb_env.button_inst; + uint8_t net_event = 0xff; + uint8_t len = 0; + uint8_t *p_rec_data = NULL; //LOG_ERROR("p_data->status = %x\n",p_data->status); //if(p_data->status != BTA_GATT_OK){ // LOG_ERROR("button profile register failed\n"); @@ -87,7 +87,7 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) LOG_ERROR("button profile cb event = %x\n",event); switch(event) { - case BTA_GATTS_REG_EVT: + case ESP_GATTS_REG_EVT: LOG_ERROR("p_data->reg_oper.status = %x\n",p_data->reg_oper.status); LOG_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n",p_data->reg_oper.uuid.uu.uuid16); @@ -104,16 +104,16 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) Button_CreateService(); } break; - case BTA_GATTS_READ_EVT: + case ESP_GATTS_READ_EVT: //tBTA_GATTS_RSP 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.len = 2; - API_Ble_GattsSendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id, + esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id, p_data->req_data.status,&rsp); break; - case BTA_GATTS_WRITE_EVT: - API_Ble_GattsSendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id, + case ESP_GATTS_WRITE_EVT: + esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id, p_data->req_data.status,NULL); LOG_ERROR("Received button data:"); for(int i = 0; i < p_data->req_data.p_data->write_req.len; i++){ @@ -142,27 +142,27 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) (*p_inst->p_cback)(button_cb_env.button_inst.app_id,net_event,len,p_rec_data); } break; - case BTA_GATTS_CONF_EVT: + case ESP_GATTS_CFM_EVT: break; - case BTA_GATTS_CREATE_EVT: + case ESP_GATTS_CREATE_EVT: //tBT_UUID uuid_butt_write; uuid.uu.uuid16 = ATT_CHAR_BUTTON_WIT; //tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_READ); //tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE); - //uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; + //uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; button_cb_env.clcb.cur_srvc_id= p_data->create.service_id; button_cb_env.is_primery = p_data->create.is_primary; //uuid = {LEN_UUID_16, {ATT_CHAR_BUTTON_WIT}}; //start the button service after created - API_Ble_GattsStartService(p_data->create.service_id,BTA_GATT_TRANSPORT_LE); + esp_ble_gatts_start_srvc(p_data->create.service_id); //add the frist button characteristic --> write characteristic - API_Ble_GattsAddCharacteristic(button_cb_env.clcb.cur_srvc_id,&uuid, + esp_ble_gatts_add_char(button_cb_env.clcb.cur_srvc_id,&uuid, (GATT_PERM_WRITE|GATT_PERM_READ), (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE)); break; - case BTA_GATTS_ADD_CHAR_EVT: + case ESP_GATTS_ADD_CHAR_EVT: if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_WIT) { uuid.uu.uuid16 = ATT_CHAR_BUTTON_NTF; @@ -171,49 +171,47 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) //save the att handle to the env button_cb_env.button_inst.but_wirt_hdl = p_data->add_result.attr_id; //add the frist button characteristic --> Notify characteristic - API_Ble_GattsAddCharacteristic(button_cb_env.clcb.cur_srvc_id,&uuid, + esp_ble_gatts_add_char(button_cb_env.clcb.cur_srvc_id,&uuid, 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 //tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE); uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG; button_cb_env.button_inst.but_ntf_hdl = p_data->add_result.attr_id; - API_Ble_GattsAddCharDescriptor (button_cb_env.clcb.cur_srvc_id, + esp_ble_gatts_add_char_descr (button_cb_env.clcb.cur_srvc_id, (GATT_PERM_WRITE|GATT_PERM_WRITE), &uuid); } break; - case BTA_GATTS_ADD_CHAR_DESCR_EVT: + case ESP_GATTS_ADD_CHAR_DESCR_EVT: if(p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) { button_cb_env.button_inst.but_cfg_hdl = p_data->add_result.attr_id; } ///Start advertising LOG_ERROR("\nStart sent the ADV.\n"); - API_Ble_AppStartAdvertising(&adv_params); + esp_ble_start_advertising (&adv_params); break; - case BTA_GATTS_CONNECT_EVT: + case ESP_GATTS_CONNECT_EVT: //set the connection flag to true button_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda); break; - case BTA_GATTS_DISCONNECT_EVT: + case ESP_GATTS_DISCONNECT_EVT: //set the connection flag to true button_cb_env.clcb.connected = false; break; - case BTA_GATTS_OPEN_EVT: + case ESP_GATTS_OPEN_EVT: ///stop the advertising after connected - API_Ble_AppStopAdvertising(); + esp_ble_stop_advertising(); break; - case BTA_GATTS_CLOSE_EVT: + case ESP_GATTS_CLOSE_EVT: if(button_cb_env.clcb.connected && (button_cb_env.clcb.conn_id == p_data->conn.conn_id)) { //set the connection channal congested flag to true button_cb_env.clcb.congest = p_data->congest.congested; } break; - case BTA_GATTS_LISTEN_EVT: - break; - case BTA_GATTS_CONGEST_EVT: + case ESP_GATTS_CONGEST_EVT: break; default: break; @@ -232,17 +230,17 @@ static void button_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) *******************************************************************************/ void Button_CreateService(void) { - tBTA_GATTS_IF server_if ; - tBT_UUID uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; - UINT16 num_handle = KEY_IDX_NB; - UINT8 inst = 0x00; + esp_gatts_if_t server_if ; + esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}}; + uint16_t num_handle = KEY_IDX_NB; + uint8_t inst = 0x00; server_if = button_cb_env.gatt_if; button_cb_env.inst_id = inst; //if(!button_cb_env.enabled) //{ // LOG_ERROR("button service added error."); //} - API_Ble_GattsCreateService(server_if,&uuid,inst,num_handle,true); + esp_ble_gatts_create_srvc(server_if,&uuid,inst,num_handle,true); } @@ -255,9 +253,9 @@ void Button_CreateService(void) ** Returns NULL if not found. Otherwise pointer to the connection link block. ** *******************************************************************************/ -tBUT_CLCB *button_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda) +but_clcb_t *button_env_clcb_alloc (uint16_t conn_id, BD_ADDR remote_bda) { - tBUT_CLCB *p_clcb = NULL; + but_clcb_t *p_clcb = NULL; p_clcb = &button_cb_env.clcb; if(!p_clcb->in_use) @@ -281,10 +279,10 @@ tBUT_CLCB *button_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda) ** Returns total number of clcb found. ** *******************************************************************************/ -UINT16 button_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda) +uint16_t button_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda) { - UINT8 i_clcb; - tBUT_CLCB *p_clcb = NULL; + uint8_t i_clcb; + but_clcb_t *p_clcb = NULL; for(i_clcb = 0, p_clcb = &button_cb_env.clcb; i_clcb < BUTT_MAX_APPS; i_clcb++, p_clcb++) { @@ -307,16 +305,16 @@ UINT16 button_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda) ** *******************************************************************************/ -BOOLEAN button_env_clcb_dealloc(UINT16 conn_id) +BOOLEAN button_env_clcb_dealloc(uint16_t conn_id) { - UINT8 i_clcb = 0; - tBUT_CLCB *p_clcb = NULL; + uint16_t i_clcb = 0; + but_clcb_t *p_clcb = NULL; for(i_clcb = 0, p_clcb = &button_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++) { if(p_clcb->in_use && p_clcb->connected && (p_clcb->conn_id == conn_id)) { - memset(p_clcb, 0, sizeof(tBUT_CLCB)); + memset(p_clcb, 0, sizeof(but_clcb_t)); return TRUE; } } @@ -331,7 +329,7 @@ BOOLEAN button_env_clcb_dealloc(UINT16 conn_id) ** Description Initializa the GATT Service for button profiles. ** *******************************************************************************/ -tGATT_STATUS button_init (tBU_CBACK *call_back) +esp_gatt_status_t button_init (but_prf_cb_t call_back) { tBT_UUID app_uuid = {LEN_UUID_16,{ATT_SVC_BUTTON}}; @@ -343,7 +341,7 @@ tGATT_STATUS button_init (tBU_CBACK *call_back) } else { - memset(&button_cb_env,0,sizeof(tBUTTON_CB_ENV)); + memset(&button_cb_env,0,sizeof(button_env_cb_t)); } @@ -354,33 +352,33 @@ tGATT_STATUS button_init (tBU_CBACK *call_back) /* register the button profile to the BTA_GATTS module*/ - API_Ble_GattsAppRegister(&app_uuid,button_profile_cb); + esp_ble_gatts_app_register(&app_uuid,button_profile_cb); button_cb_env.enabled = TRUE; - return GATT_SUCCESS; + return ESP_GATT_OK; } -void button_disable(UINT16 connid) +void button_disable(uint16_t connid) { button_env_clcb_dealloc(connid); } -void button_msg_notify(UINT8 len, UINT8 *button_msg) +void button_msg_notify(uint16_t len, uint8_t *button_msg) { BOOLEAN conn_status = button_cb_env.clcb.connected; - UINT16 conn_id = button_cb_env.clcb.conn_id; - UINT16 attr_id = button_cb_env.button_inst.but_ntf_hdl; + uint16_t conn_id = button_cb_env.clcb.conn_id; + uint16_t attr_id = button_cb_env.button_inst.but_ntf_hdl; //notify rsp==false; indicate rsp==true. BOOLEAN rsp = false; if(!conn_status && button_cb_env.clcb.congest) { - LOG_ERROR("the conneciton for button profile has been loss"); + LOG_ERROR("the conneciton for button profile has been loss\n"); return; } - API_Ble_GattsHandleValueIndication (conn_id, attr_id, len, + esp_ble_gatts_hdl_val_indica (conn_id, attr_id, len, button_msg, rsp); } diff --git a/components/bt/bluedroid/profiles/esp/include/button_pro.h b/components/bt/bluedroid/profiles/esp/include/button_pro.h index 023e248af..08ca83cd1 100644 --- a/components/bt/bluedroid/profiles/esp/include/button_pro.h +++ b/components/bt/bluedroid/profiles/esp/include/button_pro.h @@ -17,6 +17,7 @@ #include "bt_target.h" #include "gatt_api.h" #include "gattdefs.h" +#include "bt_app_api.h" #define KEY_SUCCESS GATT_SUCCESS #define KEY_ILLEGAL_PARAM GATT_ILLEGAL_PARAMETER @@ -36,7 +37,7 @@ #define BUT_MAX_STRING_DATA 7 -typedef void (tBU_CBACK)(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *data); +typedef void (*but_prf_cb_t)(uint8_t app_id, uint8_t event, uint16_t len, uint8_t *value); #ifndef BUT_MAX_INT_NUM #define BUT_MAX_INT_NUM 4 @@ -67,7 +68,7 @@ typedef struct BD_ADDR remote_bda; BOOLEAN need_rsp; UINT16 clt_cfg; -}tBUT_WRITE_DATA; +}but_write_data_t; typedef struct { @@ -79,7 +80,7 @@ typedef struct UINT32 trans_id; UINT8 cur_srvc_id; -}tBUT_CLCB; +}but_clcb_t; typedef struct @@ -89,36 +90,36 @@ typedef struct UINT16 but_ntf_hdl; UINT16 but_cfg_hdl; - tBU_CBACK *p_cback; + but_prf_cb_t p_cback; -}tBUT_INST; +}but_inst_t; /* service engine control block */ typedef struct { - tBUT_CLCB clcb; /* connection link*/ + but_clcb_t clcb; /* connection link*/ tGATT_IF gatt_if; BOOLEAN enabled; BOOLEAN is_primery; - tBUT_INST button_inst; + but_inst_t button_inst; UINT8 inst_id; -}tBUTTON_CB_ENV; +}button_env_cb_t; void Button_CreateService(void); -tBUT_CLCB *button_env_clcb_alloc(UINT16 conn_id, BD_ADDR bda); +but_clcb_t *button_env_clcb_alloc(uint16_t conn_id, BD_ADDR bda); -UINT16 button_env_find_conn_id_by_bd_adddr(BD_ADDR bda); +uint16_t button_env_find_conn_id_by_bd_adddr(BD_ADDR bda); -BOOLEAN button_env_clcb_dealloc(UINT16 conn_id); +BOOLEAN button_env_clcb_dealloc(uint16_t conn_id); -tGATT_STATUS button_init(tBU_CBACK *call_back); +esp_gatt_status_t button_init(but_prf_cb_t call_back); -void button_disable(UINT16 connid); +void button_disable(uint16_t connid); -void button_msg_notify(UINT8 len, UINT8 *button_msg); +void button_msg_notify(uint16_t len, uint8_t *button_msg); -extern tBUTTON_CB_ENV button_cb_env; +extern button_env_cb_t button_cb_env; #endif ///BUT_PROFILE_CFG \ No newline at end of file diff --git a/components/bt/bluedroid/profiles/std/include/prf_defs.h b/components/bt/bluedroid/profiles/std/include/prf_defs.h index 807b767d2..351657b6b 100644 --- a/components/bt/bluedroid/profiles/std/include/prf_defs.h +++ b/components/bt/bluedroid/profiles/std/include/prf_defs.h @@ -27,7 +27,7 @@ #define ATT_UUID_32_LEN 0x0004 #define WX_AIRSYNC_CFG 0 -#define BUT_PROFILE_CFG 0 +#define BUT_PROFILE_CFG 1 #define HIDD_LE_PROFILE_CFG 0 /* diff --git a/components/bt/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/bluedroid/stack/btm/btm_ble_bgconn.c index b5eef2ecc..e69d44637 100755 --- a/components/bt/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_bgconn.c @@ -581,7 +581,7 @@ void btm_ble_initiate_select_conn(BD_ADDR bda) *******************************************************************************/ BOOLEAN btm_ble_suspend_bg_conn(void) { - BTM_TRACE_EVENT ("%s", __func__); + BTM_TRACE_EVENT ("%s\n", __func__); if (btm_cb.ble_ctr_cb.bg_conn_type == BTM_BLE_CONN_AUTO) return btm_ble_start_auto_conn(FALSE); diff --git a/components/bt/bluedroid/stack/btu/btu_hcif.c b/components/bt/bluedroid/stack/btu/btu_hcif.c index 4644d7a27..4c1a40f1d 100755 --- a/components/bt/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/bluedroid/stack/btu/btu_hcif.c @@ -1196,7 +1196,7 @@ static void btu_hcif_command_status_evt(uint8_t status, BT_HDR *command, void *c *******************************************************************************/ static void btu_hcif_hardware_error_evt (UINT8 *p) { - HCI_TRACE_ERROR("Ctlr H/w error event - code:0x%x", *p); + HCI_TRACE_ERROR("Ctlr H/w error event - code:0x%x\n", *p); /* If anyone wants device status notifications, give him one. */ btm_report_device_status (BTM_DEV_STATUS_DOWN); diff --git a/components/bt/bluedroid/stack/include/l2cdefs.h b/components/bt/bluedroid/stack/include/l2cdefs.h index a6e25eb9e..b4b6f5138 100755 --- a/components/bt/bluedroid/stack/include/l2cdefs.h +++ b/components/bt/bluedroid/stack/include/l2cdefs.h @@ -38,6 +38,7 @@ #define L2CAP_CMD_AMP_MOVE_RSP 0x0F #define L2CAP_CMD_AMP_MOVE_CFM 0x10 #define L2CAP_CMD_AMP_MOVE_CFM_RSP 0x11 + #define L2CAP_CMD_BLE_UPDATE_REQ 0x12 #define L2CAP_CMD_BLE_UPDATE_RSP 0x13 diff --git a/components/bt/bluedroid/stack/l2cap/l2c_link.c b/components/bt/bluedroid/stack/l2cap/l2c_link.c index 40696ad20..9cf80c3ea 100755 --- a/components/bt/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_link.c @@ -134,7 +134,7 @@ BOOLEAN l2c_link_hci_conn_req (BD_ADDR bd_addr) } else { - L2CAP_TRACE_ERROR("L2CAP got conn_req while connected (state:%d). Reject it", + L2CAP_TRACE_ERROR("L2CAP got conn_req while connected (state:%d). Reject it\n", p_lcb->link_state); /* Reject the connection with ACL Connection Already exist reason */ //counter_add("l2cap.conn.reject.exists", 1); @@ -172,13 +172,13 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda) /* If we don't have one, this is an error */ if (!p_lcb) { - L2CAP_TRACE_WARNING ("L2CAP got conn_comp for unknown BD_ADDR"); + L2CAP_TRACE_WARNING ("L2CAP got conn_comp for unknown BD_ADDR\n"); return (FALSE); } if (p_lcb->link_state != LST_CONNECTING) { - L2CAP_TRACE_ERROR ("L2CAP got conn_comp in bad state: %d status: 0x%d", p_lcb->link_state, status); + L2CAP_TRACE_ERROR ("L2CAP got conn_comp in bad state: %d status: 0x%d\n", p_lcb->link_state, status); if (status != HCI_SUCCESS) l2c_link_hci_disc_comp (p_lcb->handle, status); @@ -314,7 +314,7 @@ void l2c_link_sec_comp (BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data /* If we don't have one, this is an error */ if (!p_lcb) { - L2CAP_TRACE_WARNING ("L2CAP got sec_comp for unknown BD_ADDR"); + L2CAP_TRACE_WARNING ("L2CAP got sec_comp for unknown BD_ADDR\n"); return; } @@ -774,7 +774,7 @@ void l2c_link_adjust_allocation (void) qq = qq_remainder = 1; } - L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation num_hipri: %u num_lowpri: %u low_quota: %u round_robin_quota: %u qq: %u", + L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation num_hipri: %u num_lowpri: %u low_quota: %u round_robin_quota: %u qq: %u\n", num_hipri_links, num_lowpri_links, low_quota, l2cb.round_robin_quota, qq); @@ -803,10 +803,10 @@ void l2c_link_adjust_allocation (void) } } - L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation LCB %d Priority: %d XmitQuota: %d", + L2CAP_TRACE_EVENT ("l2c_link_adjust_allocation LCB %d Priority: %d XmitQuota: %d\n", yy, p_lcb->acl_priority, p_lcb->link_xmit_quota); - L2CAP_TRACE_EVENT (" SentNotAcked: %d RRUnacked: %d", + L2CAP_TRACE_EVENT (" SentNotAcked: %d RRUnacked: %d\n", p_lcb->sent_not_acked, l2cb.round_robin_unacked); /* There is a special case where we have readjusted the link quotas and */ @@ -1081,7 +1081,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb) { if ( mode == BTM_PM_STS_PENDING ) { - L2CAP_TRACE_DEBUG ("LCB(0x%x) is in PM pending state", p_lcb->handle); + L2CAP_TRACE_DEBUG ("LCB(0x%x) is in PM pending state\n", p_lcb->handle); return TRUE; } @@ -1510,7 +1510,7 @@ void l2c_link_process_num_completed_pkts (UINT8 *p) #if (BLE_INCLUDED == TRUE) if (p_lcb->transport == BT_TRANSPORT_LE) { - L2CAP_TRACE_DEBUG ("TotalWin=%d,LinkUnack(0x%x)=%d,RRCheck=%d,RRUnack=%d", + L2CAP_TRACE_DEBUG ("TotalWin=%d,LinkUnack(0x%x)=%d,RRCheck=%d,RRUnack=%d\n", l2cb.controller_le_xmit_window, p_lcb->handle, p_lcb->sent_not_acked, l2cb.ble_check_round_robin, l2cb.ble_round_robin_unacked); @@ -1518,7 +1518,7 @@ void l2c_link_process_num_completed_pkts (UINT8 *p) else #endif { - L2CAP_TRACE_DEBUG ("TotalWin=%d,LinkUnack(0x%x)=%d,RRCheck=%d,RRUnack=%d", + L2CAP_TRACE_DEBUG ("TotalWin=%d,LinkUnack(0x%x)=%d,RRCheck=%d,RRUnack=%d\n", l2cb.controller_xmit_window, p_lcb->handle, p_lcb->sent_not_acked, l2cb.check_round_robin, l2cb.round_robin_unacked); @@ -1528,13 +1528,13 @@ void l2c_link_process_num_completed_pkts (UINT8 *p) else { #if (BLE_INCLUDED == TRUE) - L2CAP_TRACE_DEBUG ("TotalWin=%d LE_Win: %d, Handle=0x%x, RRCheck=%d, RRUnack=%d", + L2CAP_TRACE_DEBUG ("TotalWin=%d LE_Win: %d, Handle=0x%x, RRCheck=%d, RRUnack=%d\n", l2cb.controller_xmit_window, l2cb.controller_le_xmit_window, handle, l2cb.ble_check_round_robin, l2cb.ble_round_robin_unacked); #else - L2CAP_TRACE_DEBUG ("TotalWin=%d Handle=0x%x RRCheck=%d RRUnack=%d", + L2CAP_TRACE_DEBUG ("TotalWin=%d Handle=0x%x RRCheck=%d RRUnack=%d\n", l2cb.controller_xmit_window, handle, l2cb.check_round_robin, l2cb.round_robin_unacked); @@ -1572,7 +1572,7 @@ void l2c_link_segments_xmitted (BT_HDR *p_msg) /* Find the LCB based on the handle */ if ((p_lcb = l2cu_find_lcb_by_handle (handle)) == NULL) { - L2CAP_TRACE_WARNING ("L2CAP - rcvd segment complete, unknown handle: %d", handle); + L2CAP_TRACE_WARNING ("L2CAP - rcvd segment complete, unknown handle: %d\n", handle); GKI_freebuf (p_msg); return; } diff --git a/components/bt/bluedroid/stack/l2cap/l2cap_client.c b/components/bt/bluedroid/stack/l2cap/l2cap_client.c index 4b64e1198..086500276 100755 --- a/components/bt/bluedroid/stack/l2cap/l2cap_client.c +++ b/components/bt/bluedroid/stack/l2cap/l2cap_client.c @@ -268,7 +268,7 @@ static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *nego case L2CAP_CFG_UNACCEPTABLE_PARAMS: // TODO: see if we can renegotiate parameters instead of dropping the connection. - LOG_WARN("%s dropping L2CAP connection due to unacceptable config parameters.", __func__); + LOG_WARN("%s dropping L2CAP connection due to unacceptable config parameters.\n", __func__); l2cap_client_disconnect(client); break; @@ -281,7 +281,7 @@ static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *nego // Failure, no further parameter negotiation possible. default: - LOG_WARN("%s L2CAP parameter negotiation failed with error code %d.", __func__, negotiated_parameters->result); + LOG_WARN("%s L2CAP parameter negotiation failed with error code %d.\n", __func__, negotiated_parameters->result); l2cap_client_disconnect(client); break; } @@ -290,7 +290,7 @@ static void config_completed_cb(uint16_t local_channel_id, tL2CAP_CFG_INFO *nego static void disconnect_request_cb(uint16_t local_channel_id, bool ack_required) { l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.", __func__, local_channel_id); + LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -309,7 +309,7 @@ static void disconnect_completed_cb(uint16_t local_channel_id, UNUSED_ATTR uint1 l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.", __func__, local_channel_id); + LOG_ERROR("%s unable to find L2CAP client with LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -324,7 +324,7 @@ static void congestion_cb(uint16_t local_channel_id, bool is_congested) { l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.\n", __func__, local_channel_id); return; } @@ -345,7 +345,7 @@ static void read_ready_cb(uint16_t local_channel_id, BT_HDR *packet) { l2cap_client_t *client = find(local_channel_id); if (!client) { - LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.", __func__, local_channel_id); + LOG_ERROR("%s unable to find L2CAP client matching LCID 0x%04x.\n", __func__, local_channel_id); return; } diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c index 6c24854dd..2e0b742a3 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_project/SampleServerProject.c @@ -168,7 +168,7 @@ esp_ble_adv_data_cfg_t wechat_adv_data[ADV_SCAN_IDX_MAX] = }; #if (BUT_PROFILE_CFG) -static void SimpleDataCallBack(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *p_data); +static void SimpleDataCallBack(uint8_t app_id, uint8_t event, uint16_t len, uint8_t *p_data); #endif typedef struct { @@ -303,7 +303,7 @@ void bta_gatts_callback(tBTA_GATTS_EVT event, tBTA_GATTS* p_data) } #if (BUT_PROFILE_CFG) -static void SimpleDataCallBack(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *p_data) +static void SimpleDataCallBack(uint8_t app_id, uint8_t event, uint16_t len, uint8_t *p_data) { LOG_ERROR("the event value is:%x\n",event); switch(event) diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h b/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h index f2012dca5..265c014ad 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/include/bt_app_defs.h @@ -63,7 +63,6 @@ typedef tBTA_GATTC_IF esp_gattc_if_t; #define ESP_GATTC_ACL_EVT 13 /* ACL up event */ #define ESP_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */ #define ESP_GATTC_SRVC_CHG_EVT 15 /* service change event */ -#define ESP_GATTC_LISTEN_EVT 16 /* listen event */ #define ESP_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */ #define ESP_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */ #define ESP_GATTC_ADV_DATA_EVT 19 /* ADV data event */ @@ -91,7 +90,7 @@ typedef tBTA_GATTC_IF esp_gattc_if_t; #define ESP_GATTS_WRITE_EVT GATTS_REQ_TYPE_WRITE /* 2 */ #define ESP_GATTS_EXEC_WRITE_EVT GATTS_REQ_TYPE_WRITE_EXEC /* 3 */ #define ESP_GATTS_MTU_EVT GATTS_REQ_TYPE_MTU /* 4 */ -#define ESP_GATTS_CONF_EVT GATTS_REQ_TYPE_CONF /* 5 */ +#define ESP_GATTS_CFM_EVT GATTS_REQ_TYPE_CONF /* 5 */ #define ESP_GATTS_DEREG_EVT 6 #define ESP_GATTS_CREATE_EVT 7 #define ESP_GATTS_ADD_INCL_SRVC_EVT 8 @@ -105,7 +104,6 @@ typedef tBTA_GATTC_IF esp_gattc_if_t; #define ESP_GATTS_OPEN_EVT 16 #define ESP_GATTS_CANCEL_OPEN_EVT 17 #define ESP_GATTS_CLOSE_EVT 18 -#define ESP_GATTS_LISTEN_EVT 19 #define ESP_GATTS_CONGEST_EVT 20 /* Attribute permissions