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

Commit a5038efa authored by weichinweng's avatar weichinweng Committed by Automerger Merge Worker
Browse files

Move SetPhy and SetDataLength after connection open am: 23ade73c

parents 523f229b 23ade73c
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -359,8 +359,6 @@ class HearingAidImpl : public HearingAid {
  void OnGattConnected(tGATT_STATUS status, uint16_t conn_id,
                       tGATT_IF client_if, RawAddress address,
                       tBT_TRANSPORT transport, uint16_t mtu) {
    VLOG(2) << __func__ << ": address=" << address << ", conn_id=" << conn_id;

    HearingDevice* hearingDevice = hearingDevices.FindByAddress(address);
    if (!hearingDevice) {
      /* When Hearing Aid is quickly disabled and enabled in settings, this case
@@ -371,6 +369,8 @@ class HearingAidImpl : public HearingAid {
      return;
    }

    LOG(INFO) << __func__ << ": address=" << address << ", conn_id=" << conn_id;

    if (status != GATT_SUCCESS) {
      if (!hearingDevice->connecting_actively) {
        // acceptlist connection failed, that's ok.
@@ -402,6 +402,15 @@ class HearingAidImpl : public HearingAid {
      hearingDevice->connection_update_status = AWAITING;
    }

    if (controller_get_interface()->supports_ble_2m_phy()) {
      LOG(INFO) << address << " set preferred 2M PHY";
      BTM_BleSetPhy(address, PHY_LE_2M, PHY_LE_2M, 0);
    }

    // Set data length
    // TODO(jpawlowski: for 16khz only 87 is required, optimize
    BTM_SetBleDataLength(address, 167);

    if (BTM_SecIsSecurityPending(address)) {
      /* if security collision happened, wait for encryption done
       * (BTA_GATTC_ENC_CMPL_CB_EVT) */
@@ -890,15 +899,6 @@ class HearingAidImpl : public HearingAid {
  void ConnectSocket(HearingDevice* hearingDevice, uint16_t psm) {
    tL2CAP_CFG_INFO cfg_info = tL2CAP_CFG_INFO{.mtu = 512};

    if (controller_get_interface()->supports_ble_2m_phy()) {
      LOG(INFO) << hearingDevice->address << " set preferred PHY to 2M";
      BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0);
    }

    // Set data length
    // TODO(jpawlowski: for 16khz only 87 is required, optimize
    BTM_SetBleDataLength(hearingDevice->address, 167);

    SendEnableServiceChangedInd(hearingDevice);

    uint8_t service_id = hearingDevice->isLeft()