Skip to content

Commit 615fa1e

Browse files
authored
Merge branch 'master' into update_sysconfig_v1_18_1
2 parents e63465b + 813181a commit 615fa1e

27 files changed

+750
-346
lines changed

examples/chip-tool/commands/pairing/PairingCommand.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
154154
// These Optionals must have values now.
155155
// The commissioner will verify these values.
156156
params.SetICDSymmetricKey(mICDSymmetricKey.Value());
157+
if (mICDStayActiveDurationMsec.HasValue())
158+
{
159+
params.SetICDStayActiveDurationMsec(mICDStayActiveDurationMsec.Value());
160+
}
157161
params.SetICDCheckInNodeId(mICDCheckInNodeId.Value());
158162
params.SetICDMonitoredSubject(mICDMonitoredSubject.Value());
159163
}
@@ -465,6 +469,12 @@ void PairingCommand::OnICDRegistrationComplete(NodeId nodeId, uint32_t icdCounte
465469
ChipLogValueX64(mICDMonitoredSubject.Value()), icdSymmetricKeyHex);
466470
}
467471

472+
void PairingCommand::OnICDStayActiveComplete(NodeId deviceId, uint32_t promisedActiveDuration)
473+
{
474+
ChipLogProgress(chipTool, "ICD Stay Active Complete for device " ChipLogFormatX64 " / promisedActiveDuration: %u",
475+
ChipLogValueX64(deviceId), promisedActiveDuration);
476+
}
477+
468478
void PairingCommand::OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData)
469479
{
470480
// Ignore nodes with closed commissioning window

examples/chip-tool/commands/pairing/PairingCommand.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ class PairingCommand : public CHIPCommand,
7272
AddArgument("icd-monitored-subject", 0, UINT64_MAX, &mICDMonitoredSubject,
7373
"The monitored subject of the ICD, default: The node id used for icd-check-in-nodeid.");
7474
AddArgument("icd-symmetric-key", &mICDSymmetricKey, "The 16 bytes ICD symmetric key, default: randomly generated.");
75-
75+
AddArgument("icd-stay-active-duration", 0, UINT32_MAX, &mICDStayActiveDurationMsec,
76+
"If set, a LIT ICD that is commissioned will be requested to stay active for this many milliseconds");
7677
switch (networkType)
7778
{
7879
case PairingNetworkType::None:
@@ -197,6 +198,7 @@ class PairingCommand : public CHIPCommand,
197198
void OnReadCommissioningInfo(const chip::Controller::ReadCommissioningInfo & info) override;
198199
void OnCommissioningComplete(NodeId deviceId, CHIP_ERROR error) override;
199200
void OnICDRegistrationComplete(NodeId deviceId, uint32_t icdCounter) override;
201+
void OnICDStayActiveComplete(NodeId deviceId, uint32_t promisedActiveDuration) override;
200202

201203
/////////// DeviceDiscoveryDelegate Interface /////////
202204
void OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData) override;
@@ -235,6 +237,7 @@ class PairingCommand : public CHIPCommand,
235237
chip::Optional<NodeId> mICDCheckInNodeId;
236238
chip::Optional<chip::ByteSpan> mICDSymmetricKey;
237239
chip::Optional<uint64_t> mICDMonitoredSubject;
240+
chip::Optional<uint32_t> mICDStayActiveDurationMsec;
238241
chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type> mTimeZoneList;
239242
TypedComplexArgument<chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type>>
240243
mComplex_TimeZones;

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;

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

+21
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,24 @@ DataModelCallbacks * DataModelCallbacks::SetInstance(DataModelCallbacks * newIns
3434
}
3535

3636
} // namespace chip
37+
38+
/// Strong-link callbacks for backwards compatibiltiy error reporting
39+
///
40+
/// We used to have these as __attribute__(weak) linkage in previous releases, so
41+
/// we define these as non-weak now so that we get compile errors in case anyone tries
42+
/// to link with them on the assumption they work (because they do not anymore)
43+
///
44+
/// TODO(future): we should be able to remove these once we assume everyone is updated
45+
/// to the latest code.
46+
void MatterPreAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) {}
47+
void MatterPostAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) {}
48+
void MatterPreAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) {}
49+
void MatterPostAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) {}
50+
CHIP_ERROR MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
51+
const chip::Access::SubjectDescriptor & subjectDescriptor)
52+
{
53+
return CHIP_NO_ERROR;
54+
}
55+
void MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
56+
const chip::Access::SubjectDescriptor & subjectDescriptor)
57+
{}

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
{}

src/app/util/af.h

-33
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@ chip::EndpointId emberAfParentEndpointFromIndex(uint16_t index);
136136
*/
137137
uint16_t emberAfIndexFromEndpoint(chip::EndpointId endpoint);
138138

139-
/**
140-
* Returns the index of a given endpoint; Does not ignore disabled endpoints.
141-
* Will return 0xFFFF if this is not a valid endpoint id.
142-
*/
143-
uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(chip::EndpointId endpoint);
144-
145139
/**
146140
* @brief Returns the index of the given endpoint in the list of all endpoints that might support the given cluster server.
147141
*
@@ -189,35 +183,8 @@ uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::C
189183
*/
190184
uint16_t emberAfFixedEndpointCount(void);
191185

192-
/**
193-
*@brief Returns true if type is signed, false otherwise.
194-
*/
195-
bool emberAfIsTypeSigned(EmberAfAttributeType dataType);
196-
197186
/** @} END Attribute Storage */
198187

199-
/** @name Miscellaneous */
200-
// @{
201-
202-
/** @brief Returns true if a given ZCL data type is a list type. */
203-
bool emberAfIsThisDataTypeAListType(EmberAfAttributeType dataType);
204-
205-
/**
206-
* @brief Simple integer comparison function.
207-
* Compares two values of a known length as integers.
208-
* Signed integer comparison are supported for numbers with length of
209-
* 4 (bytes) or less.
210-
* The integers are in native endianness.
211-
*
212-
* @return -1, if val1 is smaller
213-
* 0, if they are the same or if two negative numbers with length
214-
* greater than 4 is being compared
215-
* 1, if val2 is smaller.
216-
*/
217-
int8_t emberAfCompareValues(const uint8_t * val1, const uint8_t * val2, uint16_t len, bool signedNumber);
218-
219-
/** @} END Miscellaneous */
220-
221188
/** @} END addtogroup */
222189

223190
/**

src/app/util/attribute-storage.cpp

+30-30
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,36 @@ void UnregisterMatchingAttributeAccessInterfaces(F shouldUnregister)
175175
}
176176
}
177177

178+
bool emberAfIsThisDataTypeAListType(EmberAfAttributeType dataType)
179+
{
180+
return dataType == ZCL_ARRAY_ATTRIBUTE_TYPE;
181+
}
182+
183+
uint16_t findIndexFromEndpoint(EndpointId endpoint, bool ignoreDisabledEndpoints)
184+
{
185+
if (endpoint == kInvalidEndpointId)
186+
{
187+
return kEmberInvalidEndpointIndex;
188+
}
189+
190+
uint16_t epi;
191+
for (epi = 0; epi < emberAfEndpointCount(); epi++)
192+
{
193+
if (emAfEndpoints[epi].endpoint == endpoint &&
194+
(!ignoreDisabledEndpoints || emAfEndpoints[epi].bitmask.Has(EmberAfEndpointOptions::isEnabled)))
195+
{
196+
return epi;
197+
}
198+
}
199+
return kEmberInvalidEndpointIndex;
200+
}
201+
202+
// Returns the index of a given endpoint. Considers disabled endpoints.
203+
uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(EndpointId endpoint)
204+
{
205+
return findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
206+
}
207+
178208
} // anonymous namespace
179209

180210
// Initial configuration
@@ -354,11 +384,6 @@ bool emberAfEndpointIndexIsEnabled(uint16_t index)
354384
return (emAfEndpoints[index].bitmask.Has(EmberAfEndpointOptions::isEnabled));
355385
}
356386

357-
bool emberAfIsThisDataTypeAListType(EmberAfAttributeType dataType)
358-
{
359-
return dataType == ZCL_ARRAY_ATTRIBUTE_TYPE;
360-
}
361-
362387
// This function is used to call the per-cluster attribute changed callback
363388
void emAfClusterAttributeChangedCallback(const app::ConcreteAttributePath & attributePath)
364389
{
@@ -845,25 +870,6 @@ const EmberAfCluster * emberAfFindClusterIncludingDisabledEndpoints(EndpointId e
845870
return nullptr;
846871
}
847872

848-
static uint16_t findIndexFromEndpoint(EndpointId endpoint, bool ignoreDisabledEndpoints)
849-
{
850-
if (endpoint == kInvalidEndpointId)
851-
{
852-
return kEmberInvalidEndpointIndex;
853-
}
854-
855-
uint16_t epi;
856-
for (epi = 0; epi < emberAfEndpointCount(); epi++)
857-
{
858-
if (emAfEndpoints[epi].endpoint == endpoint &&
859-
(!ignoreDisabledEndpoints || emAfEndpoints[epi].bitmask.Has(EmberAfEndpointOptions::isEnabled)))
860-
{
861-
return epi;
862-
}
863-
}
864-
return kEmberInvalidEndpointIndex;
865-
}
866-
867873
uint16_t emberAfGetClusterServerEndpointIndex(EndpointId endpoint, ClusterId cluster, uint16_t fixedClusterServerEndpointCount)
868874
{
869875
VerifyOrDie(fixedClusterServerEndpointCount <= FIXED_ENDPOINT_COUNT);
@@ -980,12 +986,6 @@ uint16_t emberAfIndexFromEndpoint(EndpointId endpoint)
980986
return findIndexFromEndpoint(endpoint, true /* ignoreDisabledEndpoints */);
981987
}
982988

983-
// Returns the index of a given endpoint. Considers disabled endpoints.
984-
uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(EndpointId endpoint)
985-
{
986-
return findIndexFromEndpoint(endpoint, false /* ignoreDisabledEndpoints */);
987-
}
988-
989989
EndpointId emberAfEndpointFromIndex(uint16_t index)
990990
{
991991
return emAfEndpoints[index].endpoint;

0 commit comments

Comments
 (0)