From 736ed63b5208a1f1c02b3a78038a82060a21264f Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 24 Oct 2024 12:48:02 +0200 Subject: [PATCH] =?UTF-8?q?[Matter.framework]=20Enforce=20max=20reporting?= =?UTF-8?q?=20interval=20to=20kSubscriptionMax=E2=80=A6=20(#36112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CHIP/MTRDeviceControllerFactory.mm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm index 8ab6a7dc365f2a..9de51431bfe4f8 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm @@ -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; + readHandler.GetReportingIntervals(requestedMinInterval, requestedMaxInterval); + + uint16_t maximumMaxInterval = std::max(kSubscriptionMaxIntervalPublisherLimit, requestedMaxInterval); + return readHandler.SetMaxReportingInterval(maximumMaxInterval); + } +}; + MTR_DIRECT_MEMBERS @interface MTRDeviceControllerFactory () - (void)preWarmCommissioningSessionDone; @@ -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. @@ -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; @@ -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) {