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

Commit c0d3763f authored by Chris Manton's avatar Chris Manton
Browse files

Re-log stack/btm/btm_ble::BTM_BleSetPhy

Towards loggable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Test: act.py -tc BleCocTest
Change-Id: I9dee4893066ed0a80a4dac652d622909a05416fd
parent b925a412
Loading
Loading
Loading
Loading
+5 −25
Original line number Diff line number Diff line
@@ -784,21 +784,6 @@ void BTM_BleReadPhy(

void doNothing(uint8_t* data, uint16_t len) {}

/*******************************************************************************
 *
 * Function         BTM_BleSetPhy
 *
 * Description      To set PHY preferences for specified LE connection
 *
 *
 * Returns          BTM_SUCCESS if command successfully sent to controller,
 *                  BTM_MODE_UNSUPPORTED if local controller doesn't support LE
 *                  2M or LE Coded PHY,
 *                  BTM_ILLEGAL_VALUE if specified remote doesn't support LE 2M
 *                  or LE Coded PHY,
 *                  BTM_WRONG_MODE if Device in wrong mode for request.
 *
 ******************************************************************************/
void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
                   uint16_t phy_options) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
@@ -806,8 +791,9 @@ void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
                                          phy_options);
  }
  if (!BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) {
    BTM_TRACE_ERROR("%s: Wrong mode: no LE link exist or LE not supported",
                    __func__);
    LOG_INFO(
        "Unable to set phy preferences because no le acl is connected to "
        "device");
    return;
  }

@@ -815,25 +801,19 @@ void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
  if (tx_phys == 0) all_phys &= 0x01;
  if (rx_phys == 0) all_phys &= 0x02;

  BTM_TRACE_DEBUG(
      "%s: all_phys = 0x%02x, tx_phys = 0x%02x, rx_phys = 0x%02x, phy_options "
      "= 0x%04x",
      __func__, all_phys, tx_phys, rx_phys, phy_options);

  uint16_t handle = acl_get_hci_handle_for_hcif(bd_addr, BT_TRANSPORT_LE);

  // checking if local controller supports it!
  if (!controller_get_interface()->supports_ble_2m_phy() &&
      !controller_get_interface()->supports_ble_coded_phy()) {
    BTM_TRACE_ERROR("%s failed, request not supported in local controller!",
                    __func__);
    LOG_INFO("Local controller unable to support setting of le phy parameters");
    gatt_notify_phy_updated(GATT_REQ_NOT_SUPPORTED, handle, tx_phys, rx_phys);
    return;
  }

  if (!acl_peer_supports_ble_2m_phy(handle) &&
      !acl_peer_supports_ble_coded_phy(handle)) {
    BTM_TRACE_ERROR("%s failed, peer does not support request", __func__);
    LOG_INFO("Remote device unable to support setting of le phy parameter");
    gatt_notify_phy_updated(GATT_REQ_NOT_SUPPORTED, handle, tx_phys, rx_phys);
    return;
  }