Loading system/bta/gatt/bta_gattc_act.cc +21 −7 Original line number Diff line number Diff line Loading @@ -933,13 +933,23 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb, void bta_gattc_read(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { if (!bta_gattc_enqueue(p_clcb, p_data)) return; tBTA_GATT_STATUS status; if (p_data->api_read.handle != 0) { tGATT_READ_PARAM read_param; memset(&read_param, 0, sizeof(tGATT_READ_PARAM)); read_param.by_handle.handle = p_data->api_read.handle; read_param.by_handle.auth_req = p_data->api_read.auth_req; status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param); } else { tGATT_READ_PARAM read_param; memset(&read_param, 0, sizeof(tGATT_READ_BY_TYPE)); tBTA_GATT_STATUS status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param); read_param.char_type.s_handle = p_data->api_read.s_handle; read_param.char_type.e_handle = p_data->api_read.e_handle; read_param.char_type.uuid = p_data->api_read.uuid; read_param.char_type.auth_req = p_data->api_read.auth_req; status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_TYPE, &read_param); } /* read fail */ if (status != BTA_GATT_OK) { Loading Loading @@ -1080,7 +1090,11 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_OP_CMPL* p_data) { GATT_READ_OP_CB cb = p_clcb->p_q_cmd->api_read.read_cb; void* my_cb_data = p_clcb->p_q_cmd->api_read.read_cb_data; // if it was read by handle, return the handle requested, if read by UUID, use // handle returned from remote uint16_t handle = p_clcb->p_q_cmd->api_read.handle; if (handle == 0) handle = p_data->p_cmpl->att_value.handle; osi_free_and_reset((void**)&p_clcb->p_q_cmd); if (cb) { Loading system/bta/gatt/bta_gattc_api.cc +24 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,30 @@ void BTA_GATTC_ReadCharacteristic(uint16_t conn_id, uint16_t handle, bta_sys_sendmsg(p_buf); } /** * This function is called to read a value of characteristic with uuid equal to * |uuid| */ void BTA_GATTC_ReadUsingCharUuid(uint16_t conn_id, tBT_UUID uuid, uint16_t s_handle, uint16_t e_handle, tBTA_GATT_AUTH_REQ auth_req, GATT_READ_OP_CB callback, void* cb_data) { tBTA_GATTC_API_READ* p_buf = (tBTA_GATTC_API_READ*)osi_calloc(sizeof(tBTA_GATTC_API_READ)); p_buf->hdr.event = BTA_GATTC_API_READ_EVT; p_buf->hdr.layer_specific = conn_id; p_buf->auth_req = auth_req; p_buf->handle = 0; p_buf->uuid = uuid; p_buf->s_handle = s_handle; p_buf->e_handle = e_handle; p_buf->read_cb = callback; p_buf->read_cb_data = cb_data; bta_sys_sendmsg(p_buf); } /******************************************************************************* * * Function BTA_GATTC_ReadCharDescr Loading system/bta/gatt/bta_gattc_int.h +8 −0 Original line number Diff line number Diff line Loading @@ -109,7 +109,15 @@ typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN; typedef struct { BT_HDR hdr; tBTA_GATT_AUTH_REQ auth_req; // read by handle data uint16_t handle; // read by UUID data tBT_UUID uuid; uint16_t s_handle; uint16_t e_handle; tBTA_GATTC_EVT cmpl_evt; GATT_READ_OP_CB read_cb; void* read_cb_data; Loading system/bta/include/bta_gatt_api.h +9 −0 Original line number Diff line number Diff line Loading @@ -777,6 +777,15 @@ void BTA_GATTC_ReadCharacteristic(uint16_t conn_id, uint16_t handle, tBTA_GATT_AUTH_REQ auth_req, GATT_READ_OP_CB callback, void* cb_data); /** * This function is called to read a value of characteristic with uuid equal to * |uuid| */ void BTA_GATTC_ReadUsingCharUuid(uint16_t conn_id, tBT_UUID uuid, uint16_t s_handle, uint16_t e_handle, tBTA_GATT_AUTH_REQ auth_req, GATT_READ_OP_CB callback, void* cb_data); /******************************************************************************* * * Function BTA_GATTC_ReadCharDescr Loading system/btif/src/btif_gatt_client.cc +27 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,32 @@ bt_status_t btif_gattc_read_char(int conn_id, uint16_t handle, int auth_req) { auth_req, read_char_cb, nullptr)); } void read_using_char_uuid_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, uint16_t len, uint8_t* value, void* data) { btgatt_read_params_t* params = new btgatt_read_params_t; params->value_type = 0x00 /* GATTC_READ_VALUE_TYPE_VALUE */; params->status = status; params->handle = handle; params->value.len = len; CHECK(len <= BTGATT_MAX_ATTR_LEN); if (len > 0) memcpy(params->value.value, value, len); CLI_CBACK_IN_JNI(read_characteristic_cb, conn_id, status, base::Owned(params)); } bt_status_t btif_gattc_read_using_char_uuid(int conn_id, bt_uuid_t* uuid, uint16_t s_handle, uint16_t e_handle, int auth_req) { CHECK_BTGATT_INIT(); tBT_UUID bt_uuid; btif_to_bta_uuid(&bt_uuid, uuid); return do_in_jni_thread(Bind(&BTA_GATTC_ReadUsingCharUuid, conn_id, bt_uuid, s_handle, e_handle, auth_req, read_using_char_uuid_cb, nullptr)); } void read_desc_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, uint16_t len, uint8_t* value, void* data) { btgatt_read_params_t* params = new btgatt_read_params_t; Loading Loading @@ -584,6 +610,7 @@ const btgatt_client_interface_t btgattClientInterface = { btif_gattc_refresh, btif_gattc_search_service, btif_gattc_read_char, btif_gattc_read_using_char_uuid, btif_gattc_write_char, btif_gattc_read_char_descr, btif_gattc_write_char_descr, Loading Loading
system/bta/gatt/bta_gattc_act.cc +21 −7 Original line number Diff line number Diff line Loading @@ -933,13 +933,23 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB* p_clcb, void bta_gattc_read(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { if (!bta_gattc_enqueue(p_clcb, p_data)) return; tBTA_GATT_STATUS status; if (p_data->api_read.handle != 0) { tGATT_READ_PARAM read_param; memset(&read_param, 0, sizeof(tGATT_READ_PARAM)); read_param.by_handle.handle = p_data->api_read.handle; read_param.by_handle.auth_req = p_data->api_read.auth_req; status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param); } else { tGATT_READ_PARAM read_param; memset(&read_param, 0, sizeof(tGATT_READ_BY_TYPE)); tBTA_GATT_STATUS status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_HANDLE, &read_param); read_param.char_type.s_handle = p_data->api_read.s_handle; read_param.char_type.e_handle = p_data->api_read.e_handle; read_param.char_type.uuid = p_data->api_read.uuid; read_param.char_type.auth_req = p_data->api_read.auth_req; status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_TYPE, &read_param); } /* read fail */ if (status != BTA_GATT_OK) { Loading Loading @@ -1080,7 +1090,11 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_OP_CMPL* p_data) { GATT_READ_OP_CB cb = p_clcb->p_q_cmd->api_read.read_cb; void* my_cb_data = p_clcb->p_q_cmd->api_read.read_cb_data; // if it was read by handle, return the handle requested, if read by UUID, use // handle returned from remote uint16_t handle = p_clcb->p_q_cmd->api_read.handle; if (handle == 0) handle = p_data->p_cmpl->att_value.handle; osi_free_and_reset((void**)&p_clcb->p_q_cmd); if (cb) { Loading
system/bta/gatt/bta_gattc_api.cc +24 −0 Original line number Diff line number Diff line Loading @@ -353,6 +353,30 @@ void BTA_GATTC_ReadCharacteristic(uint16_t conn_id, uint16_t handle, bta_sys_sendmsg(p_buf); } /** * This function is called to read a value of characteristic with uuid equal to * |uuid| */ void BTA_GATTC_ReadUsingCharUuid(uint16_t conn_id, tBT_UUID uuid, uint16_t s_handle, uint16_t e_handle, tBTA_GATT_AUTH_REQ auth_req, GATT_READ_OP_CB callback, void* cb_data) { tBTA_GATTC_API_READ* p_buf = (tBTA_GATTC_API_READ*)osi_calloc(sizeof(tBTA_GATTC_API_READ)); p_buf->hdr.event = BTA_GATTC_API_READ_EVT; p_buf->hdr.layer_specific = conn_id; p_buf->auth_req = auth_req; p_buf->handle = 0; p_buf->uuid = uuid; p_buf->s_handle = s_handle; p_buf->e_handle = e_handle; p_buf->read_cb = callback; p_buf->read_cb_data = cb_data; bta_sys_sendmsg(p_buf); } /******************************************************************************* * * Function BTA_GATTC_ReadCharDescr Loading
system/bta/gatt/bta_gattc_int.h +8 −0 Original line number Diff line number Diff line Loading @@ -109,7 +109,15 @@ typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN; typedef struct { BT_HDR hdr; tBTA_GATT_AUTH_REQ auth_req; // read by handle data uint16_t handle; // read by UUID data tBT_UUID uuid; uint16_t s_handle; uint16_t e_handle; tBTA_GATTC_EVT cmpl_evt; GATT_READ_OP_CB read_cb; void* read_cb_data; Loading
system/bta/include/bta_gatt_api.h +9 −0 Original line number Diff line number Diff line Loading @@ -777,6 +777,15 @@ void BTA_GATTC_ReadCharacteristic(uint16_t conn_id, uint16_t handle, tBTA_GATT_AUTH_REQ auth_req, GATT_READ_OP_CB callback, void* cb_data); /** * This function is called to read a value of characteristic with uuid equal to * |uuid| */ void BTA_GATTC_ReadUsingCharUuid(uint16_t conn_id, tBT_UUID uuid, uint16_t s_handle, uint16_t e_handle, tBTA_GATT_AUTH_REQ auth_req, GATT_READ_OP_CB callback, void* cb_data); /******************************************************************************* * * Function BTA_GATTC_ReadCharDescr Loading
system/btif/src/btif_gatt_client.cc +27 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,32 @@ bt_status_t btif_gattc_read_char(int conn_id, uint16_t handle, int auth_req) { auth_req, read_char_cb, nullptr)); } void read_using_char_uuid_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, uint16_t len, uint8_t* value, void* data) { btgatt_read_params_t* params = new btgatt_read_params_t; params->value_type = 0x00 /* GATTC_READ_VALUE_TYPE_VALUE */; params->status = status; params->handle = handle; params->value.len = len; CHECK(len <= BTGATT_MAX_ATTR_LEN); if (len > 0) memcpy(params->value.value, value, len); CLI_CBACK_IN_JNI(read_characteristic_cb, conn_id, status, base::Owned(params)); } bt_status_t btif_gattc_read_using_char_uuid(int conn_id, bt_uuid_t* uuid, uint16_t s_handle, uint16_t e_handle, int auth_req) { CHECK_BTGATT_INIT(); tBT_UUID bt_uuid; btif_to_bta_uuid(&bt_uuid, uuid); return do_in_jni_thread(Bind(&BTA_GATTC_ReadUsingCharUuid, conn_id, bt_uuid, s_handle, e_handle, auth_req, read_using_char_uuid_cb, nullptr)); } void read_desc_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle, uint16_t len, uint8_t* value, void* data) { btgatt_read_params_t* params = new btgatt_read_params_t; Loading Loading @@ -584,6 +610,7 @@ const btgatt_client_interface_t btgattClientInterface = { btif_gattc_refresh, btif_gattc_search_service, btif_gattc_read_char, btif_gattc_read_using_char_uuid, btif_gattc_write_char, btif_gattc_read_char_descr, btif_gattc_write_char_descr, Loading