return status;
}
-/*******************************************************************************
-**
-** Function BTA_GATTC_GetNextCharDescr
-**
-** Description This function is called to find the next characteristic descriptor
-** of the characterisctic.
-**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_descr_id: start the descriptor search from the next record
-** after the one identified by p_start_descr_id.
-** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
-** the first available characteristic descriptor.
-** p_descr_result: output parameter which will store the GATT
-** characteristic descriptor ID.
-**
-** Returns returns status.
-**
-*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
- tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
- tBT_UUID *p_descr_uuid_cond,
- tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
-{
- tBTA_GATT_STATUS status;
-
- if (!p_start_descr_id || !p_descr_result)
- return BTA_GATT_ILLEGAL_PARAMETER;
-
- memset(p_descr_result, 0, sizeof(tBTA_GATTC_CHAR_DESCR_ID));
-
- if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
- &p_start_descr_id->char_id.srvc_id,
- &p_start_descr_id->char_id.char_id,
- p_descr_uuid_cond,
- &p_descr_result->char_id.char_id,
- (void *)&p_start_descr_id->descr_id))
- == BTA_GATT_OK)
- {
- memcpy(&p_descr_result->descr_id, &p_descr_result->char_id.char_id, sizeof(tBTA_GATT_ID));
- memcpy(&p_descr_result->char_id, p_start_descr_id, sizeof(tBTA_GATTC_CHAR_ID));
- }
-
- return status;
-}
-
/*******************************************************************************
**
return status;
}
-/*******************************************************************************
-**
-** Function BTA_GATTC_GetNextIncludedService
-**
-** Description This function is called to find the next included service of the
-** service on the given server.
-**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_id: start the search from the next record
-** after the one identified by p_start_id.
-** p_uuid_cond: Included service UUID, if NULL find the first available
-** included service.
-** p_result: output parameter which will store the GATT ID
-** of the included service found.
-**
-** Returns returns status.
-**
-*******************************************************************************/
-tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
- tBTA_GATTC_INCL_SVC_ID *p_start_id,
- tBT_UUID *p_uuid_cond,
- tBTA_GATTC_INCL_SVC_ID *p_result)
-{
- tBTA_GATT_STATUS status;
-
- if (!p_start_id || !p_result)
- return BTA_GATT_ILLEGAL_PARAMETER;
-
- if ((status = bta_gattc_query_cache(conn_id,
- BTA_GATTC_ATTR_TYPE_INCL_SRVC,
- &p_start_id->srvc_id,
- &p_start_id->incl_svc_id.id,
- p_uuid_cond,
- &p_result->incl_svc_id.id,
- (void *)&p_result->incl_svc_id.is_primary))
- == BTA_GATT_OK)
- {
- memcpy(&p_result->srvc_id, &p_start_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
- }
-
- return status;
-}
/*******************************************************************************
**
/*******************************************************************************
**
-** Function BTA_GATTC_GetNextCharDescr
-**
-** Description This function is called to find the next charatceristic of the
-** service on the given server.
-**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_descr_id: start the characteristic search from the next record
-** after the one identified by p_start_descr_id.
-** p_descr_uuid_cond: Characteristic descriptor UUID, if NULL find
-** the first available characteristic descriptor.
-** p_descr_result: output parameter which will store the GATT
-** characteristic descriptor ID.
-**
-** Returns returns status.
-**
-*******************************************************************************/
-extern tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
- tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
- tBT_UUID *p_descr_uuid_cond,
- tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
-
-
-/*******************************************************************************
-**
** Function BTA_GATTC_GetFirstIncludedService
**
** Description This function is called to find the first included service of the
/*******************************************************************************
**
-** Function BTA_GATTC_GetNextIncludedService
-**
-** Description This function is called to find the next included service of the
-** service on the given server.
-**
-** Parameters conn_id: connection ID which identify the server.
-** p_start_id: start the search from the next record
-** after the one identified by p_start_id.
-** p_uuid_cond: Included service UUID, if NULL find the first available
-** included service.
-** p_result: output parameter which will store the GATT ID
-** of the included service found.
-**
-** Returns returns status.
-**
-*******************************************************************************/
-extern tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
- tBTA_GATTC_INCL_SVC_ID *p_start_id,
- tBT_UUID *p_uuid_cond,
- tBTA_GATTC_INCL_SVC_ID *p_result);
-
-/*******************************************************************************
-**
** Function BTA_GATTC_GetGattDb
**
** Description This function is called to get gatt db.
BTIF_GATTC_OPEN,
BTIF_GATTC_CLOSE,
BTIF_GATTC_SEARCH_SERVICE,
- BTIF_GATTC_GET_FIRST_CHAR,
- BTIF_GATTC_GET_NEXT_CHAR,
- BTIF_GATTC_GET_FIRST_CHAR_DESCR,
- BTIF_GATTC_GET_NEXT_CHAR_DESCR,
- BTIF_GATTC_GET_FIRST_INCL_SERVICE,
- BTIF_GATTC_GET_NEXT_INCL_SERVICE,
BTIF_GATTC_READ_CHAR,
BTIF_GATTC_READ_CHAR_DESCR,
BTIF_GATTC_WRITE_CHAR,
break;
}
- case BTA_GATTC_SEARCH_RES_EVT:
- {
- btgatt_srvc_id_t data;
- bta_to_btif_srvc_id(&data, &(p_data->srvc_res.service_uuid));
- HAL_CBACK(bt_gatt_callbacks, client->search_result_cb
- , p_data->srvc_res.conn_id, &data);
- break;
- }
-
case BTA_GATTC_READ_DESCR_EVT:
{
btgatt_read_params_t data;
{
tBTA_GATT_STATUS status;
tBT_UUID uuid;
- tBTA_GATT_SRVC_ID srvc_id;
- tGATT_CHAR_PROP out_char_prop;
tBTA_GATTC_CHAR_ID in_char_id;
- tBTA_GATTC_CHAR_ID out_char_id;
tBTA_GATTC_CHAR_DESCR_ID in_char_descr_id;
- tBTA_GATTC_CHAR_DESCR_ID out_char_descr_id;
- tBTA_GATTC_INCL_SVC_ID in_incl_svc_id;
- tBTA_GATTC_INCL_SVC_ID out_incl_svc_id;
tBTA_GATT_UNFMT descr_val;
btif_gattc_cb_t* p_cb = (btif_gattc_cb_t*) p_param;
break;
}
- case BTIF_GATTC_GET_FIRST_CHAR:
- {
- btgatt_gatt_id_t char_id;
- btif_to_bta_srvc_id(&srvc_id, &p_cb->srvc_id);
- status = BTA_GATTC_GetFirstChar(p_cb->conn_id, &srvc_id, NULL,
- &out_char_id, &out_char_prop);
-
- if (status == 0)
- bta_to_btif_gatt_id(&char_id, &out_char_id.char_id);
-
- HAL_CBACK(bt_gatt_callbacks, client->get_characteristic_cb,
- p_cb->conn_id, status, &p_cb->srvc_id,
- &char_id, out_char_prop);
- break;
- }
-
- case BTIF_GATTC_GET_NEXT_CHAR:
- {
- btgatt_gatt_id_t char_id;
- btif_to_bta_srvc_id(&in_char_id.srvc_id, &p_cb->srvc_id);
- btif_to_bta_gatt_id(&in_char_id.char_id, &p_cb->char_id);
-
- status = BTA_GATTC_GetNextChar(p_cb->conn_id, &in_char_id, NULL,
- &out_char_id, &out_char_prop);
-
- if (status == 0)
- bta_to_btif_gatt_id(&char_id, &out_char_id.char_id);
-
- HAL_CBACK(bt_gatt_callbacks, client->get_characteristic_cb,
- p_cb->conn_id, status, &p_cb->srvc_id,
- &char_id, out_char_prop);
- break;
- }
-
- case BTIF_GATTC_GET_FIRST_CHAR_DESCR:
- {
- btgatt_gatt_id_t descr_id;
- btif_to_bta_srvc_id(&in_char_id.srvc_id, &p_cb->srvc_id);
- btif_to_bta_gatt_id(&in_char_id.char_id, &p_cb->char_id);
-
- status = BTA_GATTC_GetFirstCharDescr(p_cb->conn_id, &in_char_id, NULL,
- &out_char_descr_id);
-
- if (status == 0)
- bta_to_btif_gatt_id(&descr_id, &out_char_descr_id.descr_id);
-
- HAL_CBACK(bt_gatt_callbacks, client->get_descriptor_cb,
- p_cb->conn_id, status, &p_cb->srvc_id,
- &p_cb->char_id, &descr_id);
- break;
- }
-
- case BTIF_GATTC_GET_NEXT_CHAR_DESCR:
- {
- btgatt_gatt_id_t descr_id;
- btif_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &p_cb->srvc_id);
- btif_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &p_cb->char_id);
- btif_to_bta_gatt_id(&in_char_descr_id.descr_id, &p_cb->descr_id);
-
- status = BTA_GATTC_GetNextCharDescr(p_cb->conn_id, &in_char_descr_id
- , NULL, &out_char_descr_id);
-
- if (status == 0)
- bta_to_btif_gatt_id(&descr_id, &out_char_descr_id.descr_id);
-
- HAL_CBACK(bt_gatt_callbacks, client->get_descriptor_cb,
- p_cb->conn_id, status, &p_cb->srvc_id,
- &p_cb->char_id, &descr_id);
- break;
- }
-
- case BTIF_GATTC_GET_FIRST_INCL_SERVICE:
- {
- btgatt_srvc_id_t incl_srvc_id;
- btif_to_bta_srvc_id(&srvc_id, &p_cb->srvc_id);
-
- status = BTA_GATTC_GetFirstIncludedService(p_cb->conn_id,
- &srvc_id, NULL, &out_incl_svc_id);
-
- bta_to_btif_srvc_id(&incl_srvc_id, &out_incl_svc_id.incl_svc_id);
-
- HAL_CBACK(bt_gatt_callbacks, client->get_included_service_cb,
- p_cb->conn_id, status, &p_cb->srvc_id,
- &incl_srvc_id);
- break;
- }
-
- case BTIF_GATTC_GET_NEXT_INCL_SERVICE:
- {
- btgatt_srvc_id_t incl_srvc_id;
- btif_to_bta_srvc_id(&in_incl_svc_id.srvc_id, &p_cb->srvc_id);
- btif_to_bta_srvc_id(&in_incl_svc_id.incl_svc_id, &p_cb->incl_srvc_id);
-
- status = BTA_GATTC_GetNextIncludedService(p_cb->conn_id,
- &in_incl_svc_id, NULL, &out_incl_svc_id);
-
- bta_to_btif_srvc_id(&incl_srvc_id, &out_incl_svc_id.incl_svc_id);
-
- HAL_CBACK(bt_gatt_callbacks, client->get_included_service_cb,
- p_cb->conn_id, status, &p_cb->srvc_id,
- &incl_srvc_id);
- break;
- }
-
case BTIF_GATTC_GET_GATT_DB:
{
btgatt_db_element_t *db = NULL;
(char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
}
-static bt_status_t btif_gattc_get_characteristic( int conn_id
- , btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id)
-{
- CHECK_BTGATT_INIT();
- btif_gattc_cb_t btif_cb;
- btif_cb.conn_id = (uint16_t) conn_id;
- memcpy(&btif_cb.srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
- if (start_char_id)
- {
- memcpy(&btif_cb.char_id, start_char_id, sizeof(btgatt_gatt_id_t));
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_GET_NEXT_CHAR,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
- }
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_GET_FIRST_CHAR,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
-}
-
-static bt_status_t btif_gattc_get_descriptor( int conn_id
- , btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id
- , btgatt_gatt_id_t *start_descr_id)
-{
- CHECK_BTGATT_INIT();
- btif_gattc_cb_t btif_cb;
- btif_cb.conn_id = (uint16_t) conn_id;
- memcpy(&btif_cb.srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
- memcpy(&btif_cb.char_id, char_id, sizeof(btgatt_gatt_id_t));
- if (start_descr_id)
- {
- memcpy(&btif_cb.descr_id, start_descr_id, sizeof(btgatt_gatt_id_t));
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_GET_NEXT_CHAR_DESCR,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
- }
-
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_GET_FIRST_CHAR_DESCR,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
-}
-
-static bt_status_t btif_gattc_get_included_service(int conn_id, btgatt_srvc_id_t *srvc_id,
- btgatt_srvc_id_t *start_incl_srvc_id)
-{
- CHECK_BTGATT_INIT();
- btif_gattc_cb_t btif_cb;
- btif_cb.conn_id = (uint16_t) conn_id;
- memcpy(&btif_cb.srvc_id, srvc_id, sizeof(btgatt_srvc_id_t));
- if (start_incl_srvc_id)
- {
- memcpy(&btif_cb.incl_srvc_id, start_incl_srvc_id, sizeof(btgatt_srvc_id_t));
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_GET_NEXT_INCL_SERVICE,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
- }
- return btif_transfer_context(btgattc_handle_event, BTIF_GATTC_GET_FIRST_INCL_SERVICE,
- (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
-}
-
static bt_status_t btif_gattc_get_gatt_db(int conn_id)
{
CHECK_BTGATT_INIT();
btif_gattc_listen,
btif_gattc_refresh,
btif_gattc_search_service,
- btif_gattc_get_included_service,
- btif_gattc_get_characteristic,
- btif_gattc_get_descriptor,
btif_gattc_read_char,
btif_gattc_write_char,
btif_gattc_read_char_descr,