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

Commit fbe7bbec authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

state_machine: Add address to multiple logs

Bug: 331775328
Flag: EXEMPT, comment only
Test: mmm packages/modules/Bluetooth

Change-Id: I19aef9d55ba86fd1351078da4e376c51677e1e8c
parent 976e404c
Loading
Loading
Loading
Loading
+30 −19
Original line number Original line Diff line number Diff line
@@ -250,13 +250,13 @@ bool LeAudioDevice::ConfigureAses(
  /* First try to use the already configured ASE */
  /* First try to use the already configured ASE */
  auto ase = GetFirstActiveAseByDirection(direction);
  auto ase = GetFirstActiveAseByDirection(direction);
  if (ase) {
  if (ase) {
    log::info("Using an already active ASE id={}", ase->id);
    log::info("{}, using an already active ASE id={}", address_, ase->id);
  } else {
  } else {
    ase = GetFirstInactiveAse(direction, reuse_cis_id);
    ase = GetFirstInactiveAse(direction, reuse_cis_id);
  }
  }


  if (!ase) {
  if (!ase) {
    log::error("Unable to find an ASE to configure");
    log::error("{}, unable to find an ASE to configure", address_);
    PrintDebugState();
    PrintDebugState();
    return false;
    return false;
  }
  }
@@ -294,7 +294,7 @@ bool LeAudioDevice::ConfigureAses(
    auto const& ase_cfg = ase_configs.at(i);
    auto const& ase_cfg = ase_configs.at(i);
    if (utils::IsCodecUsingLtvFormat(ase_cfg.codec.id) &&
    if (utils::IsCodecUsingLtvFormat(ase_cfg.codec.id) &&
        !utils::GetConfigurationSupportedPac(pacs, ase_cfg.codec)) {
        !utils::GetConfigurationSupportedPac(pacs, ase_cfg.codec)) {
      log::error("No matching PAC found. Stop the activation.");
      log::error("{}, no matching PAC found. Stop the activation.", address_);
      return false;
      return false;
    }
    }
  }
  }
@@ -309,8 +309,9 @@ bool LeAudioDevice::ConfigureAses(
    if (CodecManager::GetInstance()->CheckCodecConfigIsDualBiDirSwb(
    if (CodecManager::GetInstance()->CheckCodecConfigIsDualBiDirSwb(
            *audio_set_conf)) {
            *audio_set_conf)) {
      log::error(
      log::error(
          "Trying to configure the dual bidir SWB, but the feature is "
          "{}, trying to configure the dual bidir SWB, but the feature is "
          "disabled. This should not happen! Skipping ASE activation.");
          "disabled. This should not happen! Skipping ASE activation.",
          address_);
      return true;
      return true;
    }
    }
  }
  }
@@ -443,7 +444,7 @@ void LeAudioDevice::ParseHeadtrackingCodec(
     */
     */
    std::vector<uint8_t> ltv = pac.metadata;
    std::vector<uint8_t> ltv = pac.metadata;
    if (ltv.size() < 7) {
    if (ltv.size() < 7) {
      log::info("Headtracker codec does not have metadata");
      log::info("{}, headtracker codec does not have metadata", address_);
      return;
      return;
    }
    }


@@ -452,7 +453,7 @@ void LeAudioDevice::ParseHeadtrackingCodec(
        ltv[3] != (types::kLeAudioVendorCompanyIdGoogle >> 8) ||
        ltv[3] != (types::kLeAudioVendorCompanyIdGoogle >> 8) ||
        ltv[4] != types::kLeAudioMetadataHeadtrackerTransportLen ||
        ltv[4] != types::kLeAudioMetadataHeadtrackerTransportLen ||
        ltv[5] != types::kLeAudioMetadataHeadtrackerTransportVal) {
        ltv[5] != types::kLeAudioMetadataHeadtrackerTransportVal) {
      log::warn("Headtracker codec metadata invalid");
      log::warn("{}, headtracker codec metadata invalid", address_);
      return;
      return;
    }
    }


@@ -461,13 +462,13 @@ void LeAudioDevice::ParseHeadtrackingCodec(


    if ((supported_transports &
    if ((supported_transports &
         types::kLeAudioMetadataHeadtrackerTransportLeAcl) != 0) {
         types::kLeAudioMetadataHeadtrackerTransportLeAcl) != 0) {
      log::debug("Headtracking supported over LE-ACL");
      log::debug("{}, headtracking supported over LE-ACL", address_);
      dsa_modes.push_back(DsaMode::ACL);
      dsa_modes.push_back(DsaMode::ACL);
    }
    }


    if ((supported_transports &
    if ((supported_transports &
         types::kLeAudioMetadataHeadtrackerTransportLeIso) != 0) {
         types::kLeAudioMetadataHeadtrackerTransportLeIso) != 0) {
      log::debug("Headtracking supported over LE-ISO");
      log::debug("{}, headtracking supported over LE-ISO", address_);
      dsa_modes.push_back(DsaMode::ISO_SW);
      dsa_modes.push_back(DsaMode::ISO_SW);
      dsa_modes.push_back(DsaMode::ISO_HW);
      dsa_modes.push_back(DsaMode::ISO_HW);
    }
    }
@@ -481,7 +482,7 @@ void LeAudioDevice::RegisterPACs(
    std::vector<struct types::acs_ac_record>* pac_recs) {
    std::vector<struct types::acs_ac_record>* pac_recs) {
  /* Clear PAC database for characteristic in case if re-read, indicated */
  /* Clear PAC database for characteristic in case if re-read, indicated */
  if (!pac_db->empty()) {
  if (!pac_db->empty()) {
    log::debug("upgrade PACs for characteristic");
    log::debug("{}, upgrade PACs for characteristic", address_);
    pac_db->clear();
    pac_db->clear();
  }
  }


@@ -578,7 +579,8 @@ struct ase* LeAudioDevice::GetNextActiveAseWithDifferentDirection(


  /* Invalid ase given */
  /* Invalid ase given */
  if (std::distance(iter, ases_.end()) < 1) {
  if (std::distance(iter, ases_.end()) < 1) {
    log::debug("ASE {} does not use bidirectional CIS", base_ase->id);
    log::debug("{}, ASE {} does not use bidirectional CIS", address_,
               base_ase->id);
    return nullptr;
    return nullptr;
  }
  }


@@ -715,6 +717,7 @@ bool LeAudioDevice::HaveAnyUnconfiguredAses(void) {
}
}


bool LeAudioDevice::HaveAllActiveAsesSameState(AseState state) {
bool LeAudioDevice::HaveAllActiveAsesSameState(AseState state) {
  log::verbose("{}", address_);
  auto iter =
  auto iter =
      std::find_if(ases_.begin(), ases_.end(), [&state](const auto& ase) {
      std::find_if(ases_.begin(), ases_.end(), [&state](const auto& ase) {
        log::verbose("ASE id: {}, active: {}, state: {}", ase.id, ase.active,
        log::verbose("ASE id: {}, active: {}, state: {}", ase.id, ase.active,
@@ -727,6 +730,7 @@ bool LeAudioDevice::HaveAllActiveAsesSameState(AseState state) {


bool LeAudioDevice::HaveAllActiveAsesSameDataPathState(
bool LeAudioDevice::HaveAllActiveAsesSameDataPathState(
    types::DataPathState state) const {
    types::DataPathState state) const {
  log::verbose("{}", address_);
  auto iter =
  auto iter =
      std::find_if(ases_.begin(), ases_.end(), [&state](const auto& ase) {
      std::find_if(ases_.begin(), ases_.end(), [&state](const auto& ase) {
        log::verbose("ASE id: {}, active: {}, state: {}", ase.id, ase.active,
        log::verbose("ASE id: {}, active: {}, state: {}", ase.id, ase.active,
@@ -738,6 +742,7 @@ bool LeAudioDevice::HaveAllActiveAsesSameDataPathState(
}
}


bool LeAudioDevice::IsReadyToCreateStream(void) {
bool LeAudioDevice::IsReadyToCreateStream(void) {
  log::verbose("{}", address_);
  auto iter = std::find_if(ases_.begin(), ases_.end(), [](const auto& ase) {
  auto iter = std::find_if(ases_.begin(), ases_.end(), [](const auto& ase) {
    if (!ase.active) return false;
    if (!ase.active) return false;


@@ -785,6 +790,8 @@ bool LeAudioDevice::HaveAllActiveAsesCisEst(void) const {
    return true;
    return true;
  }
  }


  log::verbose("{}", address_);

  bool has_active_ase = false;
  bool has_active_ase = false;
  auto iter = std::find_if(ases_.begin(), ases_.end(), [&](const auto& ase) {
  auto iter = std::find_if(ases_.begin(), ases_.end(), [&](const auto& ase) {
    if (!has_active_ase && ase.active) {
    if (!has_active_ase && ase.active) {
@@ -816,7 +823,7 @@ uint8_t LeAudioDevice::GetSupportedAudioChannelCounts(uint8_t direction) const {
      direction == types::kLeAudioDirectionSink ? snk_pacs_ : src_pacs_;
      direction == types::kLeAudioDirectionSink ? snk_pacs_ : src_pacs_;


  if (pacs.size() == 0) {
  if (pacs.size() == 0) {
    log::error("missing PAC for direction {}", direction);
    log::error("{}, missing PAC for direction {}", address_, direction);
    return 0;
    return 0;
  }
  }


@@ -826,7 +833,7 @@ uint8_t LeAudioDevice::GetSupportedAudioChannelCounts(uint8_t direction) const {


    for (const auto pac : pac_recs) {
    for (const auto pac : pac_recs) {
      if (!utils::IsCodecUsingLtvFormat(pac.codec_id)) {
      if (!utils::IsCodecUsingLtvFormat(pac.codec_id)) {
        log::warn("Unknown codec PAC record for codec: {}",
        log::warn(" {} Unknown codec PAC record for codec: {}", address_,
                  bluetooth::common::ToString(pac.codec_id));
                  bluetooth::common::ToString(pac.codec_id));
        continue;
        continue;
      }
      }
@@ -910,12 +917,14 @@ uint8_t LeAudioDevice::GetPreferredPhyBitmask(uint8_t preferred_phy) const {
  // Take the preferences if possible
  // Take the preferences if possible
  if (preferred_phy && (phy_bitmask & preferred_phy)) {
  if (preferred_phy && (phy_bitmask & preferred_phy)) {
    phy_bitmask &= preferred_phy;
    phy_bitmask &= preferred_phy;
    log::debug("Using ASE preferred phy 0x{:02x}",
    log::debug("{},  using ASE preferred phy 0x{:02x}", address_,
               static_cast<int>(phy_bitmask));
               static_cast<int>(phy_bitmask));
  } else {
  } else {
    log::warn(
    log::warn(
        "ASE preferred 0x{:02x} has nothing common with phy_bitfield  0x{:02x}",
        " {}, ASE preferred 0x{:02x} has nothing common with phy_bitfield  "
        static_cast<int>(preferred_phy), static_cast<int>(phy_bitmask));
        "0x{:02x}",
        address_, static_cast<int>(preferred_phy),
        static_cast<int>(phy_bitmask));
  }
  }
  return phy_bitmask;
  return phy_bitmask;
}
}
@@ -1033,10 +1042,12 @@ void LeAudioDevice::DisconnectAcl(void) {
void LeAudioDevice::SetAvailableContexts(
void LeAudioDevice::SetAvailableContexts(
    BidirectionalPair<AudioContexts> contexts) {
    BidirectionalPair<AudioContexts> contexts) {
  log::debug(
  log::debug(
      "\n\t previous_contexts_.sink: {} \n\t previous_contexts_.source: {}  "
      "{}: \n\t previous_contexts_.sink: {} \n\t previous_contexts_.source: {} "
      " "
      "\n\t new_contexts.sink: {} \n\t new_contexts.source: {} \n\t",
      "\n\t new_contexts.sink: {} \n\t new_contexts.source: {} \n\t",
      avail_contexts_.sink.to_string(), avail_contexts_.source.to_string(),
      address_, avail_contexts_.sink.to_string(),
      contexts.sink.to_string(), contexts.source.to_string());
      avail_contexts_.source.to_string(), contexts.sink.to_string(),
      contexts.source.to_string());


  avail_contexts_.sink = contexts.sink;
  avail_contexts_.sink = contexts.sink;
  avail_contexts_.source = contexts.source;
  avail_contexts_.source = contexts.source;