Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remaining UCI app config parameters to nocli uwb range start #196

Merged
merged 7 commits into from
Apr 1, 2023

Conversation

corbin-phipps
Copy link
Contributor

@corbin-phipps corbin-phipps commented Apr 1, 2023

Type

  • Bug fix
  • Feature addition
  • Feature update
  • Breaking change
  • Non-functional change
  • Documentation
  • Infrastructure

Goals

This PR adds the remaining UCI app config params to nocli. This includes CLI options, some additional validation (not all), and additional code to print out parameters.

Technical Details

  • Add new CLI options
  • Add to and improve parameter display code in ProcessApplicationConfigurationParameters
  • Add validation for ResultReportConfig
  • Improve GetValueMap()
  • Remove redundant ParameterTypesVariant
  • Update some comments in FiraDevice.hxx

Test Results

nocli output looks correct

Reviewer Focus

Apologies for the long PR, but there are so many UCI app config parameters!

Also, in this line: oss << "0x" << std::setw(2) << std::internal << std::setfill('0') << std::hex << +value << " ";, I had to add "0x" instead of std::showbase because it interferes with std::setw(2) and std::setfill('0'), since the added base is considered part of the width, thus truncating the added 0.

Future Work

Additional validation for the newly added parameters.

I also really don't like how CLI11 adds "UINT" or "ENUM" when displaying the options. Perhaps this can be changed.

Checklist

  • Build target all compiles cleanly.
  • clang-format and clang-tidy deltas produced no new output.
  • Newly added functions include doxygen-style comment block.

@corbin-phipps corbin-phipps requested a review from a team as a code owner April 1, 2023 01:45
@corbin-phipps
Copy link
Contributor Author

Output:
image

@corbin-phipps
Copy link
Contributor Author

image

image

@abeltrano
Copy link
Contributor

I also really don't like how CLI11 adds "UINT" or "ENUM" when displaying the options. Perhaps this can be changed.

💯 I've never liked it.

@abeltrano
Copy link
Contributor

Future Work

I'm also hoping we can make some of the primary parameters positional such that switches don't always need to be provided. This is mostly for commands that only take 1 or 2 arguments.

Copy link
Contributor

@abeltrano abeltrano left a comment

Choose a reason for hiding this comment

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

Thanks for doing this, I know it must have been tedious 😒

@@ -483,6 +545,40 @@ NearObjectCli::AddSubcommandUwbRangeStart(CLI::App* parent)
m_cliData->appConfigParamsData.destinationMacAddresses.value().insert(uwb::UwbMacAddress::FromString(m_cliData->destinationMacAddressString, macAddressType).value());
}

// Parse and validate ResultReportConfig
constexpr int resultReportConfigurationSize = 4; // TODO: Find a way to calculate this number
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
constexpr int resultReportConfigurationSize = 4; // TODO: Find a way to calculate this number
constexpr int resultReportConfigurationSize = magic_enum::enum_count<ResultReportConfig>();

if (IsValidResultReportConfigurationString(m_cliData->resultReportConfigurationString)) {
m_cliData->appConfigParamsData.resultReportConfig.emplace();

const std::bitset<4> resultReportConfigurationBits(m_cliData->resultReportConfigurationString);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be resultReportConfigurationSize instead?

Suggested change
const std::bitset<4> resultReportConfigurationBits(m_cliData->resultReportConfigurationString);
const std::bitset<resultReportConfigurationSize > resultReportConfigurationBits(m_cliData->resultReportConfigurationString);

m_cliData->appConfigParamsData.resultReportConfig.emplace();

const std::bitset<4> resultReportConfigurationBits(m_cliData->resultReportConfigurationString);
if (resultReportConfigurationBits[0]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, std::bitset also has a test() function is does the same thing as the subscript operator here. I like that test() more directly indicates what's being done, but I'm mostly bringing this up for informational purposes. Feel free to close.

@abeltrano abeltrano merged commit 73df7c8 into develop Apr 1, 2023
@corbin-phipps corbin-phipps deleted the user/corbinphipps/add-remaining-params branch April 4, 2023 19:29
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