Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a2442c7 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'bt5-cherry-pickerry-3' into oc-dev

* changes:
  Fix LE disconnecting right after pairing
  Handle remote not supporting LL_SLAVE_FEATURE_REQ
  Expose LE advertiser address for easier PTS tests (4/6)
  Read by UUID for PTS tests (4/5)
parents 15a03831 7dc86588
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
@@ -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) {
@@ -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) {
+24 −0
Original line number Diff line number Diff line
@@ -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
+8 −0
Original line number Diff line number Diff line
@@ -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;
+9 −0
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
@@ -107,6 +107,13 @@ class BleAdvertiserInterfaceImpl : public BleAdvertiserInterface {
             base::Unretained(BleAdvertisingManager::Get()), advertiser_id));
  }

  void GetOwnAddress(uint8_t advertiser_id, GetAddressCallback cb) override {
    do_in_bta_thread(FROM_HERE,
                     Bind(&BleAdvertisingManager::GetOwnAddress,
                          base::Unretained(BleAdvertisingManager::Get()),
                          advertiser_id, jni_thread_wrapper(FROM_HERE, cb)));
  }

  void SetParameters(uint8_t advertiser_id, AdvertiseParameters params,
                     ParametersCallback cb) override {
    VLOG(1) << __func__;
Loading