Skip to content

Commit

Permalink
[Matter.framework] Enforce max reporting interval to kSubscriptionMax…
Browse files Browse the repository at this point in the history
…IntervalPublisherLimit
  • Loading branch information
vivien-apple committed Oct 21, 2024
1 parent 605e3f5 commit 7b7bcf1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ @interface MTRDeviceControllerFactoryParams ()

@end

class MTRApplicationCallback : public app::ReadHandler::ApplicationCallback {
CHIP_ERROR OnSubscriptionRequested(app::ReadHandler & readHandler, Transport::SecureSession & secureSession) override
{
uint16_t requestedMinInterval = 0;
uint16_t requestedMaxInterval = 0;
ReturnErrorOnFailure(readHandler.GetReportingIntervals(requestedMinInterval, requestedMaxInterval));

uint16_t maximumMaxInterval = std::max(kSubscriptionMaxIntervalPublisherLimit, requestedMaxInterval);
return readHandler.SetMaxReportingInterval(maximumMaxInterval);
}
};

MTR_DIRECT_MEMBERS
@interface MTRDeviceControllerFactory ()
- (void)preWarmCommissioningSessionDone;
Expand All @@ -90,6 +102,7 @@ @implementation MTRDeviceControllerFactory {

Credentials::IgnoreCertificateValidityPeriodPolicy _certificateValidityPolicy;
Crypto::RawKeySessionKeystore _sessionKeystore;
MTRApplicationCallback _applicationCallback;
// We use TestPersistentStorageDelegate just to get an in-memory store to back
// our group data provider impl. We initialize this store correctly on every
// controller startup, so don't need to actually persist it.
Expand Down Expand Up @@ -239,6 +252,8 @@ - (void)cleanupStartupObjects

// Make sure the deinit order here is the reverse of the init order in
// startControllerFactory:
app::InteractionModelEngine::GetInstance()->UnregisterReadHandlerAppCallback();

_certificationDeclarationCertificates = nil;
_productAttestationAuthorityCertificates = nil;

Expand Down Expand Up @@ -367,6 +382,8 @@ - (BOOL)_startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParam
_productAttestationAuthorityCertificates = [startupParams.productAttestationAuthorityCertificates copy];
_certificationDeclarationCertificates = [startupParams.certificationDeclarationCertificates copy];

app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&_applicationCallback);

{
chip::Controller::FactoryInitParams params;
if (startupParams.port != nil) {
Expand Down

0 comments on commit 7b7bcf1

Please sign in to comment.