Skip to content

Follow mode (-f) re-prints cached results instead of re-querying #585

Description

@Sapd

-f / --follow re-prints the first result instead of re-querying the device.

initializeFeatureRequests() runs before the loop, and processFeatureRequests() only executes requests still marked FEATURE_NOT_PROCESSED:

// cli/main.cpp
if (req.should_process && req.result.status == FEATURE_NOT_PROCESSED) {
    req.result = handleFeature(dev, req.cap, req.param);
}

After the first iteration every request is FEATURE_SUCCESS / FEATURE_INFO, so iterations 2..N skip handleFeature() entirely and output() prints the cached result again. Nothing in the do/while resets the status.

So headsetcontrol -f -b shows the same battery level forever. The test device hides it because it returns a constant 42%.

Present in 4.0.0 and 4.1.0.

Fix is to reset req.result.status to FEATURE_NOT_PROCESSED at the top of each iteration - but only for the requests that were genuinely processable, since handleMultiDeviceActions() deliberately sets that same status to mean "refused, multiple devices". That distinction needs a separate flag or the reset has to skip requests it neutralised.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions