Loading system/stack/gatt/gatt_api.cc +50 −71 Original line number Diff line number Diff line Loading @@ -407,11 +407,7 @@ void GATTS_StopService(uint16_t service_handle) { ******************************************************************************/ tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle, uint16_t val_len, uint8_t* p_val) { tGATT_STATUS cmd_status = GATT_NO_RESOURCES; tGATT_VALUE indication; BT_HDR* p_msg; tGATT_VALUE* p_buf; tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); tGATT_REG* p_reg = gatt_get_regcb(gatt_if); Loading @@ -425,6 +421,7 @@ tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle, if (!GATT_HANDLE_IS_VALID(attr_handle)) return GATT_ILLEGAL_PARAMETER; tGATT_VALUE indication; indication.conn_id = conn_id; indication.handle = attr_handle; indication.len = val_len; Loading @@ -433,25 +430,21 @@ tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle, if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle)) { VLOG(1) << "Add a pending indication"; p_buf = gatt_add_pending_ind(p_tcb, &indication); if (p_buf != NULL) { cmd_status = GATT_SUCCESS; } else { cmd_status = GATT_NO_RESOURCES; gatt_add_pending_ind(p_tcb, &indication); return GATT_SUCCESS; } } else { tGATT_SR_MSG gatt_sr_msg; gatt_sr_msg.attr_value = indication; p_msg = attp_build_sr_msg(*p_tcb, GATT_HANDLE_VALUE_IND, &gatt_sr_msg); if (p_msg != NULL) { cmd_status = attp_send_sr_msg(*p_tcb, p_msg); BT_HDR* p_msg = attp_build_sr_msg(*p_tcb, GATT_HANDLE_VALUE_IND, &gatt_sr_msg); if (!p_msg) return GATT_NO_RESOURCES; tGATT_STATUS cmd_status = attp_send_sr_msg(*p_tcb, p_msg); if (cmd_status == GATT_SUCCESS || cmd_status == GATT_CONGESTED) { p_tcb->indicate_handle = indication.handle; gatt_start_conf_timer(p_tcb); } } } return cmd_status; } Loading Loading @@ -909,10 +902,9 @@ tGATT_STATUS GATTC_SendHandleValueConfirm(uint16_t conn_id, uint16_t handle) { ******************************************************************************/ void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout, tBT_TRANSPORT transport) { tGATT_TCB* p_tcb; bool status = false; p_tcb = gatt_find_tcb_by_addr(bd_addr, transport); tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, transport); if (p_tcb != NULL) { if (p_tcb->att_lcid == L2CAP_ATT_CID) { status = L2CA_SetFixedChannelTout(bd_addr, L2CAP_ATT_CID, idle_tout); Loading Loading @@ -1021,14 +1013,14 @@ void GATT_Deregister(tGATT_IF gatt_if) { tGATT_TCB* p_tcb; int i, j; for (i = 0, p_tcb = gatt_cb.tcb; i < GATT_MAX_PHY_CHANNEL; i++, p_tcb++) { if (p_tcb->in_use) { if (!p_tcb->in_use) continue; if (gatt_get_ch_state(p_tcb) != GATT_CH_CLOSE) { gatt_update_app_use_link_flag(gatt_if, p_tcb, false, true); } tGATT_CLCB* p_clcb; for (j = 0, p_clcb = &gatt_cb.clcb[j]; j < GATT_CL_MAX_LCB; j++, p_clcb++) { for (j = 0, p_clcb = &gatt_cb.clcb[j]; j < GATT_CL_MAX_LCB; j++, p_clcb++) { if (p_clcb->in_use && (p_clcb->p_reg->gatt_if == gatt_if) && (p_clcb->p_tcb->tcb_idx == p_tcb->tcb_idx)) { alarm_cancel(p_clcb->gatt_rsp_timer_ent); Loading @@ -1037,7 +1029,6 @@ void GATT_Deregister(tGATT_IF gatt_if) { } } } } gatt_deregister_bgdev_list(gatt_if); Loading Loading @@ -1107,30 +1098,25 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct, bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct, tBT_TRANSPORT transport, bool opportunistic, uint8_t initiating_phys) { tGATT_REG* p_reg; bool status = false; LOG(INFO) << __func__ << "gatt_if=" << +gatt_if << " " << bd_addr; /* Make sure app is registered */ p_reg = gatt_get_regcb(gatt_if); if (p_reg == NULL) { tGATT_REG* p_reg = gatt_get_regcb(gatt_if); if (!p_reg) { LOG(ERROR) << "gatt_if = " << +gatt_if << " is not registered"; return (false); } if (is_direct) status = gatt_act_connect(p_reg, bd_addr, transport, opportunistic, return gatt_act_connect(p_reg, bd_addr, transport, opportunistic, initiating_phys); else { if (transport == BT_TRANSPORT_LE) status = gatt_auto_connect_dev_add(p_reg, bd_addr); else { // is not direct if (transport != BT_TRANSPORT_LE) { LOG(ERROR) << "Unsupported transport for background connection"; return false; } } return status; return gatt_auto_connect_dev_add(p_reg, bd_addr); } /******************************************************************************* Loading Loading @@ -1212,20 +1198,15 @@ bool GATT_CancelConnect(tGATT_IF gatt_if, const RawAddress& bd_addr, * ******************************************************************************/ tGATT_STATUS GATT_Disconnect(uint16_t conn_id) { tGATT_STATUS ret = GATT_ILLEGAL_PARAMETER; tGATT_TCB* p_tcb = NULL; tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); LOG(INFO) << __func__ << " conn_id=" << loghex(conn_id); p_tcb = gatt_get_tcb_by_idx(tcb_idx); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx); if (!p_tcb) return GATT_ILLEGAL_PARAMETER; if (p_tcb) { tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id); gatt_update_app_use_link_flag(gatt_if, p_tcb, false, true); ret = GATT_SUCCESS; } return ret; return GATT_SUCCESS; } /******************************************************************************* Loading @@ -1248,17 +1229,15 @@ bool GATT_GetConnectionInfor(uint16_t conn_id, tGATT_IF* p_gatt_if, tGATT_REG* p_reg = gatt_get_regcb(gatt_if); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx); bool status = false; VLOG(1) << __func__ << " conn_id=" << loghex(conn_id); if (p_tcb && p_reg) { if (!p_tcb || !p_reg) return false; bd_addr = p_tcb->peer_bda; *p_gatt_if = gatt_if; *p_transport = p_tcb->transport; status = true; } return status; return true; } /******************************************************************************* Loading system/stack/gatt/gatt_int.h +1 −1 Original line number Diff line number Diff line Loading @@ -461,7 +461,7 @@ extern bool gatt_find_the_connected_bda(uint8_t start_idx, RawAddress& bda, tBT_TRANSPORT* p_transport); extern void gatt_set_srv_chg(void); extern void gatt_delete_dev_from_srv_chg_clt_list(const RawAddress& bd_addr); extern tGATT_VALUE* gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind); extern void gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind); extern void gatt_free_srvc_db_buffer_app_id(const bluetooth::Uuid& app_id); extern bool gatt_cl_send_next_cmd_inq(tGATT_TCB& tcb); Loading system/stack/gatt/gatt_utils.cc +3 −15 Original line number Diff line number Diff line Loading @@ -155,25 +155,13 @@ void gatt_set_srv_chg(void) { } } /******************************************************************************* * * Function gatt_add_pending_ind * * Description Add a pending indication * * Returns Pointer to the current pending indication buffer, NULL no buffer * available * ******************************************************************************/ tGATT_VALUE* gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind) { tGATT_VALUE* p_buf = (tGATT_VALUE*)osi_malloc(sizeof(tGATT_VALUE)); /** Add a pending indication */ void gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind) { VLOG(1) << __func__ << "enqueue a pending indication"; tGATT_VALUE* p_buf = (tGATT_VALUE*)osi_malloc(sizeof(tGATT_VALUE)); memcpy(p_buf, p_ind, sizeof(tGATT_VALUE)); fixed_queue_enqueue(p_tcb->pending_ind_q, p_buf); return p_buf; } /******************************************************************************* Loading Loading
system/stack/gatt/gatt_api.cc +50 −71 Original line number Diff line number Diff line Loading @@ -407,11 +407,7 @@ void GATTS_StopService(uint16_t service_handle) { ******************************************************************************/ tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle, uint16_t val_len, uint8_t* p_val) { tGATT_STATUS cmd_status = GATT_NO_RESOURCES; tGATT_VALUE indication; BT_HDR* p_msg; tGATT_VALUE* p_buf; tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); tGATT_REG* p_reg = gatt_get_regcb(gatt_if); Loading @@ -425,6 +421,7 @@ tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle, if (!GATT_HANDLE_IS_VALID(attr_handle)) return GATT_ILLEGAL_PARAMETER; tGATT_VALUE indication; indication.conn_id = conn_id; indication.handle = attr_handle; indication.len = val_len; Loading @@ -433,25 +430,21 @@ tGATT_STATUS GATTS_HandleValueIndication(uint16_t conn_id, uint16_t attr_handle, if (GATT_HANDLE_IS_VALID(p_tcb->indicate_handle)) { VLOG(1) << "Add a pending indication"; p_buf = gatt_add_pending_ind(p_tcb, &indication); if (p_buf != NULL) { cmd_status = GATT_SUCCESS; } else { cmd_status = GATT_NO_RESOURCES; gatt_add_pending_ind(p_tcb, &indication); return GATT_SUCCESS; } } else { tGATT_SR_MSG gatt_sr_msg; gatt_sr_msg.attr_value = indication; p_msg = attp_build_sr_msg(*p_tcb, GATT_HANDLE_VALUE_IND, &gatt_sr_msg); if (p_msg != NULL) { cmd_status = attp_send_sr_msg(*p_tcb, p_msg); BT_HDR* p_msg = attp_build_sr_msg(*p_tcb, GATT_HANDLE_VALUE_IND, &gatt_sr_msg); if (!p_msg) return GATT_NO_RESOURCES; tGATT_STATUS cmd_status = attp_send_sr_msg(*p_tcb, p_msg); if (cmd_status == GATT_SUCCESS || cmd_status == GATT_CONGESTED) { p_tcb->indicate_handle = indication.handle; gatt_start_conf_timer(p_tcb); } } } return cmd_status; } Loading Loading @@ -909,10 +902,9 @@ tGATT_STATUS GATTC_SendHandleValueConfirm(uint16_t conn_id, uint16_t handle) { ******************************************************************************/ void GATT_SetIdleTimeout(const RawAddress& bd_addr, uint16_t idle_tout, tBT_TRANSPORT transport) { tGATT_TCB* p_tcb; bool status = false; p_tcb = gatt_find_tcb_by_addr(bd_addr, transport); tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bd_addr, transport); if (p_tcb != NULL) { if (p_tcb->att_lcid == L2CAP_ATT_CID) { status = L2CA_SetFixedChannelTout(bd_addr, L2CAP_ATT_CID, idle_tout); Loading Loading @@ -1021,14 +1013,14 @@ void GATT_Deregister(tGATT_IF gatt_if) { tGATT_TCB* p_tcb; int i, j; for (i = 0, p_tcb = gatt_cb.tcb; i < GATT_MAX_PHY_CHANNEL; i++, p_tcb++) { if (p_tcb->in_use) { if (!p_tcb->in_use) continue; if (gatt_get_ch_state(p_tcb) != GATT_CH_CLOSE) { gatt_update_app_use_link_flag(gatt_if, p_tcb, false, true); } tGATT_CLCB* p_clcb; for (j = 0, p_clcb = &gatt_cb.clcb[j]; j < GATT_CL_MAX_LCB; j++, p_clcb++) { for (j = 0, p_clcb = &gatt_cb.clcb[j]; j < GATT_CL_MAX_LCB; j++, p_clcb++) { if (p_clcb->in_use && (p_clcb->p_reg->gatt_if == gatt_if) && (p_clcb->p_tcb->tcb_idx == p_tcb->tcb_idx)) { alarm_cancel(p_clcb->gatt_rsp_timer_ent); Loading @@ -1037,7 +1029,6 @@ void GATT_Deregister(tGATT_IF gatt_if) { } } } } gatt_deregister_bgdev_list(gatt_if); Loading Loading @@ -1107,30 +1098,25 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct, bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, bool is_direct, tBT_TRANSPORT transport, bool opportunistic, uint8_t initiating_phys) { tGATT_REG* p_reg; bool status = false; LOG(INFO) << __func__ << "gatt_if=" << +gatt_if << " " << bd_addr; /* Make sure app is registered */ p_reg = gatt_get_regcb(gatt_if); if (p_reg == NULL) { tGATT_REG* p_reg = gatt_get_regcb(gatt_if); if (!p_reg) { LOG(ERROR) << "gatt_if = " << +gatt_if << " is not registered"; return (false); } if (is_direct) status = gatt_act_connect(p_reg, bd_addr, transport, opportunistic, return gatt_act_connect(p_reg, bd_addr, transport, opportunistic, initiating_phys); else { if (transport == BT_TRANSPORT_LE) status = gatt_auto_connect_dev_add(p_reg, bd_addr); else { // is not direct if (transport != BT_TRANSPORT_LE) { LOG(ERROR) << "Unsupported transport for background connection"; return false; } } return status; return gatt_auto_connect_dev_add(p_reg, bd_addr); } /******************************************************************************* Loading Loading @@ -1212,20 +1198,15 @@ bool GATT_CancelConnect(tGATT_IF gatt_if, const RawAddress& bd_addr, * ******************************************************************************/ tGATT_STATUS GATT_Disconnect(uint16_t conn_id) { tGATT_STATUS ret = GATT_ILLEGAL_PARAMETER; tGATT_TCB* p_tcb = NULL; tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); LOG(INFO) << __func__ << " conn_id=" << loghex(conn_id); p_tcb = gatt_get_tcb_by_idx(tcb_idx); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx); if (!p_tcb) return GATT_ILLEGAL_PARAMETER; if (p_tcb) { tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id); gatt_update_app_use_link_flag(gatt_if, p_tcb, false, true); ret = GATT_SUCCESS; } return ret; return GATT_SUCCESS; } /******************************************************************************* Loading @@ -1248,17 +1229,15 @@ bool GATT_GetConnectionInfor(uint16_t conn_id, tGATT_IF* p_gatt_if, tGATT_REG* p_reg = gatt_get_regcb(gatt_if); uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id); tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx); bool status = false; VLOG(1) << __func__ << " conn_id=" << loghex(conn_id); if (p_tcb && p_reg) { if (!p_tcb || !p_reg) return false; bd_addr = p_tcb->peer_bda; *p_gatt_if = gatt_if; *p_transport = p_tcb->transport; status = true; } return status; return true; } /******************************************************************************* Loading
system/stack/gatt/gatt_int.h +1 −1 Original line number Diff line number Diff line Loading @@ -461,7 +461,7 @@ extern bool gatt_find_the_connected_bda(uint8_t start_idx, RawAddress& bda, tBT_TRANSPORT* p_transport); extern void gatt_set_srv_chg(void); extern void gatt_delete_dev_from_srv_chg_clt_list(const RawAddress& bd_addr); extern tGATT_VALUE* gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind); extern void gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind); extern void gatt_free_srvc_db_buffer_app_id(const bluetooth::Uuid& app_id); extern bool gatt_cl_send_next_cmd_inq(tGATT_TCB& tcb); Loading
system/stack/gatt/gatt_utils.cc +3 −15 Original line number Diff line number Diff line Loading @@ -155,25 +155,13 @@ void gatt_set_srv_chg(void) { } } /******************************************************************************* * * Function gatt_add_pending_ind * * Description Add a pending indication * * Returns Pointer to the current pending indication buffer, NULL no buffer * available * ******************************************************************************/ tGATT_VALUE* gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind) { tGATT_VALUE* p_buf = (tGATT_VALUE*)osi_malloc(sizeof(tGATT_VALUE)); /** Add a pending indication */ void gatt_add_pending_ind(tGATT_TCB* p_tcb, tGATT_VALUE* p_ind) { VLOG(1) << __func__ << "enqueue a pending indication"; tGATT_VALUE* p_buf = (tGATT_VALUE*)osi_malloc(sizeof(tGATT_VALUE)); memcpy(p_buf, p_ind, sizeof(tGATT_VALUE)); fixed_queue_enqueue(p_tcb->pending_ind_q, p_buf); return p_buf; } /******************************************************************************* Loading