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

Cherry-pick the wifi and thread config related changes on v1.2-branch. #33606

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ namespace NetworkCommissioning {
using namespace DeviceLayer::NetworkCommissioning;

namespace {
// For WiFi and Thread scan results, each item will cose ~60 bytes in TLV, thus 15 is a safe upper bound of scan results.

// For WiFi and Thread scan results, each item will cost ~60 bytes in TLV, thus 15 is a safe upper bound of scan results.
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP || CHIP_DEVICE_CONFIG_ENABLE_THREAD
constexpr size_t kMaxNetworksInScanResponse = 15;
#endif

enum ValidWiFiCredentialLength
{
Expand Down Expand Up @@ -315,6 +318,7 @@ bool CheckFailSafeArmed(CommandHandlerInterface::HandlerContext & ctx)

void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req)
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
MATTER_TRACE_SCOPE("HandleAddOrUpdateWiFiNetwork", "NetworkCommissioning");

VerifyOrReturn(CheckFailSafeArmed(ctx));
Expand Down Expand Up @@ -369,10 +373,13 @@ void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands
{
UpdateBreadcrumb(req.breadcrumb);
}
#endif
}

void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Commands::AddOrUpdateThreadNetwork::DecodableType & req)
{
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD

MATTER_TRACE_SCOPE("HandleAddOrUpdateThreadNetwork", "NetworkCommissioning");

VerifyOrReturn(CheckFailSafeArmed(ctx));
Expand All @@ -392,6 +399,7 @@ void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Comman
{
UpdateBreadcrumb(req.breadcrumb);
}
#endif
}

void Instance::UpdateBreadcrumb(const Optional<uint64_t> & breadcrumb)
Expand Down Expand Up @@ -508,6 +516,7 @@ void Instance::OnResult(Status commissioningError, CharSpan debugText, int32_t i

void Instance::OnFinished(Status status, CharSpan debugText, ThreadScanResponseIterator * networks)
{
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
CHIP_ERROR err = CHIP_NO_ERROR;
auto commandHandleRef = std::move(mAsyncCommandHandle);
auto commandHandle = commandHandleRef.Get();
Expand Down Expand Up @@ -618,10 +627,12 @@ void Instance::OnFinished(Status status, CharSpan debugText, ThreadScanResponseI
CommitSavedBreadcrumb();
}
networks->Release();
#endif
}

void Instance::OnFinished(Status status, CharSpan debugText, WiFiScanResponseIterator * networks)
{
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
CHIP_ERROR err = CHIP_NO_ERROR;
auto commandHandleRef = std::move(mAsyncCommandHandle);
auto commandHandle = commandHandleRef.Get();
Expand Down Expand Up @@ -682,6 +693,7 @@ void Instance::OnFinished(Status status, CharSpan debugText, WiFiScanResponseIte
{
networks->Release();
}
#endif
}

void Instance::OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg)
Expand Down
Loading