Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and tcarmelveilleux committed Feb 15, 2024
1 parent 4fbe075 commit 5775cd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
24 changes: 15 additions & 9 deletions src/app/clusters/network-commissioning/network-commissioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ Instance::Instance(EndpointId aEndpointId, WiFiDriver * apDelegate) :

Instance::Instance(EndpointId aEndpointId, ThreadDriver * apDelegate) :
CommandHandlerInterface(Optional<EndpointId>(aEndpointId), Id), AttributeAccessInterface(Optional<EndpointId>(aEndpointId), Id),
mEndpointId(aEndpointId), mFeatureFlags(Feature::kThreadNetworkInterface), mpWirelessDriver(apDelegate), mpBaseDriver(apDelegate)
mEndpointId(aEndpointId), mFeatureFlags(Feature::kThreadNetworkInterface), mpWirelessDriver(apDelegate),
mpBaseDriver(apDelegate)
{
mpDriver.Set<ThreadDriver *>(apDelegate);
}
Expand Down Expand Up @@ -174,32 +175,36 @@ void Instance::SetLastNetworkingStatusValue(Attributes::LastNetworkingStatus::Ty
{
if (mLastNetworkingStatusValue.SetToMatch(networkingStatusValue))
{
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id, Attributes::LastNetworkingStatus::TypeInfo::GetAttributeId());
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id,
Attributes::LastNetworkingStatus::TypeInfo::GetAttributeId());
}
}

void Instance::SetLastConnectErrorValue(Attributes::LastConnectErrorValue::TypeInfo::Type connectErrorValue)
{
if (mLastConnectErrorValue.SetToMatch(connectErrorValue))
{
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id, Attributes::LastConnectErrorValue::TypeInfo::GetAttributeId());
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id,
Attributes::LastConnectErrorValue::TypeInfo::GetAttributeId());
}
}

void Instance::SetLastNetworkId(ByteSpan lastNetworkId)
{
ByteSpan prevLastNetworkId{mLastNetworkID, mLastNetworkIDLen};
ByteSpan prevLastNetworkId{ mLastNetworkID, mLastNetworkIDLen };
VerifyOrReturn(lastNetworkId.size() <= kMaxNetworkIDLen);
VerifyOrReturn(!prevLastNetworkId.data_equal(lastNetworkId));

memcpy(mLastNetworkID, lastNetworkId.data(), lastNetworkId.size());
mLastNetworkIDLen = static_cast<uint8_t>(lastNetworkId.size());
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id, Attributes::LastNetworkID::TypeInfo::GetAttributeId());
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id,
Attributes::LastNetworkID::TypeInfo::GetAttributeId());
}

void Instance::ReportNetworksListChanged() const
{
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id, Attributes::Networks::TypeInfo::GetAttributeId());
MatterReportingAttributeChangeCallback(mEndpointId, Clusters::NetworkCommissioning::Id,
Attributes::Networks::TypeInfo::GetAttributeId());
}

void Instance::InvokeCommand(HandlerContext & ctxt)
Expand Down Expand Up @@ -478,7 +483,7 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw
return;
}

mScanningWasDirected = !ssid.empty();
mScanningWasDirected = !ssid.empty();
mCurrentOperationBreadcrumb = req.breadcrumb;
mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler);
ctx.mCommandHandler.FlushAcksRightAwayOnSlowCommand();
Expand Down Expand Up @@ -948,7 +953,7 @@ void Instance::OnResult(Status commissioningError, CharSpan debugText, int32_t i
SetLastConnectErrorValue(MakeNullable(interfaceStatus));
}

SetLastNetworkId(ByteSpan{mConnectingNetworkID, mConnectingNetworkIDLen});
SetLastNetworkId(ByteSpan{ mConnectingNetworkID, mConnectingNetworkIDLen });
SetLastNetworkingStatusValue(MakeNullable(commissioningError));

#if CONFIG_NETWORK_LAYER_BLE && !CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION
Expand Down Expand Up @@ -1124,7 +1129,8 @@ void Instance::OnFinished(Status status, CharSpan debugText, WiFiScanResponseIte
// Only encode results on success, to avoid stale contents on partial failure.
if (status == Status::kSuccess)
{
for (; networks != nullptr && networks->Next(scanResponse) && networksEncoded < kMaxNetworksInScanResponse; networksEncoded++)
for (; networks != nullptr && networks->Next(scanResponse) && networksEncoded < kMaxNetworksInScanResponse;
networksEncoded++)
{
Structs::WiFiInterfaceScanResultStruct::Type result;
result.security = scanResponse.security;
Expand Down
2 changes: 1 addition & 1 deletion src/app/data-model/Nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct Nullable : protected Optional<T>
constexpr bool SetToMatch(const Nullable<T> & other)
{
bool changed = *this != other;
*this = other;
*this = other;
return changed;
}

Expand Down
12 changes: 5 additions & 7 deletions src/app/tests/TestNullable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ static void TestSetToMatch(nlTestSuite * inSuite, void * inContext)
using SmallArray = std::array<uint8_t, 3>;
// Arrays
{
auto nullable1 = MakeNullable<SmallArray>({1,2,3});
auto nullable2 = MakeNullable<SmallArray>({1,2,3});
auto nullable1 = MakeNullable<SmallArray>({ 1, 2, 3 });
auto nullable2 = MakeNullable<SmallArray>({ 1, 2, 3 });

NL_TEST_ASSERT(inSuite, !nullable1.IsNull());
NL_TEST_ASSERT(inSuite, !nullable2.IsNull());
Expand All @@ -209,13 +209,11 @@ static void TestSetToMatch(nlTestSuite * inSuite, void * inContext)
uint8_t a;
uint8_t b;

bool operator==(const SomeObject & other) const {
return (a == other.a) && (b == other.b);
}
bool operator==(const SomeObject & other) const { return (a == other.a) && (b == other.b); }
};

auto nullable1 = MakeNullable<SomeObject>({1, 2});
auto nullable2 = MakeNullable<SomeObject>({1, 2});
auto nullable1 = MakeNullable<SomeObject>({ 1, 2 });
auto nullable2 = MakeNullable<SomeObject>({ 1, 2 });

NL_TEST_ASSERT(inSuite, !nullable1.IsNull());
NL_TEST_ASSERT(inSuite, !nullable2.IsNull());
Expand Down

0 comments on commit 5775cd6

Please sign in to comment.