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

Move session status changed callback from device to session callbacks #309

Merged
merged 8 commits into from
Jun 20, 2023

Conversation

abeltrano
Copy link
Contributor

Type

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

Goals

Simplify registering for session callbacks. The existing logic had the session status changed callback in the device event callbacks. The reasoning was that the UwbDevice would probably need to manage sessions even if the session clients went away. With the Windows WinRT API implementation, this is not done separately in the service and so isn't needed in the underlying library code.

Technical Details

  • Move OnSessionStatusChanged callback from UwbDeviceEventCallbacks to UwbSessionEventCallbacks and associated connector code handling tokens and registered callbacks.
  • Remove code for processing synchronous IOCTL_UWB_NOTIFICATION I/O (both the simulator and UwbCx process everything async, so this was dead code, making notification processing more complex than it needed to be).
  • Changed notification logging to use std::format, reducing some verbosity in both the code and the log messages.
  • Improve and simplify log messages in UwbConnector::HandleNotifications.
  • Add debug output appender to Windows nocli logging configuration, enabling all logs to be forwarded to an attached debugger, if present.

Test Results

Ran some ad-hoc scenarios with the simulator driver and verified there were no regressions.

Reviewer Focus

  • Consider whether any of these changes could negatively affect the UwbCx.

Future Work

  • Convert all other Windows-specific logging code to use std::format and/or std::vformat.
  • Simplify token registration code where the template-foo is extremely complex and probably at least 1 layer of indirection can be eliminated (this is inspired by some recent logs that show certain evens are not being raised correctly despite them being delivered by the driver).

Checklist

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

@abeltrano abeltrano requested a review from a team as a code owner June 19, 2023 23:10
corbin-phipps
corbin-phipps previously approved these changes Jun 19, 2023

plog::init(plog::verbose).addAppender(plog::get<static_cast<int>(LogInstanceId::Console)>()).addAppender(plog::get<static_cast<int>(LogInstanceId::File)>());
plog::init<static_cast<int>(LogInstanceId::Console)>(plog::verbose, &colorConsoleAppender);
plog::init<static_cast<int>(LogInstanceId::File)>(plog::verbose, &rollingFileAppender);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for adding these two additional plog::inits?

Copy link
Contributor Author

@abeltrano abeltrano Jun 20, 2023

Choose a reason for hiding this comment

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

They were there previously, just moved to be declared together with other statics. The one that was added is the DebugOutputAppender. That will forward log data to the debugger window, if a debugger is attached. It's really useful when you're using the debugger and want to see things in realtime as opposed to setting up ETW logging separately.

@abeltrano abeltrano dismissed corbin-phipps’s stale review June 20, 2023 02:24

The merge-base changed after approval.

@abeltrano abeltrano merged commit b97a2e2 into develop Jun 20, 2023
5 of 6 checks passed
@abeltrano abeltrano deleted the simplifycallbacks branch June 20, 2023 02: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