bta_sys_sendmsg(p_buf);
}
-void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id,
- const Uuid& p_srvc_uuid) {
- tGATT_DISC_PARAM* param = new tGATT_DISC_PARAM;
- param->s_handle = 0x0001;
- param->e_handle = 0xFFFF;
- param->service = p_srvc_uuid;
- do_in_bta_thread(FROM_HERE,
- base::Bind(base::IgnoreResult(&GATTC_Discover), conn_id,
- GATT_DISC_SRVC_BY_UUID, base::Owned(param)));
+void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id, const Uuid& srvc_uuid) {
+ do_in_bta_thread(
+ FROM_HERE,
+ base::Bind(
+ base::IgnoreResult<tGATT_STATUS (*)(uint16_t, tGATT_DISC_TYPE,
+ uint16_t, uint16_t, const Uuid&)>(
+ &GATTC_Discover),
+ conn_id, GATT_DISC_SRVC_BY_UUID, 0x0001, 0xFFFF, srvc_uuid));
}
/*******************************************************************************
if (!p_clcb) return GATT_ERROR;
if (p_clcb->transport == BTA_TRANSPORT_LE) {
- tGATT_DISC_PARAM param{.s_handle = 0x0001, .e_handle = 0xFFFF};
- return GATTC_Discover(conn_id, disc_type, ¶m);
+ return GATTC_Discover(conn_id, disc_type, 0x0001, 0xFFFF);
}
// only for Classic transport
VLOG(1) << "Start service discovery";
/* start discovering included services */
- tGATT_DISC_PARAM param = {.s_handle = service.first,
- .e_handle = service.second};
- GATTC_Discover(conn_id, GATT_DISC_INC_SRVC, ¶m);
+ GATTC_Discover(conn_id, GATT_DISC_INC_SRVC, service.first, service.second);
}
static void bta_gattc_explore_srvc_finished(uint16_t conn_id,
goto descriptor_discovery_done;
}
- {
- tGATT_DISC_PARAM param{.s_handle = range.first, .e_handle = range.second};
- if (GATTC_Discover(conn_id, GATT_DISC_CHAR_DSCPT, ¶m) != 0) {
- goto descriptor_discovery_done;
- }
+ if (GATTC_Discover(conn_id, GATT_DISC_CHAR_DSCPT, range.first,
+ range.second) != 0) {
+ goto descriptor_discovery_done;
}
return;
case GATT_DISC_INC_SRVC: {
auto& service = p_srvc_cb->pending_discovery.CurrentlyExploredService();
/* start discovering characteristic */
- tGATT_DISC_PARAM param = {.s_handle = service.first,
- .e_handle = service.second};
- GATTC_Discover(conn_id, GATT_DISC_CHAR, ¶m);
+ GATTC_Discover(conn_id, GATT_DISC_CHAR, service.first, service.second);
break;
}
* PTS tests.
*/
extern void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id,
- const bluetooth::Uuid& p_srvc_uuid);
+ const bluetooth::Uuid& srvc_uuid);
/*******************************************************************************
*
case 0x04: /* Discover */
{
- tGATT_DISC_PARAM param;
- memset(¶m, 0, sizeof(tGATT_DISC_PARAM));
-
if (params->u1 >= GATT_DISC_MAX) {
LOG_ERROR(LOG_TAG, "%s: DISCOVER - Invalid type (%d)!", __func__,
params->u1);
return (bt_status_t)0;
}
- param.s_handle = params->u2;
- param.e_handle = params->u3;
- param.service = *params->uuid1;
-
LOG_DEBUG(LOG_TAG,
"%s: DISCOVER (%s), conn_id=%d, uuid=%s, handles=0x%04x-0x%04x",
__func__, disc_name[params->u1], test_cb.conn_id,
- param.service.ToString().c_str(), params->u2, params->u3);
- GATTC_Discover(test_cb.conn_id, params->u1, ¶m);
+ params->uuid1->ToString().c_str(), params->u2, params->u3);
+ GATTC_Discover(test_cb.conn_id, params->u1, params->u2, params->u3,
+ *params->uuid1);
break;
}
*
* Parameters conn_id: connection identifier.
* disc_type:discovery type.
- * p_param: parameters of discovery requirement.
+ * start_handle and end_handle: range of handles for discovery
+ * uuid: uuid to discovery. set to Uuid::kEmpty for requests
+ * that don't need it
*
* Returns GATT_SUCCESS if command received/sent successfully.
*
******************************************************************************/
tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
- tGATT_DISC_PARAM* p_param) {
+ uint16_t start_handle, uint16_t end_handle,
+ const Uuid& uuid) {
tGATT_IF gatt_if = GATT_GET_GATT_IF(conn_id);
uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id);
tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx);
tGATT_REG* p_reg = gatt_get_regcb(gatt_if);
- if ((p_tcb == NULL) || (p_reg == NULL) || (p_param == NULL) ||
- (disc_type >= GATT_DISC_MAX)) {
+ if ((p_tcb == NULL) || (p_reg == NULL) || (disc_type >= GATT_DISC_MAX)) {
LOG(ERROR) << __func__ << " Illegal param: disc_type=" << +disc_type
<< " conn_id=" << loghex(conn_id);
return GATT_ILLEGAL_PARAMETER;
LOG(INFO) << __func__ << " conn_id=" << loghex(conn_id)
<< ", disc_type=" << +disc_type
- << ", s_handle=" << loghex(p_param->s_handle)
- << ", e_handle=" << loghex(p_param->e_handle);
+ << ", s_handle=" << loghex(start_handle)
+ << ", e_handle=" << loghex(end_handle);
- if (!GATT_HANDLE_IS_VALID(p_param->s_handle) ||
- !GATT_HANDLE_IS_VALID(p_param->e_handle) ||
+ if (!GATT_HANDLE_IS_VALID(start_handle) ||
+ !GATT_HANDLE_IS_VALID(end_handle) ||
/* search by type does not have a valid UUID param */
- (disc_type == GATT_DISC_SRVC_BY_UUID && p_param->service.IsEmpty())) {
+ (disc_type == GATT_DISC_SRVC_BY_UUID && uuid.IsEmpty())) {
return GATT_ILLEGAL_PARAMETER;
}
p_clcb->operation = GATTC_OPTYPE_DISCOVERY;
p_clcb->op_subtype = disc_type;
- p_clcb->s_handle = p_param->s_handle;
- p_clcb->e_handle = p_param->e_handle;
- p_clcb->uuid = p_param->service;
+ p_clcb->s_handle = start_handle;
+ p_clcb->e_handle = end_handle;
+ p_clcb->uuid = uuid;
gatt_act_discovery(p_clcb);
return GATT_SUCCESS;
}
+tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
+ uint16_t start_handle, uint16_t end_handle) {
+ return GATTC_Discover(conn_id, disc_type, start_handle, end_handle,
+ Uuid::kEmpty);
+}
+
/*******************************************************************************
*
* Function GATTC_Read
*
******************************************************************************/
static void gatt_cl_start_config_ccc(tGATT_PROFILE_CLCB* p_clcb) {
- tGATT_DISC_PARAM srvc_disc_param;
- tGATT_VALUE ccc_value;
VLOG(1) << __func__ << ": stage: " << +p_clcb->ccc_stage;
- memset(&srvc_disc_param, 0, sizeof(tGATT_DISC_PARAM));
- memset(&ccc_value, 0, sizeof(tGATT_VALUE));
-
switch (p_clcb->ccc_stage) {
case GATT_SVC_CHANGED_SERVICE: /* discover GATT service */
- srvc_disc_param.s_handle = 1;
- srvc_disc_param.e_handle = 0xffff;
- srvc_disc_param.service = Uuid::From16Bit(UUID_SERVCLASS_GATT_SERVER);
- GATTC_Discover(p_clcb->conn_id, GATT_DISC_SRVC_BY_UUID, &srvc_disc_param);
+ GATTC_Discover(p_clcb->conn_id, GATT_DISC_SRVC_BY_UUID, 0x0001, 0xffff,
+ Uuid::From16Bit(UUID_SERVCLASS_GATT_SERVER));
break;
case GATT_SVC_CHANGED_CHARACTERISTIC: /* discover service change char */
- srvc_disc_param.s_handle = 1;
- srvc_disc_param.e_handle = p_clcb->e_handle;
- srvc_disc_param.service = Uuid::From16Bit(GATT_UUID_GATT_SRV_CHGD);
- GATTC_Discover(p_clcb->conn_id, GATT_DISC_CHAR, &srvc_disc_param);
+ GATTC_Discover(p_clcb->conn_id, GATT_DISC_CHAR, 0x0001, p_clcb->e_handle,
+ Uuid::From16Bit(GATT_UUID_GATT_SRV_CHGD));
break;
case GATT_SVC_CHANGED_DESCRIPTOR: /* discover service change ccc */
- srvc_disc_param.s_handle = p_clcb->s_handle;
- srvc_disc_param.e_handle = p_clcb->e_handle;
- GATTC_Discover(p_clcb->conn_id, GATT_DISC_CHAR_DSCPT, &srvc_disc_param);
+ GATTC_Discover(p_clcb->conn_id, GATT_DISC_CHAR_DSCPT, p_clcb->s_handle,
+ p_clcb->e_handle);
break;
case GATT_SVC_CHANGED_CONFIGURE_CCCD: /* write ccc */
+ {
+ tGATT_VALUE ccc_value;
+ memset(&ccc_value, 0, sizeof(tGATT_VALUE));
ccc_value.handle = p_clcb->s_handle;
ccc_value.len = 2;
ccc_value.value[0] = GATT_CLT_CONFIG_INDICATION;
GATTC_Write(p_clcb->conn_id, GATT_WRITE, &ccc_value);
break;
+ }
}
}
};
typedef uint8_t tGATT_DISC_TYPE;
-/* Discover parameters of different discovery types
-*/
-typedef struct {
- bluetooth::Uuid service;
- uint16_t s_handle;
- uint16_t e_handle;
-} tGATT_DISC_PARAM;
-
/* GATT read type enumeration
*/
enum {
*
* Parameters conn_id: connection identifier.
* disc_type:discovery type.
- * p_param: parameters of discovery requirement.
+ * start_handle and end_handle: range of handles for discovery
+ * uuid: uuid to discovery. set to Uuid::kEmpty for requests
+ * that don't need it
*
* Returns GATT_SUCCESS if command received/sent successfully.
*
******************************************************************************/
extern tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
- tGATT_DISC_PARAM* p_param);
+ uint16_t start_handle, uint16_t end_handle,
+ const bluetooth::Uuid& uuid);
+extern tGATT_STATUS GATTC_Discover(uint16_t conn_id, tGATT_DISC_TYPE disc_type,
+ uint16_t start_handle, uint16_t end_handle);
+
/*******************************************************************************
*
* Function GATTC_Read