Home | History | Annotate | Download | only in gatt

Lines Matching full:p_tcb

45 UINT32 gatt_sr_enqueue_cmd (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 handle)
47 tGATT_SR_CMD *p_cmd = &p_tcb->sr_cmd;
58 trans_id = ++p_tcb->trans_id;
62 p_cmd->trans_id = ++p_tcb->trans_id;
66 p_tcb->trans_id %= GATT_TRANS_ID_MAX;
83 BOOLEAN gatt_sr_cmd_empty (tGATT_TCB *p_tcb)
85 return(p_tcb->sr_cmd.op_code == 0);
97 void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb)
101 if (p_tcb->sr_cmd.p_rsp_msg)
103 GATT_TRACE_ERROR1("free p_tcb->sr_cmd.p_rsp_msg = %d", p_tcb->sr_cmd.p_rsp_msg);
105 GKI_freebuf (p_tcb->sr_cmd.p_rsp_msg);
108 while (p_tcb->sr_cmd.multi_rsp_q.p_first)
109 GKI_freebuf (GKI_dequeue (&p_tcb->sr_cmd.multi_rsp_q));
110 memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD));
260 tGATT_STATUS gatt_sr_process_app_rsp (tGATT_TCB *p_tcb, tGATT_IF gatt_if,
268 gatt_sr_update_cback_cnt(p_tcb, gatt_if, FALSE, FALSE);
273 if (!process_read_multi_rsp (&p_tcb->sr_cmd, status, p_msg, p_tcb->payload_size))
279 gatt_sr_update_prep_cnt(p_tcb, gatt_if, TRUE, FALSE);
282 gatt_sr_reset_cback_cnt(p_tcb);
284 p_tcb->sr_cmd.status = status;
286 if (gatt_sr_is_cback_cnt_zero(p_tcb)
289 if (p_tcb->sr_cmd.p_rsp_msg == NULL)
291 p_tcb->sr_cmd.p_rsp_msg = attp_build_sr_msg (p_tcb, (UINT8)(op_code + 1), (tGATT_SR_MSG *)p_msg);
299 if (gatt_sr_is_cback_cnt_zero(p_tcb))
301 if ( (p_tcb->sr_cmd.status == GATT_SUCCESS) && (p_tcb->sr_cmd.p_rsp_msg) )
303 ret_code = attp_send_sr_msg (p_tcb, p_tcb->sr_cmd.p_rsp_msg);
304 p_tcb->sr_cmd.p_rsp_msg = NULL;
308 ret_code = gatt_send_error_rsp (p_tcb, status, op_code, p_tcb->sr_cmd.handle, FALSE);
311 gatt_dequeue_sr_cmd(p_tcb);
329 void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, UINT8 *p_data)
343 gatt_send_error_rsp (p_tcb, gatt_cb.err_status, gatt_cb.req_op_code, gatt_cb.handle, FALSE);
356 if (!gatt_sr_is_prep_cnt_zero(p_tcb))
358 trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, 0);
359 gatt_sr_copy_prep_cnt_to_cback_cnt(p_tcb);
363 if (p_tcb->prep_cnt[i])
366 conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
371 p_tcb->prep_cnt[i]= 0;
379 if ((p_buf = attp_build_sr_msg(p_tcb, GATT_RSP_EXEC_WRITE, NULL)) != NULL)
381 attp_send_sr_msg (p_tcb, p_buf);
397 void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, UINT8 *p_data)
407 p_tcb->sr_cmd.multi_req.num_handles = 0;
409 gatt_sr_get_sec_info(p_tcb->peer_bda,
410 (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
421 gatt_send_error_rsp (p_tcb, gatt_cb.err_status, gatt_cb.req_op_code, handle, FALSE);
427 while (ll >= 2 && p_tcb->sr_cmd.multi_req.num_handles < GATT_MAX_READ_MULTI_HANDLES)
433 p_tcb->sr_cmd.multi_req.handles[p_tcb->sr_cmd.multi_req.num_handles++] = handle;
461 if (p_tcb->sr_cmd.multi_req.num_handles == 0)
466 if ((trans_id = gatt_sr_enqueue_cmd (p_tcb, op_code, p_tcb->sr_cmd.multi_req.handles[0])) != 0)
468 gatt_sr_reset_cback_cnt(p_tcb); /* read multiple use multi_rsp_q's count*/
470 for (ll = 0; ll < p_tcb->sr_cmd.multi_req.num_handles; ll ++)
476 handle = p_tcb->sr_cmd.multi_req.handles[ll];
480 err = gatts_read_attr_value_by_handle(p_tcb,
494 gatt_sr_process_app_rsp(p_tcb, gatt_cb.sr_reg[i_rcb].gatt_if ,trans_id, op_code, GATT_SUCCESS, p_msg);
502 gatt_dequeue_sr_cmd(p_tcb);
513 gatt_send_error_rsp(p_tcb, err, op_code, handle, FALSE);
526 static tGATT_STATUS gatt_build_primary_service_rsp (BT_HDR *p_msg, tGATT_TCB *p_tcb,
569 if (p_msg->len + p_msg->offset <= p_tcb->payload_size &&
757 void gatts_process_primary_service_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, UINT8 *p_data)
763 UINT16 msg_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
787 reason = gatt_build_primary_service_rsp (p_msg, p_tcb, op_code, s_hdl, e_hdl, p_data, value);
810 gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
813 attp_send_sr_msg(p_tcb, p_msg);
827 static void gatts_process_find_info(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, UINT8 *p_data)
840 buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
855 buf_len = p_tcb->payload_size - 2;
885 gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
888 attp_send_sr_msg(p_tcb, p_msg);
902 static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
910 if (p_tcb->att_lcid != L2CAP_ATT_CID)
912 gatt_send_error_rsp (p_tcb, GATT_REQ_NOT_SUPPORTED, GATT_REQ_MTU, 0, FALSE);
917 gatt_send_error_rsp (p_tcb, GATT_INVALID_PDU, GATT_REQ_MTU, 0, FALSE);
924 p_tcb->payload_size = GATT_DEF_BLE_MTU_SIZE;
926 p_tcb->payload_size = GATT_MAX_MTU_SIZE;
928 p_tcb->payload_size = mtu;
930 if ((p_buf = attp_build_sr_msg(p_tcb, GATT_RSP_MTU, (tGATT_SR_MSG *) &p_tcb->payload_size)) != NULL)
932 attp_send_sr_msg (p_tcb, p_buf);
941 conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_cb.cl_rcb[i].gatt_if);
943 (tGATTS_DATA *)&p_tcb->payload_size);
966 void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, UINT8 *p_data)
970 UINT16 msg_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET),
987 gatt_send_error_rsp (p_tcb, gatt_cb.err_status, gatt_cb.req_op_code, s_hdl, FALSE);
1009 buf_len = p_tcb->payload_size - 2;
1023 gatt_sr_get_sec_info(p_tcb->peer_bda,
1024 (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
1028 ret = gatts_db_read_attr_value_by_type(p_tcb,
1065 gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
1068 attp_send_sr_msg(p_tcb, p_msg);
1082 void gatts_process_write_req (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 handle,
1118 gatt_sr_get_sec_info(p_tcb->peer_bda,
1119 (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
1134 if ((trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, handle)) != 0)
1137 conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_sreg->gatt_if);
1156 gatt_send_error_rsp (p_tcb, status, op_code, handle, FALSE);
1171 static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8 op_code,
1174 UINT16 buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
1195 buf_len = p_tcb->payload_size - 1;
1197 gatt_sr_get_sec_info(p_tcb->peer_bda,
1198 (BOOLEAN)(p_tcb->att_lcid == L2CAP_ATT_CID),
1202 reason = gatts_read_attr_value_by_handle(p_tcb,
1223 gatt_send_error_rsp (p_tcb, reason, op_code, handle, FALSE);
1226 attp_send_sr_msg(p_tcb, p_msg);
1240 void gatts_process_attribute_req (tGATT_TCB *p_tcb, UINT8 op_code,
1266 gatt_send_error_rsp (p_tcb, gatt_cb.err_status, gatt_cb.req_op_code, handle, FALSE);
1288 gatts_process_read_req(p_tcb, p_rcb, op_code, handle, len, p);
1295 gatts_process_write_req(p_tcb, i, handle, op_code, len, p);
1311 gatt_send_error_rsp (p_tcb, status, op_code, handle, FALSE);
1323 static void gatts_proc_srv_chg_ind_ack(tGATT_TCB *p_tcb )
1330 if ((p_buf = gatt_is_bda_in_the_srv_chg_clt_list(p_tcb->peer_bda)) != NULL)
1350 static void gatts_chk_pending_ind(tGATT_TCB *p_tcb )
1352 tGATT_VALUE *p_buf = (tGATT_VALUE *)GKI_getfirst(&p_tcb->pending_ind_q);
1361 GKI_freebuf(GKI_remove_from_queue (&p_tcb->pending_ind_q, p_buf));
1375 static BOOLEAN gatts_proc_ind_ack(tGATT_TCB *p_tcb, UINT16 ack_handle)
1383 gatts_proc_srv_chg_ind_ack(p_tcb);
1388 gatts_chk_pending_ind(p_tcb);
1401 void gatts_process_value_conf(tGATT_TCB *p_tcb, UINT8 op_code)
1403 UINT16 handle = p_tcb->indicate_handle;
1410 btu_stop_timer (&p_tcb->conf_timer_ent);
1413 p_tcb->indicate_handle = 0;
1414 continue_processing = gatts_proc_ind_ack(p_tcb, handle);
1422 trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, handle);
1423 conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_rcb->gatt_if);
1447 void gatt_server_handle_client_req (tGATT_TCB *p_tcb, UINT8 op_code,
1451 if (!gatt_sr_cmd_empty(p_tcb) && op_code != GATT_HANDLE_VALUE_CONF)
1456 if (len >= p_tcb->payload_size)
1458 GATT_TRACE_ERROR2("server receive invalid PDU size:%d pdu size:%d", len + 1, p_tcb->payload_size );
1464 gatt_send_error_rsp (p_tcb, GATT_INVALID_PDU, op_code, 0, FALSE);
1474 gatts_process_primary_service_req (p_tcb, op_code, len, p_data);
1478 gatts_process_find_info(p_tcb, op_code, len, p_data);
1483 gatts_process_read_by_type_req(p_tcb, op_code, len, p_data);
1493 gatts_process_attribute_req (p_tcb, op_code, len, p_data);
1497 gatts_process_value_conf (p_tcb, op_code);
1501 gatts_process_mtu_req (p_tcb, len, p_data);
1505 gatt_process_exec_write_req (p_tcb, op_code, len, p_data);
1509 gatt_process_read_multi_req (p_tcb, op_code, len, p_data);