Skip to content

Commit cbc7e80

Browse files
Merge branch 'master' into bugfix/cnet_scan_fix
2 parents 4e619c6 + 72bd295 commit cbc7e80

File tree

20 files changed

+500
-218
lines changed

20 files changed

+500
-218
lines changed

.github/workflows/lint.yml

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ jobs:
9595
--known-failure app/CommandHandler.h \
9696
--known-failure app/CommandHandlerInterface.h \
9797
--known-failure app/CommandSenderLegacyCallback.h \
98-
--known-failure app/data-model/ListLargeSystemExtensions.h \
9998
--known-failure app/ReadHandler.h \
10099
--known-failure app/reporting/reporting.cpp \
101100
--known-failure app/reporting/tests/MockReportScheduler.cpp \

examples/placeholder/linux/include/MatterCallbacks.h

-40
This file was deleted.

examples/placeholder/linux/main.cpp

+39-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,44 @@
1818

1919
#include "AppMain.h"
2020
#include "AppOptions.h"
21-
#include "MatterCallbacks.h"
21+
#include "InteractiveServer.h"
22+
23+
#include <app/util/MatterCallbacks.h>
24+
25+
namespace {
26+
class InteractiveServerRedirectCallbacks : public chip::DataModelCallbacks
27+
{
28+
public:
29+
void AttributeOperation(OperationType operation, OperationOrder order, const chip::app::ConcreteAttributePath & path) override
30+
{
31+
if (order != OperationOrder::Post)
32+
{
33+
return;
34+
}
35+
36+
// TODO: is there any value in checking the return of read/write attributes?
37+
// they seem to only return true/false based on isRead (i.e. commissioning complete)
38+
switch (operation)
39+
{
40+
case OperationType::Read:
41+
(void) InteractiveServer::GetInstance().ReadAttribute(path);
42+
break;
43+
case OperationType::Write:
44+
(void) InteractiveServer::GetInstance().WriteAttribute(path);
45+
break;
46+
}
47+
}
48+
49+
void PostCommandReceived(const chip::app::ConcreteCommandPath & commandPath,
50+
const chip::Access::SubjectDescriptor & subjectDescriptor) override
51+
{
52+
(void) InteractiveServer::GetInstance().Command(commandPath);
53+
}
54+
};
55+
56+
InteractiveServerRedirectCallbacks gDmCallbacks;
57+
58+
} // namespace
2259

2360
void ApplicationInit() {}
2461

@@ -36,6 +73,7 @@ int main(int argc, char * argv[])
3673
server.Run(AppOptions::GetInteractiveModePort());
3774
}
3875

76+
chip::DataModelCallbacks::SetInstance(&gDmCallbacks);
3977
ChipLinuxAppMainLoop();
4078

4179
return 0;

examples/tv-app/android/java/MyUserPrompterResolver-JNI.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ using namespace chip;
3030

3131
JNI_METHOD(void, OnPinCodeEntered)(JNIEnv *, jobject, jint jPinCode)
3232
{
33-
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
3433
chip::DeviceLayer::StackLock lock;
35-
uint32_t pinCode = (uint32_t) jPinCode;
34+
uint32_t pinCode = static_cast<uint32_t>(jPinCode);
3635
ChipLogProgress(Zcl, "OnPinCodeEntered %d", pinCode);
36+
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
3737
GetCommissionerDiscoveryController()->CommissionWithPasscode(pinCode);
3838
#endif
3939
}
@@ -67,11 +67,7 @@ JNI_METHOD(void, OnPromptDeclined)(JNIEnv *, jobject)
6767

6868
JNI_METHOD(void, OnCommissionerPasscodeOK)(JNIEnv *, jobject)
6969
{
70-
#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
71-
chip::DeviceLayer::StackLock lock;
7270
ChipLogProgress(Zcl, "OnCommissionerPasscodeOK");
73-
// GetCommissionerDiscoveryController()->Ok();
74-
#endif
7571
}
7672

7773
JNI_METHOD(void, OnCommissionerPasscodeCancel)(JNIEnv *, jobject)

examples/tv-app/android/java/TVApp-JNI.cpp

+28-5
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,28 @@ JNI_METHOD(void, setChipDeviceEventProvider)(JNIEnv *, jobject, jobject provider
197197
#if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED
198198
class MyPincodeService : public PasscodeService
199199
{
200-
bool HasTargetContentApp(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId,
201-
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info, uint32_t & passcode) override
200+
void LookupTargetContentApp(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId,
201+
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info) override
202202
{
203-
return ContentAppPlatform::GetInstance().HasTargetContentApp(vendorId, productId, rotatingId, info, passcode);
203+
uint32_t passcode;
204+
bool foundApp = ContentAppPlatform::GetInstance().HasTargetContentApp(vendorId, productId, rotatingId, info, passcode);
205+
if (!foundApp)
206+
{
207+
info.checkState = chip::Controller::TargetAppCheckState::kAppNotFound;
208+
}
209+
else if (passcode != 0)
210+
{
211+
info.checkState = chip::Controller::TargetAppCheckState::kAppFoundPasscodeReturned;
212+
}
213+
else
214+
{
215+
info.checkState = chip::Controller::TargetAppCheckState::kAppFoundNoPasscode;
216+
}
217+
CommissionerDiscoveryController * cdc = GetCommissionerDiscoveryController();
218+
if (cdc != nullptr)
219+
{
220+
cdc->HandleTargetContentAppCheck(info, passcode);
221+
}
204222
}
205223

206224
uint32_t GetCommissionerPasscode(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId) override
@@ -209,9 +227,14 @@ class MyPincodeService : public PasscodeService
209227
return 12345678;
210228
}
211229

212-
uint32_t FetchCommissionPasscodeFromContentApp(uint16_t vendorId, uint16_t productId, CharSpan rotatingId) override
230+
void FetchCommissionPasscodeFromContentApp(uint16_t vendorId, uint16_t productId, CharSpan rotatingId) override
213231
{
214-
return ContentAppPlatform::GetInstance().GetPasscodeFromContentApp(vendorId, productId, rotatingId);
232+
uint32_t passcode = ContentAppPlatform::GetInstance().GetPasscodeFromContentApp(vendorId, productId, rotatingId);
233+
CommissionerDiscoveryController * cdc = GetCommissionerDiscoveryController();
234+
if (cdc != nullptr)
235+
{
236+
cdc->HandleContentAppPasscodeResponse(passcode);
237+
}
215238
}
216239
};
217240
MyPincodeService gMyPincodeService;

examples/tv-app/tv-common/include/CHIPProjectAppConfig.h

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
// TVs need to be commissioners and likely want to be discoverable
3131
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 1
3232

33+
// TVs can handle the memory impact of supporting a larger list
34+
#define CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS 10
35+
3336
// TVs will often enable this feature
3437
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_PASSCODE 1
3538

examples/tv-app/tv-common/src/AppTv.cpp

+28-5
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,28 @@ MyUserPrompter gMyUserPrompter;
102102

103103
class MyPasscodeService : public PasscodeService
104104
{
105-
bool HasTargetContentApp(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId,
106-
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info, uint32_t & passcode) override
105+
void LookupTargetContentApp(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId,
106+
chip::Protocols::UserDirectedCommissioning::TargetAppInfo & info) override
107107
{
108-
return ContentAppPlatform::GetInstance().HasTargetContentApp(vendorId, productId, rotatingId, info, passcode);
108+
uint32_t passcode = 0;
109+
bool foundApp = ContentAppPlatform::GetInstance().HasTargetContentApp(vendorId, productId, rotatingId, info, passcode);
110+
if (!foundApp)
111+
{
112+
info.checkState = TargetAppCheckState::kAppNotFound;
113+
}
114+
else if (passcode != 0)
115+
{
116+
info.checkState = TargetAppCheckState::kAppFoundPasscodeReturned;
117+
}
118+
else
119+
{
120+
info.checkState = TargetAppCheckState::kAppFoundNoPasscode;
121+
}
122+
CommissionerDiscoveryController * cdc = GetCommissionerDiscoveryController();
123+
if (cdc != nullptr)
124+
{
125+
cdc->HandleTargetContentAppCheck(info, passcode);
126+
}
109127
}
110128

111129
uint32_t GetCommissionerPasscode(uint16_t vendorId, uint16_t productId, chip::CharSpan rotatingId) override
@@ -114,9 +132,14 @@ class MyPasscodeService : public PasscodeService
114132
return 12345678;
115133
}
116134

117-
uint32_t FetchCommissionPasscodeFromContentApp(uint16_t vendorId, uint16_t productId, CharSpan rotatingId) override
135+
void FetchCommissionPasscodeFromContentApp(uint16_t vendorId, uint16_t productId, CharSpan rotatingId) override
118136
{
119-
return ContentAppPlatform::GetInstance().GetPasscodeFromContentApp(vendorId, productId, rotatingId);
137+
uint32_t passcode = ContentAppPlatform::GetInstance().GetPasscodeFromContentApp(vendorId, productId, rotatingId);
138+
CommissionerDiscoveryController * cdc = GetCommissionerDiscoveryController();
139+
if (cdc != nullptr)
140+
{
141+
cdc->HandleContentAppPasscodeResponse(passcode);
142+
}
120143
}
121144
};
122145
MyPasscodeService gMyPasscodeService;

examples/tv-casting-app/android/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ shared_library("jni") {
5353

5454
deps = [
5555
"${chip_root}/examples/tv-casting-app/tv-casting-common",
56+
"${chip_root}/src/app/data-model:heap",
5657
"${chip_root}/src/app/server/java:jni",
5758
"${chip_root}/src/lib",
5859
"${chip_root}/third_party/inipp",

src/app/CommandHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ Status CommandHandler::ProcessGroupCommandDataIB(CommandDataIB::Parser & aComman
564564
else
565565
{
566566
ChipLogError(DataManagement,
567-
"Error when calling MatterPreCommandReceivedCallback for Endpoint=%u Cluster=" ChipLogFormatMEI
567+
"Error when calling PreCommandReceived for Endpoint=%u Cluster=" ChipLogFormatMEI
568568
" Command=" ChipLogFormatMEI " : %" CHIP_ERROR_FORMAT,
569569
mapping.endpoint_id, ChipLogValueMEI(clusterId), ChipLogValueMEI(commandId), err.Format());
570570
continue;

src/app/data-model/BUILD.gn

+9
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ source_set("data-model") {
4545
"${chip_root}/src/protocols/interaction_model",
4646
]
4747
}
48+
49+
# Provides extensions that use heap and should be
50+
# used for systems that are not as constrained as
51+
# embedded systems typically are
52+
source_set("heap") {
53+
sources = [ "ListLargeSystemExtensions.h" ]
54+
55+
deps = [ ":data-model" ]
56+
}

src/app/server/Server.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,22 @@ CHIP_ERROR Server::SendUserDirectedCommissioningRequest(chip::Transport::PeerAdd
645645
#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
646646
if (id.GetRotatingIdLength() == 0)
647647
{
648-
char rotatingDeviceIdHexBuffer[RotatingDeviceId::kHexMaxLength];
648+
AdditionalDataPayloadGeneratorParams additionalDataPayloadParams;
649+
uint8_t rotatingDeviceIdUniqueId[chip::DeviceLayer::ConfigurationManager::kRotatingDeviceIDUniqueIDLength];
650+
MutableByteSpan rotatingDeviceIdUniqueIdSpan(rotatingDeviceIdUniqueId);
651+
652+
ReturnErrorOnFailure(
653+
chip::DeviceLayer::GetDeviceInstanceInfoProvider()->GetRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueIdSpan));
649654
ReturnErrorOnFailure(
650-
app::DnssdServer::Instance().GenerateRotatingDeviceId(rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer)));
655+
chip::DeviceLayer::ConfigurationMgr().GetLifetimeCounter(additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter));
656+
additionalDataPayloadParams.rotatingDeviceIdUniqueId = rotatingDeviceIdUniqueIdSpan;
657+
658+
uint8_t rotatingDeviceIdInternalBuffer[RotatingDeviceId::kMaxLength];
659+
MutableByteSpan rotatingDeviceIdBufferTemp(rotatingDeviceIdInternalBuffer);
660+
ReturnErrorOnFailure(AdditionalDataPayloadGenerator().generateRotatingDeviceIdAsBinary(additionalDataPayloadParams,
661+
rotatingDeviceIdBufferTemp));
651662

652-
uint8_t * rotatingId = reinterpret_cast<uint8_t *>(rotatingDeviceIdHexBuffer);
653-
size_t rotatingIdLen = strlen(rotatingDeviceIdHexBuffer);
654-
id.SetRotatingId(rotatingId, rotatingIdLen);
663+
id.SetRotatingId(rotatingDeviceIdInternalBuffer, RotatingDeviceId::kMaxLength);
655664
}
656665
#endif
657666

src/app/util/MatterCallbacks.cpp

+2-65
Original file line numberDiff line numberDiff line change
@@ -15,74 +15,11 @@
1515
*/
1616
#include "MatterCallbacks.h"
1717

18-
// The defines below are using link-time callback and should be removed
19-
//
20-
// TODO: applications should be converted to use DataModelCallbacks instead
21-
// of relying on weak linkage
22-
void __attribute__((weak)) MatterPreAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) {}
23-
void __attribute__((weak)) MatterPostAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) {}
24-
void __attribute__((weak)) MatterPreAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) {}
25-
void __attribute__((weak)) MatterPostAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) {}
26-
CHIP_ERROR __attribute__((weak)) MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
27-
const chip::Access::SubjectDescriptor & subjectDescriptor)
28-
{
29-
return CHIP_NO_ERROR;
30-
}
31-
void __attribute__((weak)) MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
32-
const chip::Access::SubjectDescriptor & subjectDescriptor)
33-
{}
34-
3518
namespace chip {
3619
namespace {
3720

38-
class WeakRedirectCallbacks : public DataModelCallbacks
39-
{
40-
public:
41-
void AttributeOperation(OperationType operation, OperationOrder order, const chip::app::ConcreteAttributePath & path) override
42-
{
43-
switch (operation)
44-
{
45-
case OperationType::Read:
46-
switch (order)
47-
{
48-
case OperationOrder::Pre:
49-
MatterPreAttributeReadCallback(path);
50-
break;
51-
case OperationOrder::Post:
52-
MatterPostAttributeReadCallback(path);
53-
break;
54-
}
55-
break;
56-
case OperationType::Write:
57-
switch (order)
58-
{
59-
case OperationOrder::Pre:
60-
MatterPreAttributeWriteCallback(path);
61-
break;
62-
case OperationOrder::Post:
63-
MatterPostAttributeWriteCallback(path);
64-
break;
65-
}
66-
break;
67-
}
68-
}
69-
70-
CHIP_ERROR PreCommandReceived(const chip::app::ConcreteCommandPath & commandPath,
71-
const chip::Access::SubjectDescriptor & subjectDescriptor) override
72-
{
73-
return MatterPreCommandReceivedCallback(commandPath, subjectDescriptor);
74-
}
75-
76-
void PostCommandReceived(const chip::app::ConcreteCommandPath & commandPath,
77-
const chip::Access::SubjectDescriptor & subjectDescriptor) override
78-
{
79-
80-
MatterPostCommandReceivedCallback(commandPath, subjectDescriptor);
81-
}
82-
};
83-
84-
WeakRedirectCallbacks gWeakCallbacks;
85-
DataModelCallbacks * gInstance = &gWeakCallbacks;
21+
DataModelCallbacks gNoopCallbacks;
22+
DataModelCallbacks * gInstance = &gNoopCallbacks;
8623

8724
} // namespace
8825

src/app/util/MatterCallbacks.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ class DataModelCallbacks
6060
return CHIP_NO_ERROR;
6161
}
6262

63-
/// This callback is called once the message has been determined to be a command, but
64-
/// after it being dispatched to the receiver.
63+
/// This callback is called once for every command dispatch, after the dispatch is actually
64+
/// done towards the receiver.
65+
///
66+
/// This method is called once for every CommandDataIB (i.e. it may be called several times
67+
/// in the case of batch invoke, where a single `InvokeRequestMessage` may contain several
68+
/// CommandDataIB entries).
6569
virtual void PostCommandReceived(const chip::app::ConcreteCommandPath & commandPath,
6670
const chip::Access::SubjectDescriptor & subjectDescriptor)
6771
{}

0 commit comments

Comments
 (0)