@@ -713,6 +713,57 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP
713
713
ReturnErrorOnFailure (subscribeRequestParser.GetMaxIntervalCeilingSeconds (&mMaxInterval ));
714
714
VerifyOrReturnError (mMinIntervalFloorSeconds <= mMaxInterval , CHIP_ERROR_INVALID_ARGUMENT);
715
715
716
+ #if CHIP_CONFIG_ENABLE_ICD_SERVER
717
+
718
+ // Default behavior for ICDs where the wanted MaxInterval for a subscription is the IdleModeInterval
719
+ // defined in the ICD Management Cluster.
720
+ // Behavior can be changed with the OnSubscriptionRequested function defined in the application callbacks
721
+
722
+ // Default Behavior Steps :
723
+ // If MinInterval > IdleModeInterval, try to set the MaxInterval to the first interval of IdleModeIntervals above the
724
+ // MinInterval.
725
+ // If the next interval is greater than the MaxIntervalCeiling, use the MaxIntervalCeiling.
726
+ // Otherwise, use IdleModeInterval as MaxInterval
727
+
728
+ // GetPublisherSelectedIntervalLimit() returns the IdleModeInterval if the device is an ICD
729
+ uint32_t decidedMaxInterval = GetPublisherSelectedIntervalLimit ();
730
+
731
+ // Check if the PublisherSelectedIntervalLimit is 0. If so, set decidedMaxInterval to MaxIntervalCeiling
732
+ if (decidedMaxInterval == 0 )
733
+ {
734
+ decidedMaxInterval = mMaxInterval ;
735
+ }
736
+
737
+ // If requestedMinInterval is greater than the IdleTimeInterval, select next active up time as max interval
738
+ if (mMinIntervalFloorSeconds > decidedMaxInterval)
739
+ {
740
+ uint16_t ratio = mMinIntervalFloorSeconds / static_cast <uint16_t >(decidedMaxInterval);
741
+ if (mMinIntervalFloorSeconds % decidedMaxInterval)
742
+ {
743
+ ratio++;
744
+ }
745
+
746
+ decidedMaxInterval *= ratio;
747
+ }
748
+
749
+ // Verify that decidedMaxInterval is an acceptable value (overflow)
750
+ if (decidedMaxInterval > System::Clock::Seconds16::max ().count ())
751
+ {
752
+ decidedMaxInterval = System::Clock::Seconds16::max ().count ();
753
+ }
754
+
755
+ // Verify that the decidedMaxInterval respects MAX(GetPublisherSelectedIntervalLimit(), MaxIntervalCeiling)
756
+ uint16_t maximumMaxInterval = std::max (GetPublisherSelectedIntervalLimit (), mMaxInterval );
757
+ if (decidedMaxInterval > maximumMaxInterval)
758
+ {
759
+ decidedMaxInterval = maximumMaxInterval;
760
+ }
761
+
762
+ // Set max interval of the subscription
763
+ mMaxInterval = static_cast <uint16_t >(decidedMaxInterval);
764
+
765
+ #endif // CHIP_CONFIG_ENABLE_ICD_SERVER
766
+
716
767
//
717
768
// Notify the application (if requested) of the impending subscription and check whether we should still proceed to set it up.
718
769
// This also provides the application an opportunity to modify the negotiated min/max intervals set above.
0 commit comments