Skip to content

Commit

Permalink
ICD: Publisher-selected maximum subscription interval.
Browse files Browse the repository at this point in the history
  • Loading branch information
rcasallas-silabs committed Jun 19, 2023
1 parent ad5403e commit 1436080
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,28 @@
#include <lib/core/TLVUtilities.h>
#include <messaging/ExchangeContext.h>

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/ReadHandler.h>
#include <app/reporting/Engine.h>

namespace chip {
namespace app {
using Status = Protocols::InteractionModel::Status;

CHIP_ERROR ReadHandler::GetPublisherSelectedIntervalLimit(uint16_t & limit_s)
{
#if CHIP_DEVICE_CONFIG_ENABLE_SED
uint32_t idle_interval_ms = 0;
EmberAfStatus status =
chip::app::Clusters::IcdManagement::Attributes::IdleModeInterval::Get(kRootEndpointId, &idle_interval_ms);
VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, CHIP_ERROR_INTERNAL);
limit_s = static_cast<uint16_t>(idle_interval_ms / 1000);
#else
limit_s = kSubscriptionMaxIntervalPublisherLimit;
#endif
return CHIP_NO_ERROR;
}

ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeContext * apExchangeContext,
InteractionType aInteractionType) :
mExchangeCtx(*this),
Expand Down
8 changes: 5 additions & 3 deletions src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include <system/SystemPacketBuffer.h>

// https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/61a9d19e6af12fdfb0872bcff26d19de6c680a1a/src/Ch02_Architecture.adoc#1122-subscribe-interaction-limits
constexpr uint16_t kSubscriptionMaxIntervalPublisherLimit = 3600; // 3600 seconds
constexpr uint16_t kSubscriptionMaxIntervalPublisherLimit = 3600; // seconds (60 minutes)

namespace chip {
namespace app {
Expand Down Expand Up @@ -198,17 +198,19 @@ class ReadHandler : public Messaging::ExchangeDelegate
*/
CHIP_ERROR SetReportingIntervals(uint16_t aMaxInterval)
{
uint16_t selected_interval_limit = 0;
VerifyOrReturnError(IsIdle(), CHIP_ERROR_INCORRECT_STATE);
ReturnErrorOnFailure(GetPublisherSelectedIntervalLimit(selected_interval_limit));
VerifyOrReturnError(mMinIntervalFloorSeconds <= aMaxInterval, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(aMaxInterval <= std::max(kSubscriptionMaxIntervalPublisherLimit, mMaxInterval),
CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(aMaxInterval <= std::max(selected_interval_limit, mMaxInterval), CHIP_ERROR_INVALID_ARGUMENT);
mMaxInterval = aMaxInterval;
return CHIP_NO_ERROR;
}

private:
PriorityLevel GetCurrentPriority() const { return mCurrentPriority; }
EventNumber & GetEventMin() { return mEventMin; }
CHIP_ERROR GetPublisherSelectedIntervalLimit(uint16_t & limit_s);

enum class ReadHandlerFlags : uint8_t
{
Expand Down

0 comments on commit 1436080

Please sign in to comment.