Skip to content

Commit 03b57a4

Browse files
authored
Merge branch 'master' into system-pigweed
2 parents dcf25e2 + 8823bd9 commit 03b57a4

File tree

122 files changed

+1184
-5191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1184
-5191
lines changed

.github/workflows/qemu.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ jobs:
6060
build \
6161
"
6262
- name: Run all tests
63-
# Disabled being tracked here: https://github.com/project-chip/connectedhomeip/issues/32587
64-
if: false
6563
run: |
6664
src/test_driver/esp32/run_qemu_image.py \
6765
--verbose \

docs/tools/index.md

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Source files for these tools are located at `scripts/tools`.
2828
2929
../scripts/tools/memory/README
3030
../scripts/tools/spake2p/README
31-
../src/tools/interop/idt/README
3231
3332
```
3433

examples/platform/nxp/common/app_task/source/AppTaskBase.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
#include <app/clusters/ota-requestor/OTATestEventTriggerDelegate.h>
6363
#endif
6464

65+
#ifdef ENABLE_CHIP_SHELL
66+
#include <lib/shell/commands/WiFi.h>
67+
#endif
68+
6569
using namespace chip;
6670
using namespace chip::TLV;
6771
using namespace ::chip::Credentials;
@@ -202,6 +206,9 @@ CHIP_ERROR chip::NXP::App::AppTaskBase::Init()
202206

203207
#if CONFIG_CHIP_WIFI || CHIP_DEVICE_CONFIG_ENABLE_WPA
204208
sNetworkCommissioningInstance.Init();
209+
#ifdef ENABLE_CHIP_SHELL
210+
Shell::SetWiFiDriver(chip::NXP::App::GetAppTask().GetWifiDriverInstance());
211+
#endif
205212
#endif
206213
#if CONFIG_CHIP_OTA_REQUESTOR
207214
if (err == CHIP_NO_ERROR)

scripts/examples/gn_silabs_example.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ else
193193
shift
194194
;;
195195
--icd)
196-
optArgs+="chip_enable_icd_server=true chip_openthread_ftd=false sl_enable_test_event_trigger=true"
196+
optArgs+="chip_enable_icd_server=true chip_openthread_ftd=false sl_enable_test_event_trigger=true "
197197
shift
198198
;;
199199
--low-power)

scripts/setup/requirements.nxp.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jsonschema>=4.17.0
2+
pycrypto>=2.6.1
3+
pycryptodome>=3.20.0

src/app/CommandHandler.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ CHIP_ERROR CommandHandler::ValidateInvokeRequestMessageAndBuildRegistry(InvokeRe
158158

159159
// Grab the CommandRef if there is one, and validate that it's there when it
160160
// has to be.
161-
Optional<uint16_t> commandRef;
161+
std::optional<uint16_t> commandRef;
162162
uint16_t ref;
163163
err = commandData.GetRef(&ref);
164164
VerifyOrReturnError(err == CHIP_NO_ERROR || err == CHIP_END_OF_TLV, err);
@@ -168,7 +168,7 @@ CHIP_ERROR CommandHandler::ValidateInvokeRequestMessageAndBuildRegistry(InvokeRe
168168
}
169169
if (err == CHIP_NO_ERROR)
170170
{
171-
commandRef.SetValue(ref);
171+
commandRef.emplace(ref);
172172
}
173173

174174
// Adding can fail if concretePath is not unique, or if commandRef is a value
@@ -590,10 +590,9 @@ CHIP_ERROR CommandHandler::PrepareInvokeResponseCommand(const ConcreteCommandPat
590590
const CommandHandler::InvokeResponseParameters & aPrepareParameters)
591591
{
592592
auto commandPathRegistryEntry = GetCommandPathRegistry().Find(aPrepareParameters.mRequestCommandPath);
593-
VerifyOrReturnValue(commandPathRegistryEntry.HasValue(), CHIP_ERROR_INCORRECT_STATE);
593+
VerifyOrReturnValue(commandPathRegistryEntry.has_value(), CHIP_ERROR_INCORRECT_STATE);
594594

595-
return PrepareInvokeResponseCommand(commandPathRegistryEntry.Value(), aResponseCommandPath,
596-
aPrepareParameters.mStartOrEndDataStruct);
595+
return PrepareInvokeResponseCommand(*commandPathRegistryEntry, aResponseCommandPath, aPrepareParameters.mStartOrEndDataStruct);
597596
}
598597

599598
CHIP_ERROR CommandHandler::PrepareCommand(const ConcreteCommandPath & aResponseCommandPath, bool aStartDataStruct)
@@ -610,9 +609,9 @@ CHIP_ERROR CommandHandler::PrepareCommand(const ConcreteCommandPath & aResponseC
610609
"Seemingly device supports batch commands, but is calling the deprecated PrepareCommand API");
611610

612611
auto commandPathRegistryEntry = GetCommandPathRegistry().GetFirstEntry();
613-
VerifyOrReturnValue(commandPathRegistryEntry.HasValue(), CHIP_ERROR_INCORRECT_STATE);
612+
VerifyOrReturnValue(commandPathRegistryEntry.has_value(), CHIP_ERROR_INCORRECT_STATE);
614613

615-
return PrepareInvokeResponseCommand(commandPathRegistryEntry.Value(), aResponseCommandPath, aStartDataStruct);
614+
return PrepareInvokeResponseCommand(*commandPathRegistryEntry, aResponseCommandPath, aStartDataStruct);
616615
}
617616

618617
CHIP_ERROR CommandHandler::PrepareInvokeResponseCommand(const CommandPathRegistryEntry & apCommandPathRegistryEntry,
@@ -675,9 +674,9 @@ CHIP_ERROR CommandHandler::FinishCommand(bool aStartDataStruct)
675674
ReturnErrorOnFailure(commandData.GetWriter()->EndContainer(mDataElementContainerType));
676675
}
677676

678-
if (mRefForResponse.HasValue())
677+
if (mRefForResponse.has_value())
679678
{
680-
ReturnErrorOnFailure(commandData.Ref(mRefForResponse.Value()));
679+
ReturnErrorOnFailure(commandData.Ref(*mRefForResponse));
681680
}
682681

683682
ReturnErrorOnFailure(commandData.EndOfCommandDataIB());
@@ -699,8 +698,8 @@ CHIP_ERROR CommandHandler::PrepareStatus(const ConcreteCommandPath & aCommandPat
699698
}
700699

701700
auto commandPathRegistryEntry = GetCommandPathRegistry().Find(aCommandPath);
702-
VerifyOrReturnError(commandPathRegistryEntry.HasValue(), CHIP_ERROR_INCORRECT_STATE);
703-
mRefForResponse = commandPathRegistryEntry.Value().ref;
701+
VerifyOrReturnError(commandPathRegistryEntry.has_value(), CHIP_ERROR_INCORRECT_STATE);
702+
mRefForResponse = commandPathRegistryEntry->ref;
704703

705704
MoveToState(State::Preparing);
706705
InvokeResponseIBs::Builder & invokeResponses = mInvokeResponseBuilder.GetInvokeResponses();
@@ -720,9 +719,9 @@ CHIP_ERROR CommandHandler::FinishStatus()
720719
VerifyOrReturnError(mState == State::AddingCommand, CHIP_ERROR_INCORRECT_STATE);
721720

722721
CommandStatusIB::Builder & commandStatus = mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetStatus();
723-
if (mRefForResponse.HasValue())
722+
if (mRefForResponse.has_value())
724723
{
725-
ReturnErrorOnFailure(commandStatus.Ref(mRefForResponse.Value()));
724+
ReturnErrorOnFailure(commandStatus.Ref(*mRefForResponse));
726725
}
727726

728727
ReturnErrorOnFailure(mInvokeResponseBuilder.GetInvokeResponses().GetInvokeResponse().GetStatus().EndOfCommandStatusIB());

src/app/CommandHandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ class CommandHandler
686686
// TODO Allow flexibility in registration.
687687
BasicCommandPathRegistry<CHIP_CONFIG_MAX_PATHS_PER_INVOKE> mBasicCommandPathRegistry;
688688
CommandPathRegistry * mCommandPathRegistry = &mBasicCommandPathRegistry;
689-
Optional<uint16_t> mRefForResponse;
689+
std::optional<uint16_t> mRefForResponse;
690690

691691
CommandHandlerExchangeInterface * mpResponder = nullptr;
692692

src/app/CommandPathRegistry.h

+15-13
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,27 @@
2424
#include <lib/core/CHIPError.h>
2525
#include <lib/core/Optional.h>
2626

27+
#include <optional>
28+
2729
namespace chip {
2830
namespace app {
2931

3032
struct CommandPathRegistryEntry
3133
{
3234
ConcreteCommandPath requestPath = ConcreteCommandPath(0, 0, 0);
33-
Optional<uint16_t> ref;
35+
std::optional<uint16_t> ref;
3436
};
3537

3638
class CommandPathRegistry
3739
{
3840
public:
3941
virtual ~CommandPathRegistry() = default;
4042

41-
virtual Optional<CommandPathRegistryEntry> Find(const ConcreteCommandPath & requestPath) const = 0;
42-
virtual Optional<CommandPathRegistryEntry> GetFirstEntry() const = 0;
43-
virtual CHIP_ERROR Add(const ConcreteCommandPath & requestPath, const Optional<uint16_t> & ref) = 0;
44-
virtual size_t Count() const = 0;
45-
virtual size_t MaxSize() const = 0;
43+
virtual std::optional<CommandPathRegistryEntry> Find(const ConcreteCommandPath & requestPath) const = 0;
44+
virtual std::optional<CommandPathRegistryEntry> GetFirstEntry() const = 0;
45+
virtual CHIP_ERROR Add(const ConcreteCommandPath & requestPath, const std::optional<uint16_t> & ref) = 0;
46+
virtual size_t Count() const = 0;
47+
virtual size_t MaxSize() const = 0;
4648
};
4749

4850
/**
@@ -59,28 +61,28 @@ template <size_t N>
5961
class BasicCommandPathRegistry : public CommandPathRegistry
6062
{
6163
public:
62-
Optional<CommandPathRegistryEntry> Find(const ConcreteCommandPath & requestPath) const override
64+
std::optional<CommandPathRegistryEntry> Find(const ConcreteCommandPath & requestPath) const override
6365
{
6466
for (size_t i = 0; i < mCount; i++)
6567
{
6668
if (mTable[i].requestPath == requestPath)
6769
{
68-
return MakeOptional(mTable[i]);
70+
return std::make_optional(mTable[i]);
6971
}
7072
}
71-
return NullOptional;
73+
return std::nullopt;
7274
}
7375

74-
Optional<CommandPathRegistryEntry> GetFirstEntry() const override
76+
std::optional<CommandPathRegistryEntry> GetFirstEntry() const override
7577
{
7678
if (mCount > 0)
7779
{
78-
return MakeOptional(mTable[0]);
80+
return std::make_optional(mTable[0]);
7981
}
80-
return NullOptional;
82+
return std::nullopt;
8183
}
8284

83-
CHIP_ERROR Add(const ConcreteCommandPath & requestPath, const Optional<uint16_t> & ref) override
85+
CHIP_ERROR Add(const ConcreteCommandPath & requestPath, const std::optional<uint16_t> & ref) override
8486
{
8587
if (mCount >= N)
8688
{

src/app/tests/TestBasicCommandPathRegistry.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ void TestAddingSameConcretePath(nlTestSuite * apSuite, void * apContext)
3636
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
3737

3838
ConcreteCommandPath concretePath(0, 0, 0);
39-
Optional<uint16_t> commandRef;
39+
std::optional<uint16_t> commandRef;
4040
uint16_t commandRefValue = 0;
4141

4242
size_t idx = 0;
4343
for (idx = 0; idx < kQuickTestSize && err == CHIP_NO_ERROR; idx++)
4444
{
45-
commandRef.SetValue(commandRefValue);
45+
commandRef.emplace(commandRefValue);
4646
commandRefValue++;
4747
err = basicCommandPathRegistry.Add(concretePath, commandRef);
4848
}
@@ -56,8 +56,8 @@ void TestAddingSameCommandRef(nlTestSuite * apSuite, void * apContext)
5656
CHIP_ERROR err = CHIP_NO_ERROR;
5757
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
5858

59-
Optional<uint16_t> commandRef;
60-
commandRef.SetValue(0);
59+
std::optional<uint16_t> commandRef;
60+
commandRef.emplace(0);
6161

6262
uint16_t endpointValue = 0;
6363

@@ -78,14 +78,14 @@ void TestAddingMaxNumberOfEntries(nlTestSuite * apSuite, void * apContext)
7878
CHIP_ERROR err = CHIP_NO_ERROR;
7979
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
8080

81-
Optional<uint16_t> commandRef;
81+
std::optional<uint16_t> commandRef;
8282
uint16_t commandRefAndEndpointValue = 0;
8383

8484
size_t idx = 0;
8585
for (idx = 0; idx < kQuickTestSize && err == CHIP_NO_ERROR; idx++)
8686
{
8787
ConcreteCommandPath concretePath(commandRefAndEndpointValue, 0, 0);
88-
commandRef.SetValue(commandRefAndEndpointValue);
88+
commandRef.emplace(commandRefAndEndpointValue);
8989
commandRefAndEndpointValue++;
9090
err = basicCommandPathRegistry.Add(concretePath, commandRef);
9191
}
@@ -100,14 +100,14 @@ void TestAddingTooManyEntries(nlTestSuite * apSuite, void * apContext)
100100
BasicCommandPathRegistry<kQuickTestSize> basicCommandPathRegistry;
101101
size_t maxPlusOne = kQuickTestSize + 1;
102102

103-
Optional<uint16_t> commandRef;
103+
std::optional<uint16_t> commandRef;
104104
uint16_t commandRefAndEndpointValue = 0;
105105

106106
size_t idx = 0;
107107
for (idx = 0; idx < maxPlusOne && err == CHIP_NO_ERROR; idx++)
108108
{
109109
ConcreteCommandPath concretePath(commandRefAndEndpointValue, 0, 0);
110-
commandRef.SetValue(commandRefAndEndpointValue);
110+
commandRef.emplace(commandRefAndEndpointValue);
111111
commandRefAndEndpointValue++;
112112
err = basicCommandPathRegistry.Add(concretePath, commandRef);
113113
}

src/app/tests/TestCommandInteraction.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <messaging/ExchangeContext.h>
4141
#include <messaging/ExchangeMgr.h>
4242
#include <messaging/Flags.h>
43+
#include <optional>
4344
#include <platform/CHIPDeviceLayer.h>
4445
#include <protocols/interaction_model/Constants.h>
4546
#include <system/SystemPacketBuffer.h>
@@ -392,7 +393,7 @@ class TestCommandInteraction
392393
const Optional<uint16_t> & aRef) :
393394
CommandHandler(apCallback)
394395
{
395-
GetCommandPathRegistry().Add(aRequestCommandPath, aRef);
396+
GetCommandPathRegistry().Add(aRequestCommandPath, aRef.std_optional());
396397
SetExchangeInterface(&mMockCommandResponder);
397398
}
398399
MockCommandResponder mMockCommandResponder;
@@ -407,7 +408,8 @@ class TestCommandInteraction
407408
// payload will be included. Otherwise no payload will be included.
408409
static void GenerateInvokeResponse(nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload,
409410
CommandId aCommandId, ClusterId aClusterId = kTestClusterId,
410-
EndpointId aEndpointId = kTestEndpointId, Optional<uint16_t> aCommandRef = NullOptional);
411+
EndpointId aEndpointId = kTestEndpointId,
412+
std::optional<uint16_t> aCommandRef = std::nullopt);
411413
static void AddInvokeRequestData(nlTestSuite * apSuite, void * apContext, CommandSender * apCommandSender,
412414
CommandId aCommandId = kTestCommandIdWithData);
413415
static void AddInvalidInvokeRequestData(nlTestSuite * apSuite, void * apContext, CommandSender * apCommandSender,
@@ -494,7 +496,7 @@ void TestCommandInteraction::GenerateInvokeRequest(nlTestSuite * apSuite, void *
494496

495497
void TestCommandInteraction::GenerateInvokeResponse(nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload,
496498
CommandId aCommandId, ClusterId aClusterId, EndpointId aEndpointId,
497-
Optional<uint16_t> aCommandRef)
499+
std::optional<uint16_t> aCommandRef)
498500

499501
{
500502
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -536,9 +538,9 @@ void TestCommandInteraction::GenerateInvokeResponse(nlTestSuite * apSuite, void
536538
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
537539
}
538540

539-
if (aCommandRef.HasValue())
541+
if (aCommandRef.has_value())
540542
{
541-
NL_TEST_ASSERT(apSuite, commandDataIBBuilder.Ref(aCommandRef.Value()) == CHIP_NO_ERROR);
543+
NL_TEST_ASSERT(apSuite, commandDataIBBuilder.Ref(*aCommandRef) == CHIP_NO_ERROR);
542544
}
543545

544546
commandDataIBBuilder.EndOfCommandDataIB();
@@ -633,9 +635,9 @@ uint32_t TestCommandInteraction::GetAddResponseDataOverheadSizeForPath(nlTestSui
633635
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId, kTestClusterId, kTestCommandIdFillResponseMessage };
634636
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId, kTestClusterId, kTestCommandIdCommandSpecificResponse };
635637

636-
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, MakeOptional<uint16_t>(static_cast<uint16_t>(1)));
638+
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, std::make_optional<uint16_t>(static_cast<uint16_t>(1)));
637639
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
638-
err = basicCommandPathRegistry.Add(requestCommandPath2, MakeOptional<uint16_t>(static_cast<uint16_t>(2)));
640+
err = basicCommandPathRegistry.Add(requestCommandPath2, std::make_optional<uint16_t>(static_cast<uint16_t>(2)));
639641
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
640642

641643
err = commandHandler.AllocateBuffer();
@@ -823,7 +825,7 @@ void TestCommandInteraction::TestCommandSenderExtendableApiWithProcessReceivedMs
823825

824826
uint16_t invalidResponseCommandRef = 2;
825827
GenerateInvokeResponse(apSuite, apContext, buf, kTestCommandIdWithData, kTestClusterId, kTestEndpointId,
826-
MakeOptional(invalidResponseCommandRef));
828+
std::make_optional(invalidResponseCommandRef));
827829
bool moreChunkedMessages = false;
828830
err = commandSender.ProcessInvokeResponse(std::move(buf), moreChunkedMessages);
829831
NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_KEY_NOT_FOUND);
@@ -1948,9 +1950,9 @@ void TestCommandInteraction::TestCommandHandler_FillUpInvokeResponseMessageWhere
19481950
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId, kTestClusterId, kTestCommandIdFillResponseMessage };
19491951
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId, kTestClusterId, kTestCommandIdCommandSpecificResponse };
19501952

1951-
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, MakeOptional<uint16_t>(static_cast<uint16_t>(1)));
1953+
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, std::make_optional<uint16_t>(static_cast<uint16_t>(1)));
19521954
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
1953-
err = basicCommandPathRegistry.Add(requestCommandPath2, MakeOptional<uint16_t>(static_cast<uint16_t>(2)));
1955+
err = basicCommandPathRegistry.Add(requestCommandPath2, std::make_optional<uint16_t>(static_cast<uint16_t>(2)));
19541956
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
19551957

19561958
uint32_t sizeToLeave = 0;
@@ -1977,9 +1979,9 @@ void TestCommandInteraction::TestCommandHandler_FillUpInvokeResponseMessageWhere
19771979
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId, kTestClusterId, kTestCommandIdFillResponseMessage };
19781980
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId, kTestClusterId, kTestCommandIdCommandSpecificResponse };
19791981

1980-
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, MakeOptional<uint16_t>(static_cast<uint16_t>(1)));
1982+
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, std::make_optional<uint16_t>(static_cast<uint16_t>(1)));
19811983
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
1982-
err = basicCommandPathRegistry.Add(requestCommandPath2, MakeOptional<uint16_t>(static_cast<uint16_t>(2)));
1984+
err = basicCommandPathRegistry.Add(requestCommandPath2, std::make_optional<uint16_t>(static_cast<uint16_t>(2)));
19831985
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
19841986

19851987
uint32_t sizeToLeave = 0;
@@ -2005,9 +2007,9 @@ void TestCommandInteraction::TestCommandHandler_FillUpInvokeResponseMessageWhere
20052007
ConcreteCommandPath requestCommandPath1 = { kTestEndpointId, kTestClusterId, kTestCommandIdFillResponseMessage };
20062008
ConcreteCommandPath requestCommandPath2 = { kTestEndpointId, kTestClusterId, kTestCommandIdCommandSpecificResponse };
20072009

2008-
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, MakeOptional<uint16_t>(static_cast<uint16_t>(1)));
2010+
CHIP_ERROR err = basicCommandPathRegistry.Add(requestCommandPath1, std::make_optional<uint16_t>(static_cast<uint16_t>(1)));
20092011
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
2010-
err = basicCommandPathRegistry.Add(requestCommandPath2, MakeOptional<uint16_t>(static_cast<uint16_t>(2)));
2012+
err = basicCommandPathRegistry.Add(requestCommandPath2, std::make_optional<uint16_t>(static_cast<uint16_t>(2)));
20112013
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
20122014

20132015
uint32_t sizeToLeave = 0;

0 commit comments

Comments
 (0)