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

[nrf noup] fix various issues with Network Commissioning cluster on Wi-Fi #404

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

LuDuda
Copy link
Collaborator

@LuDuda LuDuda commented Mar 7, 2024

This PR fixes few issues with Network Commissioning cluster on Wi-Fi platform.

Please review commit by commit.

[nrf noup] Fix handling of LastNetworkID in Wi-Fi driver
This commit ensures that LastNetworkID attribute is not null, not only after ConnectNetwork command is issued, but also in case the connection is established after resboot or after connection is lost.

[1709852472.587357][369591:369593] CHIP:TOO: LastNetworkID: 536368726F64696E676572205761766573203547

[nrf noup] Do not clear Last Network ID and Connection Error after scan
This bug is already fixed upstream for Matter 1.3. This fixes the issue where LastNetworkID attribute is cleared after ScanNetworks command is completed.

[nrf noup] Fix various Wi-Fi issues with error code handling
This commit handles a few issues with Wi-Fi connection or scanning:

  • Use wifi_status structure instead of incompatible WiFiRequestStatus
  • On connect error value > 2 do not report success*
  • On scan error value > 1 do not report success
  • Provide value of mandatory LastConnectErrorValue attribute

*This is especially critical.

This commit makes sure that correct Network ID is provided to the
Network Commissioning cluster from the platform's Wi-Fi driver.

Signed-off-by: Łukasz Duda <[email protected]>
@LuDuda LuDuda added the bug Something isn't working label Mar 7, 2024
@LuDuda LuDuda added this to the 2.6.0 milestone Mar 7, 2024
Copy link
Contributor

@markaj-nordic markaj-nordic left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks.

mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, NullOptional, NullOptional);
WiFiManager::WiFiInfo wifiInfo;

if (CHIP_NO_ERROR == WiFiManager::Instance().GetWiFiInfo(wifiInfo))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we fallback to NullOptional in case the GetWiFiInfo() fails for whatever reason?

Copy link
Collaborator Author

@LuDuda LuDuda Mar 7, 2024

Choose a reason for hiding this comment

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

This might be okay, however I'm not sure. I see that in all 15 platforms, some NetworkID is used, or OnNetworkingStatusChange is skipped.

Copy link
Contributor

Choose a reason for hiding this comment

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

GetWiFiInfo only succeeds when the connection attempt succeeded. Shouldn't we rather add a getter for mWantedNetwork to obtain the network ID used in the last failed attempt 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.

But don't we support only one network anyway? If the last connection failed then we can't interact with the device anyway, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, but the connection may also fail during commissioning.

Copy link
Contributor

Choose a reason for hiding this comment

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

discussed f2f, will be fixed later as it's not vital for now.

This commit fixes the issue where ScanComplete event cleared the
attribute values for connection status.

This commit should be reverted and replaced by Matter 1.3 revision where
the network commissioning cluster has been rewritten.

Signed-off-by: Łukasz Duda <[email protected]>
@github-actions github-actions bot added the app label Mar 7, 2024
This commit handles a few issues with Wi-Fi connection or scanning:
 - Use wifi_status structure instead of incompatible WiFiRequestStatus
 - On connect error value > 2 do not report success
 - On scan error value > 1 do not report success
 - Provide value of mandatory LastConnectErrorValue attribute

Signed-off-by: Łukasz Duda <[email protected]>
@LuDuda LuDuda force-pushed the pr/fix-last-network-id branch from 087b105 to 5b97b18 Compare March 7, 2024 23:24
@LuDuda LuDuda changed the title [nrf noup] fix handling of LastNetworkID in Wi-Fi driver [nrf noup] fix various issues with Network Commissioning cluster on Wi-Fi Mar 7, 2024
Copy link
Contributor

@Damian-Nordic Damian-Nordic left a comment

Choose a reason for hiding this comment

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

It's definitely better than it was before so approving but added a few suggestions for future improvements :)

mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, NullOptional, NullOptional);
WiFiManager::WiFiInfo wifiInfo;

if (CHIP_NO_ERROR == WiFiManager::Instance().GetWiFiInfo(wifiInfo))
Copy link
Contributor

Choose a reason for hiding this comment

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

GetWiFiInfo only succeeds when the connection attempt succeeded. Shouldn't we rather add a getter for mWantedNetwork to obtain the network ID used in the last failed attempt as well?

@markaj-nordic markaj-nordic merged commit 1e9f9b2 into nrfconnect:master Mar 8, 2024
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants