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

Root endpoint with Wifi support; Wifi NW diagnostics cluster #169

Merged
merged 1 commit into from
May 25, 2024

Conversation

ivmarkov
Copy link
Contributor

@ivmarkov ivmarkov commented May 22, 2024

(A follow up on #167 , as promised there.)

  • This PR provides extra types for the Root endpoint which are generified by the type of operational network.
  • It also provides a simple implementation of the Wifi NW Diagnostics cluster (next to the existing Eth NW diagnostics one)

The existing types/struct which were actually hard-coded for Ethernet are now type-aliased / delegate to the new types and are renamed as follows:

  • root_endpont::CLUSTERS -> root_endpoint::ETH_CLUSTERS (and there's also WIFI_CLUSTERS now)
  • root_endpoint::endpoint takes an extra parameter - OperNwType
  • RootEndpointHandler type -> EthRootEndpointHandler type, and there is a newly-introduced RootEndpointHandler which is generified by NWCOMM and NWDIAG
  • root_endpoint::handler -> root_endpoint::eth_handler. Here also, newly introduced more generic root_endpoint::handler fn which takes extra parameters

... Looking at the "on off" example actually shows the API-visible changes. Minor breakage to backward compatibility - users just need to prefix a few things with eth_ now.

@ivmarkov ivmarkov requested review from kedars and andy31415 May 22, 2024 17:07
/// The type of operational network (Ethernet, Wifi or (future) Thread)
/// for which root endpoint meta-data is being requested
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum OperNwType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there precedent on naming? In other projects I was generally advised by styling guides to optimize readability even if typing speed slows down (and autocomplete helps anyway). Should we consider naming this OperationalNetworkType to fully expand things?

Copy link
Contributor Author

@ivmarkov ivmarkov May 22, 2024

Choose a reason for hiding this comment

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

I can change it in the blink of an eye, but then... I'm not so sure it is back or white:
Spelling things out is a hard Java rule (from where I'm coming from); status quo in Rust seems a bit different, in that abbreviations are seen quite more often - from keywords to type names.

I also tried to match the naming rules "around" the new name I introduce. For better or worse, the code around that type contained "Nw" (not "Network"). And "Eth". And quite a few other abbreviations. The initial name btw was OperationalNwType but it looks silly to abbreviate the shorter word (network), and keep "operational" spelled out. So I shortened them both.

If that is not convincing - I can still change it though. Just wanted to show a bit that I had similar doubts, even if I decided completely the opposite of what your doubts are hinting you. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

The Nw is what tripped me up ... kept reading it as North-west.

Java is overly verbose, but also https://google.github.io/styleguide/cppguide.html#General_Naming_Rules says to not try to save horizontal space.

Not a PR blocker though ... if Nw is used in other places (I did not know that) it seems consistency is reasonable. Will approve things either way - feel free to change or close this thread as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Outside of the scope of this PR (due to seemingly mass renames), https://www.abbreviations.com/abbreviation/Network seems to say that we should use Net or Ntwrk or NetWk ... seems heavily biased to Net

https://www.allacronyms.com/network/abbreviated has NW appearing, but also heavily biased on Net

@ivmarkov
Copy link
Contributor Author

ivmarkov commented May 25, 2024

I've now opened this as I feel that rather than fixing stuff "on the spot" (and thus maybe actually introducing even more inconsistencies), we should have an ongoing task to fix our abbreviations throughout the code base.

@ivmarkov ivmarkov merged commit 636591a into project-chip:main May 25, 2024
12 checks passed
ivmarkov added a commit to ivmarkov/rs-matter that referenced this pull request Jun 5, 2024
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