Skip to content

REFPLTV-3050: when there is no supported RCU models in configuration, no need to startPairing#183

Open
arun-madhavan-013 wants to merge 1 commit intodevelopfrom
feature/REFPLTV-3050-high-cpu-utilization
Open

REFPLTV-3050: when there is no supported RCU models in configuration, no need to startPairing#183
arun-madhavan-013 wants to merge 1 commit intodevelopfrom
feature/REFPLTV-3050-high-cpu-utilization

Conversation

@arun-madhavan-013
Copy link

Without this it is causing 95%+ CPU utilization

Copilot AI review requested due to automatic review settings March 4, 2026 16:49
@arun-madhavan-013 arun-madhavan-013 requested a review from a team as a code owner March 4, 2026 16:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent BLE auto-pairing from starting when there are no configured/supported RCU models, which (per description) can otherwise lead to very high CPU utilization.

Changes:

  • Add a guard in startPairingAutoWithTimeout() to fail early when no RCU models are configured, setting m_lastError and logging a warning.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +203 to +207
if (m_config->modelSettings().empty()) {
m_lastError = BleRcuError(BleRcuError::General, "No BLE RCU models configured");
XLOGD_WARN("cannot start BLE auto pairing - no RCU models configured");
return false;
}
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard only checks whether modelSettings() is empty, but "no supported models" can also occur when the config contains only disabled models (see ConfigModelSettings::disabled() and the pairing state machine filtering out disabled models). In that case auto-pairing would still start with an empty supported-name list. Consider checking for at least one enabled model (e.g., any_of(models, !disabled)) and failing if none are enabled.

Copilot uses AI. Check for mistakes.
Comment on lines +203 to 211
if (m_config->modelSettings().empty()) {
m_lastError = BleRcuError(BleRcuError::General, "No BLE RCU models configured");
XLOGD_WARN("cannot start BLE auto pairing - no RCU models configured");
return false;
}

// check we're not currently pairing
if (m_pairingStateMachine.isRunning()) {
m_lastError = BleRcuError(BleRcuError::General, "currently performing pairing, cannot start new scan");
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new early-return runs before the existing m_pairingStateMachine.isRunning() check. If auto-pair is requested while another pairing operation is already running, callers will now see a config error instead of the expected "busy" error. Consider keeping the busy check first (or otherwise ensuring the reported error prioritizes the in-progress operation).

Copilot uses AI. Check for mistakes.
{
m_ignorePairingFailure = false;

if (m_config->modelSettings().empty()) {
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfigSettings::modelSettings() returns the vector by value, so calling m_config->modelSettings().empty() copies the entire model list just to check emptiness. If this path can be hit repeatedly, consider caching the returned vector in a local variable (or adding a cheap hasModelSettings() / const-ref accessor on ConfigSettings).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants