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

Commit 1ea4dcd2 authored by David Duarte's avatar David Duarte Committed by Gerrit Code Review
Browse files

Merge "add max number for phy update retry"

parents 1ff2644f 1e59b5ee
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -678,13 +678,20 @@ class HearingAidImpl : public HearingAid {
    if (tx_phys == PHY_LE_2M && rx_phys == PHY_LE_2M) {
      LOG_INFO("%s phy update to 2M successful",
               ADDRESS_TO_LOGGABLE_CSTR(hearingDevice->address));
      hearingDevice->phy_update_retry_remain = PHY_UPDATE_RETRY_LIMIT;
      return;
    }

    if (hearingDevice->phy_update_retry_remain > 0) {
      LOG_INFO(
          "%s phy update successful but not target phy, try again. tx_phys: "
          "%u,rx_phys: %u",
          ADDRESS_TO_LOGGABLE_CSTR(hearingDevice->address), tx_phys, rx_phys);
      BTM_BleSetPhy(hearingDevice->address, PHY_LE_2M, PHY_LE_2M, 0);
      hearingDevice->phy_update_retry_remain--;
    } else {
      LOG_INFO("no more phy update after %d retry", PHY_UPDATE_RETRY_LIMIT);
    }
  }

  void OnServiceChangeEvent(const RawAddress& address) {
+9 −2
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@ constexpr uint8_t CAPABILITY_SIDE = 0x01;
constexpr uint8_t CAPABILITY_BINAURAL = 0x02;
constexpr uint8_t CAPABILITY_RESERVED = 0xFC;

// Number of retry for phy update. This targets to reduce phy update collision.
constexpr uint8_t PHY_UPDATE_RETRY_LIMIT = 5;

/** Implementations of HearingAid will also implement this interface */
class HearingAidAudioReceiver {
 public:
@@ -160,6 +163,8 @@ struct HearingDevice {

  bool gap_opened;

  int phy_update_retry_remain;

  HearingDevice(const RawAddress& address, uint8_t capabilities,
                uint16_t codecs, uint16_t audio_control_point_handle,
                uint16_t audio_status_handle, uint16_t audio_status_ccc_handle,
@@ -188,7 +193,8 @@ struct HearingDevice {
        playback_started(false),
        command_acked(false),
        read_rssi_count(0),
        gap_opened(false) {}
        gap_opened(false),
        phy_update_retry_remain(PHY_UPDATE_RETRY_LIMIT) {}

  HearingDevice(const RawAddress& address, bool first_connection)
      : address(address),
@@ -211,7 +217,8 @@ struct HearingDevice {
        playback_started(false),
        command_acked(false),
        read_rssi_count(0),
        gap_opened(false) {}
        gap_opened(false),
        phy_update_retry_remain(PHY_UPDATE_RETRY_LIMIT) {}

  HearingDevice() : HearingDevice(RawAddress::kEmpty, false) {}