Home | History | Annotate | Download | only in gatt

Lines Matching defs:p_tcb

58 static void gatt_send_conn_cback (tGATT_TCB *p_tcb);
149 BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport)
153 if (gatt_get_ch_state(p_tcb) != GATT_CH_OPEN)
154 gatt_set_ch_state(p_tcb, GATT_CH_CONN);
158 p_tcb->att_lcid = L2CAP_ATT_CID;
163 if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0)
176 ** Parameter p_tcb: pointer to the TCB to disconnect.
182 BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb)
188 if (p_tcb != NULL)
191 if ( (ch_state = gatt_get_ch_state(p_tcb)) != GATT_CH_CLOSING )
193 if (p_tcb->att_lcid == L2CAP_ATT_CID)
198 ret = L2CA_RemoveFixedChnl (L2CAP_ATT_CID, p_tcb->peer_bda);
202 gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
203 ret = L2CA_CancelBleConnectReq (p_tcb->peer_bda);
208 ret = L2CA_DisconnectReq(p_tcb->att_lcid);
229 void gatt_update_app_hold_link_status (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add)
234 if (p_tcb == NULL)
236 GATT_TRACE_ERROR("gatt_update_app_hold_link_status p_tcb=NULL");
243 if (p_tcb->app_hold_link[i] == gatt_if)
248 p_tcb->app_hold_link[i] = 0;
258 if (p_tcb->app_hold_link[i] == 0)
260 p_tcb->app_hold_link[i] = gatt_if;
281 void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link)
286 gatt_update_app_hold_link_status(gatt_if, p_tcb, is_add);
289 p_tcb &&
290 p_tcb->att_lcid == L2CAP_ATT_CID && /* only update link idle timer for fixed channel */
291 (BTM_GetHCIConnHandle(p_tcb->peer_bda, p_tcb->transport) != GATT_INVALID_ACL_HANDLE))
297 GATT_SetIdleTimeout(p_tcb->peer_bda, GATT_LINK_NO_IDLE_TIMEOUT, p_tcb->transport);
301 if (!gatt_num_apps_hold_link(p_tcb))
306 GATT_SetIdleTimeout(p_tcb->peer_bda, GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP, p_tcb->transport);
325 tGATT_TCB *p_tcb;
328 if ((p_tcb = gatt_find_tcb_by_addr(bd_addr, transport)) != NULL)
331 st = gatt_get_ch_state(p_tcb);
334 if(st == GATT_CH_OPEN && gatt_num_apps_hold_link(p_tcb) == 0 &&
337 if (!gatt_connect(bd_addr, p_tcb, transport))
348 if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, transport)) != NULL)
350 if (!gatt_connect(bd_addr, p_tcb, transport))
353 memset(p_tcb, 0, sizeof(tGATT_TCB));
367 gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, FALSE);
386 tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(bd_addr, transport);
411 if (p_tcb)
414 if ( gatt_get_ch_state(p_tcb) == GATT_CH_CONN)
417 gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
418 p_tcb->payload_size = GATT_DEF_BLE_MTU_SIZE;
420 gatt_send_conn_cback(p_tcb);
429 if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, BT_TRANSPORT_LE)) != NULL)
431 p_tcb->att_lcid = L2CAP_ATT_CID;
433 gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
435 p_tcb->payload_size = GATT_DEF_BLE_MTU_SIZE;
437 gatt_send_conn_cback (p_tcb);
466 static void gatt_channel_congestion(tGATT_TCB *p_tcb, BOOLEAN congested)
473 if (p_tcb != NULL && congested == FALSE)
475 gatt_cl_send_next_cmd_inq(p_tcb);
484 conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
503 tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(remote_bda, BT_TRANSPORT_LE);
506 if (p_tcb != NULL)
508 gatt_channel_congestion(p_tcb, congested);
529 tGATT_TCB *p_tcb;
532 if ((p_tcb = gatt_find_tcb_by_addr (bd_addr, BT_TRANSPORT_LE)) != NULL &&
533 gatt_get_ch_state(p_tcb) >= GATT_CH_OPEN)
535 gatt_data_process(p_tcb, p_buf);
541 if (p_tcb != NULL)
544 gatt_get_ch_state(p_tcb));
565 tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(bd_addr, BT_TRANSPORT_BR_EDR);
570 if (p_tcb == NULL)
573 if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, BT_TRANSPORT_BR_EDR)) == NULL)
579 p_tcb->att_lcid = lcid;
594 gatt_set_ch_state(p_tcb, GATT_CH_CFG);
617 tGATT_TCB *p_tcb;
621 if ((p_tcb = gatt_find_tcb_by_cid(lcid)) != NULL)
623 GATT_TRACE_DEBUG("gatt_l2c_connect_cfm_cback result: %d ch_state: %d, lcid:0x%x", result, gatt_get_ch_state(p_tcb), p_tcb->att_lcid);
626 if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN)
632 gatt_set_ch_state(p_tcb, GATT_CH_CFG);
643 gatt_cleanup_upon_disc(p_tcb->peer_bda, result, GATT_TRANSPORT_BR_EDR);
669 tGATT_TCB *p_tcb;
673 if ((p_tcb = gatt_find_tcb_by_cid(lcid)) != NULL)
676 if ( gatt_get_ch_state(p_tcb) == GATT_CH_CFG)
682 p_tcb->ch_flags |= GATT_L2C_CFG_CFM_DONE;
685 if (p_tcb->ch_flags & GATT_L2C_CFG_IND_DONE)
687 gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
689 if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL)
695 if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda))
696 gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
700 gatt_send_conn_cback(p_tcb);
725 tGATT_TCB *p_tcb;
728 if ((p_tcb = gatt_find_tcb_by_cid(lcid)) != NULL)
733 p_tcb->payload_size = p_cfg->mtu;
735 p_tcb->payload_size = L2CAP_DEFAULT_MTU;
743 if ((p_tcb->ch_flags & GATT_L2C_CFG_IND_DONE) == 0)
746 p_tcb->ch_flags |= GATT_L2C_CFG_IND_DONE;
749 if (p_tcb->ch_flags & GATT_L2C_CFG_CFM_DONE)
751 gatt_set_ch_state(p_tcb, GATT_CH_OPEN);
752 if ((p_srv_chg_clt = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL)
758 if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda))
759 gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
763 gatt_send_conn_cback(p_tcb);
781 tGATT_TCB *p_tcb;
785 if ((p_tcb = gatt_find_tcb_by_cid(lcid)) != NULL)
792 if (gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda) == NULL)
794 if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda))
795 gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
798 if ((reason = L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport)) == 0)
802 gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR);
818 tGATT_TCB *p_tcb;
823 if ((p_tcb = gatt_find_tcb_by_cid(lcid)) != NULL)
826 if (gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda) == NULL)
828 if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda))
829 gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
834 if ((reason = L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport)) == 0)
837 gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, GATT_TRANSPORT_BR_EDR);
853 tGATT_TCB *p_tcb;
856 if ((p_tcb = gatt_find_tcb_by_cid(lcid)) != NULL &&
857 gatt_get_ch_state(p_tcb) == GATT_CH_OPEN)
860 gatt_data_process(p_tcb, p_buf);
877 tGATT_TCB *p_tcb = gatt_find_tcb_by_cid(lcid);
879 if (p_tcb != NULL)
881 gatt_channel_congestion(p_tcb, congested);
895 static void gatt_send_conn_cback(tGATT_TCB *p_tcb)
902 p_bg_dev = gatt_find_bg_dev(p_tcb->peer_bda);
910 gatt_update_app_use_link_flag(p_reg->gatt_if, p_tcb, TRUE, TRUE);
914 conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
915 (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id,
916 TRUE, 0, p_tcb->transport);
922 if (gatt_num_apps_hold_link(p_tcb) && p_tcb->att_lcid == L2CAP_ATT_CID )
925 GATT_SetIdleTimeout(p_tcb->peer_bda, GATT_LINK_NO_IDLE_TIMEOUT, p_tcb->transport);
944 void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
963 gatt_verify_signature(p_tcb, p_buf);
969 gatt_server_handle_client_req (p_tcb, op_code, msg_len, p);
971 gatt_client_handle_server_rsp (p_tcb, op_code, msg_len, p);
1136 tGATT_TCB *p_tcb;
1147 p_tcb = &gatt_cb.tcb[found_idx];;
1148 srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
1172 void gatt_set_ch_state(tGATT_TCB *p_tcb, tGATT_CH_STATE ch_state)
1174 if (p_tcb)
1176 GATT_TRACE_DEBUG ("gatt_set_ch_state: old=%d new=%d", p_tcb->ch_state, ch_state);
1177 p_tcb->ch_state = ch_state;
1190 tGATT_CH_STATE gatt_get_ch_state(tGATT_TCB *p_tcb)
1193 if (p_tcb)
1195 GATT_TRACE_DEBUG ("gatt_get_ch_state: ch_state=%d", p_tcb->ch_state);
1196 ch_state = p_tcb->ch_state;