Lines Matching refs:p_clcb
314 tBTA_GATTC_CLCB *p_clcb = NULL;
321 if ((p_clcb = bta_gattc_find_alloc_clcb(p_msg->api_conn.client_if,
324 bta_gattc_sm_execute(p_clcb, event, p_msg);
359 tBTA_GATTC_CLCB *p_clcb = NULL;
365 if ((p_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_cancel_conn.client_if,
368 bta_gattc_sm_execute(p_clcb, event, p_msg);
398 void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
403 if ( p_clcb && p_clcb->p_rcb && p_clcb->p_rcb->p_cback )
404 (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CANCEL_OPEN_EVT, &cb_data);
416 void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
420 bta_gattc_send_open_cback(p_clcb->p_rcb,
422 p_clcb->bda,
423 p_clcb->bta_conn_id);
434 void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
436 bta_gattc_open_error(p_clcb, p_data);
438 bta_gattc_clcb_dealloc(p_clcb);
450 void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
455 if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, TRUE))
459 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data);
464 if (GATT_GetConnIdIfConnected(p_clcb->p_rcb->client_if,
466 &p_clcb->bta_conn_id))
468 gattc_data.hdr.layer_specific = p_clcb->bta_conn_id;
470 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, &gattc_data);
488 tBTA_GATTC_CLCB *p_clcb;
508 if ((p_clcb = bta_gattc_clcb_alloc(p_data->client_if, p_data->remote_bda)) != NULL)
510 gattc_data.hdr.layer_specific = p_clcb->bta_conn_id = conn_id;
513 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, &gattc_data);
570 void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
574 if ( p_clcb->p_rcb->p_cback )
577 (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CANCEL_OPEN_EVT, &cb_data);
580 bta_gattc_clcb_dealloc(p_clcb);
591 void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
595 if (GATT_CancelConnect(p_clcb->p_rcb->client_if, p_data->api_cancel_conn.remote_bda, TRUE))
597 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CANCEL_OPEN_OK_EVT, p_data);
601 if ( p_clcb->p_rcb->p_cback )
604 (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CANCEL_OPEN_EVT, &cb_data);
617 void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
620 APPL_TRACE_DEBUG1("bta_gattc_conn server cache state=%d",p_clcb->p_srcb->state);
626 p_clcb->p_srcb->connected = TRUE;
627 p_clcb->bta_conn_id = p_data->hdr.layer_specific;
628 GATT_GetConnectionInfor(p_data->hdr.layer_specific, &gatt_if, p_clcb->bda);
631 if (p_clcb->p_srcb->p_srvc_cache == NULL ||
632 p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE)
634 if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE)
636 p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD;
637 bta_gattc_sm_execute(p_clcb, BTA_GATTC_START_CACHE_EVT, p_data);
640 p_clcb->state = BTA_GATTC_DISCOVER_ST;
646 if (p_clcb->p_srcb->srvc_hdl_chg)
648 p_clcb->p_srcb->srvc_hdl_chg = FALSE;
650 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
654 if (p_clcb->p_rcb)
656 bta_gattc_send_open_cback(p_clcb->p_rcb,
658 p_clcb->bda,
659 p_clcb->bta_conn_id);
672 void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
676 if ( p_clcb->p_rcb->p_cback )
679 cb_data.close.client_if = p_clcb->p_rcb->client_if;
681 bdcpy(cb_data.close.remote_bda, p_clcb->bda);
686 (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CLOSE_EVT, &cb_data);
698 void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
700 tBTA_GATTC_CBACK *p_cback = p_clcb->p_rcb->p_cback;
701 tBTA_GATTC_RCB *p_clreg = p_clcb->p_rcb;
704 APPL_TRACE_DEBUG1("bta_gattc_close conn_id=%d",p_clcb->bta_conn_id);
707 p_clcb->status = GATT_Disconnect(p_clcb->bta_conn_id);
709 cb_data.close.client_if = p_clcb->p_rcb->client_if;
710 cb_data.close.conn_id = p_clcb->bta_conn_id;
711 cb_data.close.status = p_clcb->status;
712 cb_data.close.reason = p_clcb->reason;
713 bdcpy(cb_data.close.remote_bda, p_clcb->bda);
715 bta_gattc_clcb_dealloc(p_clcb);
756 void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
758 APPL_TRACE_DEBUG1("Discovery cancel conn_id=%d",p_clcb->bta_conn_id);
760 bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_ERROR);
761 bta_gattc_sm_execute(p_clcb, BTA_GATTC_API_CLOSE_EVT, p_data);
801 void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
803 p_clcb->status = BTA_GATT_CANCEL;
804 p_clcb->auto_update = BTA_GATTC_DISC_WAITING;
815 void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
818 APPL_TRACE_DEBUG2("bta_gattc_start_discover conn_id=%d p_clcb->p_srcb->state = %d ",
819 p_clcb->bta_conn_id, p_clcb->p_srcb->state);
821 if (((p_clcb->p_q_cmd == NULL || p_clcb->auto_update == BTA_GATTC_REQ_WAITING) &&
822 p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) ||
823 p_clcb->p_srcb->state == BTA_GATTC_SERV_DISC)
826 p_clcb->auto_update = BTA_GATTC_NO_SCHEDULE;
828 if (p_clcb->p_srcb != NULL)
831 p_clcb->p_srcb->srvc_hdl_chg = FALSE;
832 p_clcb->p_srcb->update_count = 0;
833 p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC_ACT;
836 bta_gattc_set_discover_st(p_clcb->p_srcb);
838 if ((p_clcb->status = bta_gattc_init_cache(p_clcb->p_srcb)) == BTA_GATT_OK)
840 p_clcb->status = bta_gattc_discover_pri_service(p_clcb->bta_conn_id, p_clcb->p_srcb, GATT_DISC_SRVC_ALL);
842 if (p_clcb->status != BTA_GATT_OK)
845 bta_gattc_reset_discover_st(p_clcb->p_srcb, p_clcb->status);
856 p_clcb->auto_update = BTA_GATTC_DISC_WAITING;
858 if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE)
859 p_clcb->state = BTA_GATTC_CONN_ST; /* set clcb state */
872 void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
874 tBTA_GATTC_DATA *p_q_cmd = p_clcb->p_q_cmd;
875 APPL_TRACE_DEBUG1("bta_gattc_disc_cmpl conn_id=%d",p_clcb->bta_conn_id);
878 L2CA_EnableUpdateBleConnParams(p_clcb->p_srcb->server_bda, TRUE);
880 p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
882 if (p_clcb->status != GATT_SUCCESS)
885 if(p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache)
887 while (p_clcb->p_srcb->cache_buffer.p_first)
889 GKI_freebuf (GKI_dequeue (&p_clcb->p_srcb->cache_buffer));
891 p_clcb->p_srcb->p_srvc_cache = NULL;
895 bta_gattc_co_cache_reset(p_clcb->p_srcb->server_bda);
898 utl_freebuf((void **)&p_clcb->p_srcb->p_srvc_list);
900 if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING)
903 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
908 p_clcb->p_q_cmd = NULL;
910 bta_gattc_sm_execute(p_clcb, p_q_cmd->hdr.event, p_q_cmd);
925 void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
934 if (bta_gattc_enqueue(p_clcb, p_data))
936 if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
948 op_cmpl.status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param);
957 bta_gattc_sm_execute(p_clcb, BTA_GATTC_OP_CMPL_EVT, (tBTA_GATTC_DATA *)&op_cmpl);
969 void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
978 if (bta_gattc_enqueue(p_clcb, p_data))
991 handle = bta_gattc_id2handle(p_clcb->p_srcb,
998 handle = bta_gattc_id2handle(p_clcb->p_srcb,
1019 status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_MULTIPLE, &read_param);
1031 bta_gattc_sm_execute(p_clcb, BTA_GATTC_OP_CMPL_EVT, (tBTA_GATTC_DATA *)&op_cmpl);
1044 void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1051 if (bta_gattc_enqueue(p_clcb, p_data))
1053 if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
1070 status = GATTC_Write(p_clcb->bta_conn_id, p_data->api_write.write_type, &attr);
1082 bta_gattc_sm_execute(p_clcb, BTA_GATTC_OP_CMPL_EVT, (tBTA_GATTC_DATA *)&op_cmpl);
1094 void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1099 if (bta_gattc_enqueue(p_clcb, p_data))
1101 status = GATTC_ExecuteWrite(p_clcb->bta_conn_id, p_data->api_exec.is_execute);
1111 bta_gattc_sm_execute(p_clcb, BTA_GATTC_OP_CMPL_EVT, (tBTA_GATTC_DATA *)&op_cmpl);
1124 void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1129 if ((handle = bta_gattc_id2handle(p_clcb->p_srcb,
1154 void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
1167 if (bta_gattc_handle2id(p_clcb->p_srcb,
1178 cb_data.read.status = bta_gattc_pack_read_cb_data(p_clcb->p_srcb,
1187 cb_data.read.srvc_id = p_clcb->p_q_cmd->api_read.srvc_id;
1188 cb_data.read.char_id = p_clcb->p_q_cmd->api_read.char_id;
1189 cb_data.read.descr_type = p_clcb->p_q_cmd->api_read.descr_type;
1192 event = (p_clcb->p_q_cmd->api_read.descr_type.len == 0) ? BTA_GATTC_READ_CHAR_EVT: BTA_GATTC_READ_DESCR_EVT;
1193 cb_data.read.conn_id = p_clcb->bta_conn_id;
1195 utl_freebuf((void **)&p_clcb->p_q_cmd);
1197 ( *p_clcb->p_rcb->p_cback)(event, (tBTA_GATTC *)&cb_data);
1209 void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
1218 bta_gattc_handle2id(p_clcb->p_srcb, p_data->p_cmpl->handle,
1224 cb_data.write.srvc_id = p_clcb->p_q_cmd->api_write.srvc_id;
1225 cb_data.write.char_id = p_clcb->p_q_cmd->api_write.char_id;
1226 cb_data.write.descr_type = p_clcb->p_q_cmd->api_write.descr_type;
1229 if (p_clcb->p_q_cmd->api_write.hdr.event == BTA_GATTC_API_WRITE_EVT &&
1230 p_clcb->p_q_cmd->api_write.write_type == BTA_GATTC_WRITE_PREPARE)
1234 else if (p_clcb->p_q_cmd->api_write.descr_type.len == 0)
1241 utl_freebuf((void **)&p_clcb->p_q_cmd);
1242 cb_data.write.conn_id = p_clcb->bta_conn_id;
1244 ( *p_clcb->p_rcb->p_cback)(event, (tBTA_GATTC *)&cb_data);
1256 void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
1260 utl_freebuf((void **)&p_clcb->p_q_cmd);
1262 p_clcb->status = BTA_GATT_OK;
1265 cb_data.exec_cmpl.conn_id = p_clcb->bta_conn_id;
1268 ( *p_clcb->p_rcb->p_cback)(BTA_GATTC_EXEC_EVT, &cb_data);
1280 void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1293 if (p_clcb->p_q_cmd == NULL)
1298 if (p_clcb->p_q_cmd->hdr.event != bta_gattc_opcode_to_int_evt[op - GATTC_OPTYPE_READ])
1300 mapped_op = p_clcb->p_q_cmd->hdr.event - BTA_GATTC_API_READ_EVT + GATTC_OPTYPE_READ;
1305 bta_gattc_op_code_name[mapped_op] , p_clcb->p_q_cmd->hdr.event,
1309 mapped_op , p_clcb->p_q_cmd->hdr.event, op);
1315 if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING)
1317 p_clcb->auto_update = BTA_GATTC_REQ_WAITING;
1318 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
1321 bta_gattc_read_cmpl(p_clcb, &p_data->op_cmpl);
1324 bta_gattc_write_cmpl(p_clcb, &p_data->op_cmpl);
1327 bta_gattc_exec_cmpl(p_clcb, &p_data->op_cmpl);
1344 void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1360 void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1364 APPL_TRACE_DEBUG1("bta_gattc_search conn_id=%d",p_clcb->bta_conn_id);
1365 if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache)
1369 bta_gattc_search_service(p_clcb, p_data->api_search.srvc_uuid);
1372 cb_data.search_cmpl.conn_id = p_clcb->bta_conn_id;
1375 ( *p_clcb->p_rcb->p_cback)(BTA_GATTC_SEARCH_CMPL_EVT, &cb_data);
1387 void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1389 bta_gattc_enqueue(p_clcb, p_data);
1400 void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1402 bta_gattc_set_discover_st(p_clcb->p_srcb);
1404 APPL_TRACE_DEBUG1("bta_gattc_cache_open conn_id=%d",p_clcb->bta_conn_id);
1405 bta_gattc_co_cache_open(p_clcb->p_srcb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
1406 p_clcb->bta_conn_id, FALSE);
1417 void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1420 p_clcb->bta_conn_id, p_clcb->p_srcb->state);
1421 if (p_clcb->p_srcb->state == BTA_GATTC_SERV_LOAD)
1425 p_clcb->p_srcb->attr_index = 0;
1426 bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
1428 p_clcb->p_srcb->attr_index,
1429 p_clcb->bta_conn_id);
1433 p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
1435 bta_gattc_start_discover(p_clcb, NULL);
1438 if (p_clcb->p_srcb->state == BTA_GATTC_SERV_SAVE)
1442 if (!bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id))
1449 p_clcb->p_srcb->attr_index = 0;
1450 bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, p_clcb->bta_conn_id);
1451 bta_gattc_reset_discover_st(p_clcb->p_srcb, p_clcb->status);
1465 void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1469 p_clcb->bta_conn_id, p_data->ci_load.status );
1470 bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
1476 bta_gattc_rebuild_cache(p_clcbp_clcb->p_srcb->attr_index);
1480 p_clcb->p_srcb->attr_index = 0;
1481 bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
1486 p_clcb->p_srcb->attr_index += p_data->ci_load.num_attr;
1488 bta_gattc_co_cache_load(p_clcb->p_srcb->server_bda,
1490 p_clcb->p_srcb->attr_index,
1491 p_clcb->bta_conn_id);
1496 p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
1497 p_clcb->p_srcb->attr_index = 0;
1499 bta_gattc_start_discover(p_clcb, NULL);
1511 void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1514 p_clcb->bta_conn_id );
1516 if (!bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id))
1518 p_clcb->p_srcb->attr_index = 0;
1519 bta_gattc_co_cache_close(p_clcb->p_srcb->server_bda, 0);
1520 bta_gattc_reset_discover_st(p_clcb->p_srcb, p_clcb->status);
1532 void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
1534 if (p_clcb->status == BTA_GATT_OK)
1536 APPL_TRACE_ERROR1("operation not supported at current state [%d]", p_clcb->state);
1553 tBTA_GATTC_CLCB *p_clcb = NULL;
1570 if ((p_clcb = bta_gattc_find_clcb_by_cif(gattc_if, bda)) == NULL)
1578 p_clcb = bta_gattc_clcb_alloc(gattc_if, bda);
1582 if (p_clcb != NULL)
1584 p_clcb->bta_conn_id = conn_id;
1603 p_clcb = bta_gattc_find_alloc_clcb(gattc_if, bda);
1604 p_clcb->bta_conn_id = conn_id;
1606 if ((p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id)) != NULL)
1612 p_clcb->reason = reason;
1636 tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0];
1645 for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++, p_clcb ++)
1647 if (p_clcb->in_use && p_clcb->p_srcb == p_srvc_cb)
1655 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
1684 tBTA_GATTC_CLCB *p_clcb,
1711 if (p_clcb == NULL || (p_clcb && p_clcb->p_q_cmd != NULL))
1719 p_clcb = &bta_gattc_cb.clcb[i];
1728 if (p_clcb != NULL)
1729 bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
1751 void bta_gattc_proc_other_indication(tBTA_GATTC_CLCB *p_clcb, UINT8 op,
1762 bdcpy(p_notify->bda, p_clcb->bda);
1764 p_notify->conn_id = p_clcb->bta_conn_id;
1766 if (p_clcb->p_rcb->p_cback)
1767 (*p_clcb->p_rcb->p_cback)(BTA_GATTC_NOTIF_EVT, (tBTA_GATTC *)p_notify);
1782 tBTA_GATTC_CLCB *p_clcb ;
1807 p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
1815 if (!bta_gattc_process_srvc_chg_ind(conn_id, p_clrcb, p_srcb, p_clcb, ¬ify, handle))
1821 if (p_clcb == NULL)
1823 if ((p_clcb = bta_gattc_clcb_alloc(gatt_if, remote_bda)) != NULL)
1825 p_clcb->bta_conn_id = conn_id;
1839 if (p_clcb != NULL)
1840 bta_gattc_proc_other_indication(p_clcb, op, p_data, ¬ify);
1867 tBTA_GATTC_CLCB *p_clcb ;
1881 else if ((p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id)) == NULL)
1919 tBTA_GATTC_CLCB *p_clcb = NULL;
1931 if ((p_clcb = bta_gattc_clcb_alloc(cif, remote_bda)) != NULL)
1933 gattc_data.hdr.layer_specific = p_clcb->bta_conn_id = conn_id;
1939 bta_gattc_sm_execute(p_clcb, BTA_GATTC_API_OPEN_EVT, &gattc_data);