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

[NWPROV] Fix spec compliance issues #17038

Conversation

erjiaqing
Copy link
Contributor

@erjiaqing erjiaqing commented Apr 5, 2022

Problem

Fixes #17010

Some definitions in network commissioning cluster does not match the spec

Change overview

  • Update the xml and the code
  • Apply some trivial changes to platform code

Testing

Build should pass.

@tcarmelveilleux tcarmelveilleux merged commit fae3888 into project-chip:master Apr 5, 2022
Comment on lines +85 to +86
using ClusterObject = NetworkCommissioning::WiFiSecurity;
using PlatformInterface = NetworkCommissioning::WiFiSecurity;
Copy link
Contributor

Choose a reason for hiding this comment

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

These are the same type, so the asserts below are trivially going to pass.

What I would suggests is that we get rid of DeviceLayer::NetworkCommissioning::WiFiSecurity and include cluster-enums.h in the relevant places so we can use Clusters::NetworkCommissioning::WiFiSecurity directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is discuessed before, and we want to avoid using cluster-enums in platform code.

Copy link
Contributor

Choose a reason for hiding this comment

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

cluster-enums was specifically created so it can be used in platform code. Not to be confused with non-ABI-stable cluster-objects.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 cluster-enums.h is usable in platform layer and was introduced to avoid this

if (!nullableSSID.IsNull())
{
ssid = nullableSSID.Value();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should enforce the "1 to 32" length constraint from the spec.

mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler);
mpDriver.Get<WiFiDriver *>()->ScanNetworks(req.ssid, this);
mpDriver.Get<WiFiDriver *>()->ScanNetworks(ssid, this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, the driver interface is not documented very well, so the implementations of it differ in how they handle the SSID. For example, src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp checks ssid.data() to decide whether we're doing a single-ssid scan or general scan, while src/platform/EFR32/NetworkCommissioningWiFiDriver.cpp checks ssid.size(). If we checked the size here the difference would at least not be observable, but as it is they would reply differently to the same protocol message.

My recommendation would be to change the driver API to have separate functions for "scan for networks with the given SSID" and "scan for all networks" so the only place where we have to make that decision is here.

Copy link
Contributor

Choose a reason for hiding this comment

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

#17060 filed on this

memcpy(mLastNetworkID, mConnectingNetworkID, mLastNetworkIDLen);
mLastNetworkingStatusValue.SetNonNull(ToClusterObjectEnum(commissioningError));

if (debugText.size() != 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be using empty(), really.


SuccessOrExit(err = commandHandle->PrepareCommand(
ConcreteCommandPath(mPath.mEndpointId, NetworkCommissioning::Id, Commands::ScanNetworksResponse::Id)));
VerifyOrExit((writer = commandHandle->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);

SuccessOrExit(err = writer->Put(TLV::ContextTag(to_underlying(Commands::ScanNetworksResponse::Fields::kNetworkingStatus)),
ToClusterObjectEnum(status)));
SuccessOrExit(err = DataModel::Encode(
*writer, TLV::ContextTag(to_underlying(Commands::ScanNetworksResponse::Fields::kDebugText)), debugText));
if (debugText.size() != 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

empty().

@@ -436,28 +468,33 @@ void Instance::OnFinished(Status status, CharSpan debugText, ThreadScanResponseI
TLV::TLVType listContainerType;
ThreadScanResponse scanResponse;
size_t networksEncoded = 0;
uint8_t extendedAddressBuffer[8];
Copy link
Contributor

Choose a reason for hiding this comment

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

That 8 should be a constant defined somewhere. I would be very surprised if we do not have a constant for this already.

chencheung pushed a commit to chencheung/connectedhomeip that referenced this pull request Apr 6, 2022
* Fix spec compliance of network commissioning cluster

* Update existing platform code

* Run Codegen
chencheung pushed a commit to chencheung/connectedhomeip that referenced this pull request Apr 6, 2022
* Fix spec compliance of network commissioning cluster

* Update existing platform code

* Run Codegen
erjiaqing added a commit to erjiaqing/connectedhomeip that referenced this pull request Apr 7, 2022
erjiaqing added a commit to erjiaqing/connectedhomeip that referenced this pull request Apr 8, 2022
erjiaqing added a commit to erjiaqing/connectedhomeip that referenced this pull request Apr 8, 2022
erjiaqing added a commit to erjiaqing/connectedhomeip that referenced this pull request Apr 8, 2022
erjiaqing added a commit that referenced this pull request Apr 14, 2022
* [nwprov] Resolve comments in #17038 add more checks

* Remove enums in include/platform/NetworkCommissioning.h use ssid.empty() instead of ssid.size()

* Fix template

* Regen
andrei-menzopol pushed a commit to andrei-menzopol/connectedhomeip that referenced this pull request Apr 14, 2022
* Fix spec compliance of network commissioning cluster

* Update existing platform code

* Run Codegen
andrei-menzopol pushed a commit to andrei-menzopol/connectedhomeip that referenced this pull request Apr 14, 2022
…ect-chip#17197)

* [nwprov] Resolve comments in project-chip#17038 add more checks

* Remove enums in include/platform/NetworkCommissioning.h use ssid.empty() instead of ssid.size()

* Fix template

* Regen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Network Commissioning cluster has many subtle spec deviations due to non-spec XML
5 participants