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

Commit 6da94e0c authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Add option to specify initial LE connection PHY (1/3)

For whitelist connections we always use all possible PHYs, for direct
connection use PHY specified by client.

Test: manual
Bug: 30622771
Change-Id: I720f134e2800dc3d282135bb7ffbe3882117c680
parent f1607be1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -432,7 +432,8 @@ void bta_gattc_open(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) {

  /* open/hold a connection */
  if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, true,
                    p_data->api_conn.transport, false)) {
                    p_data->api_conn.transport, false,
                    p_data->api_conn.initiating_phys)) {
    APPL_TRACE_ERROR("Connection open failure");

    bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data);
+9 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "bta_gatt_api.h"
#include "bta_gattc_int.h"
#include "bta_sys.h"
#include "device/include/controller.h"

/*****************************************************************************
 *  Constants
@@ -125,12 +126,17 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) {
 *                  is_direct: direct connection or background auto connection
 *                  transport: Transport to be used for GATT connection
 *                             (BREDR/LE)
 *
 * Returns          void
 *                  initiating_phys: LE PHY to use, optional
 *
 ******************************************************************************/
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
                    tBTA_GATT_TRANSPORT transport) {
  uint8_t phy = controller_get_interface()->get_le_all_initiating_phys();
  BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy);
}

void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
                    tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys) {
  tBTA_GATTC_API_OPEN* p_buf =
      (tBTA_GATTC_API_OPEN*)osi_malloc(sizeof(tBTA_GATTC_API_OPEN));

@@ -138,6 +144,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct,
  p_buf->client_if = client_if;
  p_buf->is_direct = is_direct;
  p_buf->transport = transport;
  p_buf->initiating_phys = initiating_phys;
  memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);

  bta_sys_sendmsg(p_buf);
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ typedef struct {
  tBTA_GATTC_IF client_if;
  bool is_direct;
  tBTA_TRANSPORT transport;
  uint8_t initiating_phys;
} tBTA_GATTC_API_OPEN;

typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
+4 −2
Original line number Diff line number Diff line
@@ -635,12 +635,14 @@ extern void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if);
 * Parameters       client_if: server interface.
 *                  remote_bda: remote device BD address.
 *                  is_direct: direct connection or background auto connection
 *
 * Returns          void
 *                  initiating_phys: LE PHY to use, optional
 *
 ******************************************************************************/
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
                           bool is_direct, tBTA_GATT_TRANSPORT transport);
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
                           bool is_direct, tBTA_GATT_TRANSPORT transport,
                           uint8_t initiating_phys);

/*******************************************************************************
 *
+8 −6
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ bt_status_t btif_gattc_unregister_app(int client_if) {
}

void btif_gattc_open_impl(int client_if, BD_ADDR address, bool is_direct,
                          int transport_p) {
                          int transport_p, int initiating_phys) {
  // Ensure device is in inquiry database
  int addr_type = 0;
  int device_type = 0;
@@ -308,19 +308,21 @@ void btif_gattc_open_impl(int client_if, BD_ADDR address, bool is_direct,
  }

  // Connect!
  BTIF_TRACE_DEBUG("%s Transport=%d, device type=%d", __func__, transport,
                   device_type);
  BTA_GATTC_Open(client_if, address, is_direct, transport);
  BTIF_TRACE_DEBUG("%s Transport=%d, device type=%d, phy=%d", __func__,
                   transport, device_type, initiating_phys);
  BTA_GATTC_Open(client_if, address, is_direct, transport, initiating_phys);
}

bt_status_t btif_gattc_open(int client_if, const bt_bdaddr_t* bd_addr,
                            bool is_direct, int transport) {
                            bool is_direct, int transport,
                            int initiating_phys) {
  CHECK_BTGATT_INIT();
  // Closure will own this value and free it.
  uint8_t* address = new BD_ADDR;
  bdcpy(address, bd_addr->address);
  return do_in_jni_thread(Bind(&btif_gattc_open_impl, client_if,
                               base::Owned(address), is_direct, transport));
                               base::Owned(address), is_direct, transport,
                               initiating_phys));
}

void btif_gattc_close_impl(int client_if, BD_ADDR address, int conn_id) {
Loading