From 2630738c080509e91f5eafab5bef158ec4d0129e Mon Sep 17 00:00:00 2001 From: Song GUO Date: Sat, 14 May 2022 05:58:58 +0800 Subject: [PATCH] [IM] Change type of SubscriptionId-s to uint32_t per spec (#18410) * [IM] Change SubscriptionId to uint32_t per spec * Fix --- .../commands/clusters/ReportCommand.h | 2 +- .../commands/clusters/SubscriptionsCommands.h | 2 +- .../commands/clusters/ReportCommand.h | 2 +- .../commands/clusters/SubscriptionsCommands.h | 2 +- src/app/BufferedReadCallback.h | 5 ++++- src/app/ClusterStateCache.h | 5 ++++- src/app/InteractionModelEngine.cpp | 4 ++-- src/app/InteractionModelEngine.h | 2 +- src/app/MessageDef/ReportDataMessage.cpp | 6 ++--- src/app/MessageDef/ReportDataMessage.h | 4 ++-- .../MessageDef/SubscribeResponseMessage.cpp | 6 ++--- src/app/MessageDef/SubscribeResponseMessage.h | 4 ++-- src/app/ReadClient.cpp | 22 +++++++++---------- src/app/ReadClient.h | 6 ++--- src/app/ReadHandler.h | 4 ++-- src/app/reporting/Engine.cpp | 2 +- src/app/tests/TestMessageDef.cpp | 12 +++++----- .../tests/integration/chip_im_initiator.cpp | 2 +- .../interaction_model/InteractionModel.cpp | 2 +- .../interaction_model/InteractionModel.h | 2 +- src/controller/TypedReadCallback.h | 4 ++-- src/controller/java/AndroidCallbacks.cpp | 2 +- src/controller/java/AndroidCallbacks.h | 2 +- .../ChipDeviceController-ScriptBinding.cpp | 2 +- .../python/chip/clusters/Attribute.py | 2 +- .../python/chip/clusters/attribute.cpp | 4 ++-- src/controller/tests/TestEventChunking.cpp | 2 +- src/controller/tests/TestReadChunking.cpp | 4 ++-- src/controller/tests/data_model/TestRead.cpp | 2 +- src/darwin/Framework/CHIP/CHIPDevice.mm | 6 ++--- src/lib/core/DataModelTypes.h | 1 + 31 files changed, 67 insertions(+), 60 deletions(-) diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index 58d997cc4f61ee..6a993e54881ffe 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -102,7 +102,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi SetCommandExitStatus(mError); } - void OnSubscriptionEstablished(uint64_t subscriptionId) override { OnSubscription(); } + void OnSubscriptionEstablished(chip::SubscriptionId subscriptionId) override { OnSubscription(); } protected: // Use a 3x-longer-than-default timeout because wildcard reads can take a diff --git a/examples/chip-tool/commands/clusters/SubscriptionsCommands.h b/examples/chip-tool/commands/clusters/SubscriptionsCommands.h index 641cd3aa72b250..effc9f4edca2b6 100644 --- a/examples/chip-tool/commands/clusters/SubscriptionsCommands.h +++ b/examples/chip-tool/commands/clusters/SubscriptionsCommands.h @@ -36,7 +36,7 @@ class ShutdownSubscription : public CHIPCommand chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); } private: - uint64_t mSubscriptionId; + chip::SubscriptionId mSubscriptionId; }; class ShutdownSubscriptions : public CHIPCommand diff --git a/examples/tv-casting-app/tv-casting-common/commands/clusters/ReportCommand.h b/examples/tv-casting-app/tv-casting-common/commands/clusters/ReportCommand.h index 3d33cb3c8137b0..92bdae2f04fa75 100644 --- a/examples/tv-casting-app/tv-casting-common/commands/clusters/ReportCommand.h +++ b/examples/tv-casting-app/tv-casting-common/commands/clusters/ReportCommand.h @@ -105,7 +105,7 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac SetCommandExitStatus(mError); } - void OnSubscriptionEstablished(uint64_t subscriptionId) override { OnAttributeSubscription(); } + void OnSubscriptionEstablished(chip::SubscriptionId subscriptionId) override { OnAttributeSubscription(); } protected: CHIP_ERROR ReportAttribute(chip::DeviceProxy * device, std::vector endpointIds, diff --git a/examples/tv-casting-app/tv-casting-common/commands/clusters/SubscriptionsCommands.h b/examples/tv-casting-app/tv-casting-common/commands/clusters/SubscriptionsCommands.h index 2547b1257a3b95..b1bada5c17a280 100644 --- a/examples/tv-casting-app/tv-casting-common/commands/clusters/SubscriptionsCommands.h +++ b/examples/tv-casting-app/tv-casting-common/commands/clusters/SubscriptionsCommands.h @@ -39,7 +39,7 @@ class ShutdownSubscription : public CHIPCommand chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); } private: - uint64_t mSubscriptionId; + chip::SubscriptionId mSubscriptionId; }; class ShutdownSubscriptions : public CHIPCommand diff --git a/src/app/BufferedReadCallback.h b/src/app/BufferedReadCallback.h index 8d78359d41467b..c72516ce85b9f3 100644 --- a/src/app/BufferedReadCallback.h +++ b/src/app/BufferedReadCallback.h @@ -76,7 +76,10 @@ class BufferedReadCallback : public ReadClient::Callback } void OnDone() override { return mCallback.OnDone(); } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override { mCallback.OnSubscriptionEstablished(aSubscriptionId); } + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override + { + mCallback.OnSubscriptionEstablished(aSubscriptionId); + } void OnDeallocatePaths(chip::app::ReadPrepareParams && aReadPrepareParams) override { diff --git a/src/app/ClusterStateCache.h b/src/app/ClusterStateCache.h index a10614d8fe50a2..6536976884f7e9 100644 --- a/src/app/ClusterStateCache.h +++ b/src/app/ClusterStateCache.h @@ -569,7 +569,10 @@ class ClusterStateCache : protected ReadClient::Callback return mCallback.OnDone(); } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override { mCallback.OnSubscriptionEstablished(aSubscriptionId); } + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override + { + mCallback.OnSubscriptionEstablished(aSubscriptionId); + } void OnDeallocatePaths(chip::app::ReadPrepareParams && aReadPrepareParams) override { diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index b38f1a50a26475..68c9ae8a1129ef 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -217,7 +217,7 @@ void InteractionModelEngine::CloseTransactionsFromFabricIndex(FabricIndex aFabri }); } -CHIP_ERROR InteractionModelEngine::ShutdownSubscription(uint64_t aSubscriptionId) +CHIP_ERROR InteractionModelEngine::ShutdownSubscription(SubscriptionId aSubscriptionId) { for (auto * readClient = mpActiveReadClientList; readClient != nullptr; readClient = readClient->GetNextClient()) { @@ -470,7 +470,7 @@ CHIP_ERROR InteractionModelEngine::OnUnsolicitedReportData(Messaging::ExchangeCo ReportDataMessage::Parser report; ReturnErrorOnFailure(report.Init(reader)); - uint64_t subscriptionId = 0; + SubscriptionId subscriptionId = 0; ReturnErrorOnFailure(report.GetSubscriptionId(&subscriptionId)); ReturnErrorOnFailure(report.ExitContainer()); diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 5f00f0df8e9e06..bf344511a7780a 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -119,7 +119,7 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, * @retval #CHIP_ERROR_KEY_NOT_FOUND If the subscription is not found. * @retval #CHIP_NO_ERROR On success. */ - CHIP_ERROR ShutdownSubscription(uint64_t aSubscriptionId); + CHIP_ERROR ShutdownSubscription(SubscriptionId aSubscriptionId); /** * Tears down active subscriptions for a given peer node ID. diff --git a/src/app/MessageDef/ReportDataMessage.cpp b/src/app/MessageDef/ReportDataMessage.cpp index 6a244896ce454b..dab916db5aa5c8 100644 --- a/src/app/MessageDef/ReportDataMessage.cpp +++ b/src/app/MessageDef/ReportDataMessage.cpp @@ -77,7 +77,7 @@ CHIP_ERROR ReportDataMessage::Parser::CheckSchemaValidity() const VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); #if CHIP_DETAIL_LOGGING { - uint64_t subscriptionId; + SubscriptionId subscriptionId; ReturnErrorOnFailure(reader.Get(subscriptionId)); PRETTY_PRINT("\tSubscriptionId = 0x%" PRIx64 ",", subscriptionId); } @@ -151,7 +151,7 @@ CHIP_ERROR ReportDataMessage::Parser::GetSuppressResponse(bool * const apSuppres return GetSimpleValue(to_underlying(Tag::kSuppressResponse), TLV::kTLVType_Boolean, apSuppressResponse); } -CHIP_ERROR ReportDataMessage::Parser::GetSubscriptionId(uint64_t * const apSubscriptionId) const +CHIP_ERROR ReportDataMessage::Parser::GetSubscriptionId(SubscriptionId * const apSubscriptionId) const { return GetUnsignedInteger(to_underlying(Tag::kSubscriptionId), apSubscriptionId); } @@ -185,7 +185,7 @@ ReportDataMessage::Builder & ReportDataMessage::Builder::SuppressResponse(const return *this; } -ReportDataMessage::Builder & ReportDataMessage::Builder::SubscriptionId(const uint64_t aSubscriptionId) +ReportDataMessage::Builder & ReportDataMessage::Builder::SubscriptionId(const chip::SubscriptionId aSubscriptionId) { // skip if error has already been set if (mError == CHIP_NO_ERROR) diff --git a/src/app/MessageDef/ReportDataMessage.h b/src/app/MessageDef/ReportDataMessage.h index 1e539a9068d138..29fdbff29a00d2 100644 --- a/src/app/MessageDef/ReportDataMessage.h +++ b/src/app/MessageDef/ReportDataMessage.h @@ -86,7 +86,7 @@ class Parser : public MessageParser * @return #CHIP_NO_ERROR on success * #CHIP_END_OF_TLV if there is no such element */ - CHIP_ERROR GetSubscriptionId(uint64_t * const apSubscriptionId) const; + CHIP_ERROR GetSubscriptionId(SubscriptionId * const apSubscriptionId) const; /** * @brief Get a TLVReader for the AttributesDataList. Next() must be called before accessing them. @@ -145,7 +145,7 @@ class Builder : public MessageBuilder * * @return A reference to *this */ - ReportDataMessage::Builder & SubscriptionId(const uint64_t aSubscriptionId); + ReportDataMessage::Builder & SubscriptionId(const chip::SubscriptionId aSubscriptionId); /** * @brief Initialize a AttributeReportIBs::Builder for writing into the TLV stream diff --git a/src/app/MessageDef/SubscribeResponseMessage.cpp b/src/app/MessageDef/SubscribeResponseMessage.cpp index f422395f8e5aef..d857f5c13c5264 100644 --- a/src/app/MessageDef/SubscribeResponseMessage.cpp +++ b/src/app/MessageDef/SubscribeResponseMessage.cpp @@ -46,7 +46,7 @@ CHIP_ERROR SubscribeResponseMessage::Parser::CheckSchemaValidity() const VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); #if CHIP_DETAIL_LOGGING { - uint64_t subscriptionId; + SubscriptionId subscriptionId; ReturnErrorOnFailure(reader.Get(subscriptionId)); PRETTY_PRINT("\tSubscriptionId = 0x%" PRIx64 ",", subscriptionId); } @@ -108,7 +108,7 @@ CHIP_ERROR SubscribeResponseMessage::Parser::CheckSchemaValidity() const } #endif // CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK -CHIP_ERROR SubscribeResponseMessage::Parser::GetSubscriptionId(uint64_t * const apSubscribeId) const +CHIP_ERROR SubscribeResponseMessage::Parser::GetSubscriptionId(SubscriptionId * const apSubscribeId) const { return GetUnsignedInteger(to_underlying(Tag::kSubscriptionId), apSubscribeId); } @@ -123,7 +123,7 @@ CHIP_ERROR SubscribeResponseMessage::Parser::GetMaxIntervalCeilingSeconds(uint16 return GetUnsignedInteger(to_underlying(Tag::kMaxIntervalCeilingSeconds), apMaxIntervalCeilingSeconds); } -SubscribeResponseMessage::Builder & SubscribeResponseMessage::Builder::SubscriptionId(const uint64_t aSubscribeId) +SubscribeResponseMessage::Builder & SubscribeResponseMessage::Builder::SubscriptionId(const chip::SubscriptionId aSubscribeId) { if (mError == CHIP_NO_ERROR) { diff --git a/src/app/MessageDef/SubscribeResponseMessage.h b/src/app/MessageDef/SubscribeResponseMessage.h index 68a94dd18f9383..7c4b3a0e5dd5b1 100644 --- a/src/app/MessageDef/SubscribeResponseMessage.h +++ b/src/app/MessageDef/SubscribeResponseMessage.h @@ -60,7 +60,7 @@ class Parser : public MessageParser * @return #CHIP_NO_ERROR on success * #CHIP_END_OF_TLV if there is no such element */ - CHIP_ERROR GetSubscriptionId(uint64_t * const apSubscriptionId) const; + CHIP_ERROR GetSubscriptionId(SubscriptionId * const apSubscriptionId) const; /** * @brief Get Final MinIntervalFloorSeconds. Next() must be called before accessing them. @@ -85,7 +85,7 @@ class Builder : public MessageBuilder /** * @brief final subscription Id for the subscription back to the client.s. */ - SubscribeResponseMessage::Builder & SubscriptionId(const uint64_t SubscriptionId); + SubscribeResponseMessage::Builder & SubscriptionId(const chip::SubscriptionId SubscriptionId); /** * @brief Final Min Interval for the subscription back to the clients. diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index ac5504c7796661..7e1ea4efa8aaf2 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -459,8 +459,8 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload) CHIP_ERROR err = CHIP_NO_ERROR; ReportDataMessage::Parser report; - bool suppressResponse = true; - uint64_t subscriptionId = 0; + bool suppressResponse = true; + SubscriptionId subscriptionId = 0; EventReportIBs::Parser eventReportIBs; AttributeReportIBs::Parser attributeReportIBs; System::PacketBufferTLVReader reader; @@ -735,10 +735,10 @@ CHIP_ERROR ReadClient::RefreshLivenessCheckTimer() System::Clock::Timeout timeout = System::Clock::Seconds16(mMaxIntervalCeilingSeconds) + mpExchangeCtx->GetSessionHandle()->GetAckTimeout(); // EFR32/MBED/INFINION/K32W's chrono count return long unsinged, but other platform returns unsigned - ChipLogProgress( - DataManagement, - "Refresh LivenessCheckTime for %lu milliseconds with SubscriptionId = 0x" ChipLogFormatX64 " Peer = %02x:" ChipLogFormatX64, - static_cast(timeout.count()), ChipLogValueX64(mSubscriptionId), mFabricIndex, ChipLogValueX64(mPeerNodeId)); + ChipLogProgress(DataManagement, + "Refresh LivenessCheckTime for %lu milliseconds with SubscriptionId = 0x%08" PRIx32 + " Peer = %02x:" ChipLogFormatX64, + static_cast(timeout.count()), mSubscriptionId, mFabricIndex, ChipLogValueX64(mPeerNodeId)); err = InteractionModelEngine::GetInstance()->GetExchangeManager()->GetSessionManager()->SystemLayer()->StartTimer( timeout, OnLivenessTimeoutCallback, this); @@ -774,8 +774,8 @@ void ReadClient::OnLivenessTimeoutCallback(System::Layer * apSystemLayer, void * VerifyOrDie(_this->mpImEngine->InActiveReadClientList(_this)); ChipLogError(DataManagement, - "Subscription Liveness timeout with SubscriptionID = 0x" ChipLogFormatX64 ", Peer = %02x:" ChipLogFormatX64, - ChipLogValueX64(_this->mSubscriptionId), _this->mFabricIndex, ChipLogValueX64(_this->mPeerNodeId)); + "Subscription Liveness timeout with SubscriptionID = 0x%08" PRIx32 ", Peer = %02x:" ChipLogFormatX64, + _this->mSubscriptionId, _this->mFabricIndex, ChipLogValueX64(_this->mPeerNodeId)); // TODO: add a more specific error here for liveness timeout failure to distinguish between other classes of timeouts (i.e // response timeouts). @@ -794,16 +794,16 @@ CHIP_ERROR ReadClient::ProcessSubscribeResponse(System::PacketBufferHandle && aP ReturnErrorOnFailure(subscribeResponse.CheckSchemaValidity()); #endif - uint64_t subscriptionId = 0; + SubscriptionId subscriptionId = 0; ReturnErrorOnFailure(subscribeResponse.GetSubscriptionId(&subscriptionId)); VerifyOrReturnError(IsMatchingClient(subscriptionId), CHIP_ERROR_INVALID_ARGUMENT); ReturnErrorOnFailure(subscribeResponse.GetMinIntervalFloorSeconds(&mMinIntervalFloorSeconds)); ReturnErrorOnFailure(subscribeResponse.GetMaxIntervalCeilingSeconds(&mMaxIntervalCeilingSeconds)); ChipLogProgress(DataManagement, - "Subscription established with SubscriptionID = 0x" ChipLogFormatX64 " MinInterval = %u" + "Subscription established with SubscriptionID = 0x%08" PRIx32 " MinInterval = %u" "s MaxInterval = %us Peer = %02x:" ChipLogFormatX64, - ChipLogValueX64(mSubscriptionId), mMinIntervalFloorSeconds, mMaxIntervalCeilingSeconds, mFabricIndex, + mSubscriptionId, mMinIntervalFloorSeconds, mMaxIntervalCeilingSeconds, mFabricIndex, ChipLogValueX64(mPeerNodeId)); ReturnErrorOnFailure(subscribeResponse.ExitContainer()); diff --git a/src/app/ReadClient.h b/src/app/ReadClient.h index 57ca708dcf6277..7cb89fe46be003 100644 --- a/src/app/ReadClient.h +++ b/src/app/ReadClient.h @@ -124,7 +124,7 @@ class ReadClient : public Messaging::ExchangeDelegate * * @param[in] aSubscriptionId The identifier of the subscription that was established. */ - virtual void OnSubscriptionEstablished(uint64_t aSubscriptionId) {} + virtual void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) {} /** * OnError will be called when an error occurs *after* a successful call to SendRequest(). The following @@ -312,7 +312,7 @@ class ReadClient : public Messaging::ExchangeDelegate SubscriptionActive, ///< The client is maintaining subscription }; - bool IsMatchingClient(uint64_t aSubscriptionId) + bool IsMatchingClient(SubscriptionId aSubscriptionId) { return aSubscriptionId == mSubscriptionId && mInteractionType == InteractionType::Subscribe; } @@ -383,7 +383,7 @@ class ReadClient : public Messaging::ExchangeDelegate bool mPendingMoreChunks = false; uint16_t mMinIntervalFloorSeconds = 0; uint16_t mMaxIntervalCeilingSeconds = 0; - uint64_t mSubscriptionId = 0; + SubscriptionId mSubscriptionId = 0; NodeId mPeerNodeId = kUndefinedNodeId; FabricIndex mFabricIndex = kUndefinedFabricIndex; InteractionType mInteractionType = InteractionType::Read; diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index f159994249645d..23cd0186a1423a 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -240,7 +240,7 @@ class ReadHandler : public Messaging::ExchangeDelegate bool IsActiveSubscription() const { return mActiveSubscription; } bool IsFabricFiltered() const { return mIsFabricFiltered; } CHIP_ERROR OnSubscribeRequest(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload); - void GetSubscriptionId(uint64_t & aSubscriptionId) const { aSubscriptionId = mSubscriptionId; } + void GetSubscriptionId(SubscriptionId & aSubscriptionId) const { aSubscriptionId = mSubscriptionId; } AttributePathExpandIterator * GetAttributePathExpandIterator() { return &mAttributePathExpandIterator; } /** @@ -356,7 +356,7 @@ class ReadHandler : public Messaging::ExchangeDelegate // prior to receiving a subscribe response. bool mIsPrimingReports = true; InteractionType mInteractionType = InteractionType::Read; - uint64_t mSubscriptionId = 0; + SubscriptionId mSubscriptionId = 0; uint16_t mMinIntervalFloorSeconds = 0; uint16_t mMaxIntervalCeilingSeconds = 0; SessionHolder mSessionHandle; diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index f9bd3fb9439422..d5cc8356374350 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -445,7 +445,7 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler) if (apReadHandler->IsType(ReadHandler::InteractionType::Subscribe)) { - uint64_t subscriptionId = 0; + SubscriptionId subscriptionId = 0; apReadHandler->GetSubscriptionId(subscriptionId); reportDataBuilder.SubscriptionId(subscriptionId); } diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index 3fb45f5de08cc9..745e167e5032a7 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -1051,8 +1051,8 @@ void ParseReportDataMessage(nlTestSuite * apSuite, chip::TLV::TLVReader & aReade CHIP_ERROR err = CHIP_NO_ERROR; ReportDataMessage::Parser reportDataParser; - bool suppressResponse = false; - uint64_t subscriptionId = 0; + bool suppressResponse = false; + chip::SubscriptionId subscriptionId = 0; AttributeReportIBs::Parser attributeReportIBsParser; EventReportIBs::Parser eventReportsParser; bool moreChunkedMessages = false; @@ -1352,10 +1352,10 @@ void ParseSubscribeResponseMessage(nlTestSuite * apSuite, chip::TLV::TLVReader & CHIP_ERROR err = CHIP_NO_ERROR; SubscribeResponseMessage::Parser subscribeResponseParser; - uint64_t subscriptionId = 0; - uint16_t minIntervalFloorSeconds = 0; - uint16_t maxIntervalCeilingSeconds = 0; - err = subscribeResponseParser.Init(aReader); + chip::SubscriptionId subscriptionId = 0; + uint16_t minIntervalFloorSeconds = 0; + uint16_t maxIntervalCeilingSeconds = 0; + err = subscribeResponseParser.Init(aReader); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); #if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK err = subscribeResponseParser.CheckSchemaValidity(); diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index b7b9234671bec4..dd67a126962f25 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -134,7 +134,7 @@ class MockInteractionModelApp : public ::chip::app::CommandSender::Callback, void OnEventData(const chip::app::EventHeader & aEventHeader, chip::TLV::TLVReader * apData, const chip::app::StatusIB * apStatus) override {} - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override + void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override { if (mReadClient->IsSubscriptionType()) { diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp index 0b845c980b42b4..47d8197956b9b4 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -102,7 +102,7 @@ void InteractionModel::OnDone() ContinueOnChipMainThread(CHIP_NO_ERROR); } -void InteractionModel::OnSubscriptionEstablished(uint64_t subscriptionId) +void InteractionModel::OnSubscriptionEstablished(SubscriptionId subscriptionId) { ContinueOnChipMainThread(CHIP_NO_ERROR); } diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.h b/src/app/tests/suites/commands/interaction_model/InteractionModel.h index dcf4789d35cab5..e57dd2d851cfee 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -326,7 +326,7 @@ class InteractionModel : public InteractionModelReports, const chip::app::StatusIB * status) override; void OnError(CHIP_ERROR error) override; void OnDone() override; - void OnSubscriptionEstablished(uint64_t subscriptionId) override; + void OnSubscriptionEstablished(chip::SubscriptionId subscriptionId) override; /////////// WriteClient Callback Interface ///////// void OnResponse(const chip::app::WriteClient * client, const chip::app::ConcreteDataAttributePath & path, diff --git a/src/controller/TypedReadCallback.h b/src/controller/TypedReadCallback.h index 6b7886d6eb16f6..9283a9d375ebeb 100644 --- a/src/controller/TypedReadCallback.h +++ b/src/controller/TypedReadCallback.h @@ -98,7 +98,7 @@ class TypedReadAttributeCallback final : public app::ReadClient::Callback void OnDone() override { mOnDone(this); } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { if (mOnSubscriptionEstablished) { @@ -181,7 +181,7 @@ class TypedReadEventCallback final : public app::ReadClient::Callback chip::Platform::Delete(aReadPrepareParams.mpEventPathParamsList); } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { if (mOnSubscriptionEstablished) { diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index 8ccd1e8884404c..0d3e63805a5547 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -301,7 +301,7 @@ void ReportCallback::OnDone() JniReferences::GetInstance().GetEnvForCurrentThread()->DeleteGlobalRef(mWrapperCallbackRef); } -void ReportCallback::OnSubscriptionEstablished(uint64_t aSubscriptionId) +void ReportCallback::OnSubscriptionEstablished(SubscriptionId aSubscriptionId) { JniReferences::GetInstance().CallSubscriptionEstablished(mSubscriptionEstablishedCallbackRef); } diff --git a/src/controller/java/AndroidCallbacks.h b/src/controller/java/AndroidCallbacks.h index 5531a776374029..35297d24e77072 100644 --- a/src/controller/java/AndroidCallbacks.h +++ b/src/controller/java/AndroidCallbacks.h @@ -59,7 +59,7 @@ struct ReportCallback : public app::ReadClient::Callback void OnDone() override; - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override; + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override; /** Report errors back to Java layer. attributePath may be nullptr for general errors. */ void ReportError(jobject attributePath, CHIP_ERROR err); diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 955130fc1adc57..aa1a38bb3de8ee 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -186,7 +186,7 @@ uint64_t pychip_GetCommandSenderHandle(chip::DeviceProxy * device); // CHIP Stack objects ChipError::StorageType pychip_BLEMgrImpl_ConfigureBle(uint32_t bluetoothAdapterId); -chip::ChipError::StorageType pychip_InteractionModel_ShutdownSubscription(uint64_t subscriptionId); +chip::ChipError::StorageType pychip_InteractionModel_ShutdownSubscription(SubscriptionId subscriptionId); // // Storage diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 3f012ead0f342e..6d39df7d6bd9ee 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -742,7 +742,7 @@ def handleDone(self): _OnReadAttributeDataCallbackFunct = CFUNCTYPE( None, py_object, c_uint32, c_uint16, c_uint32, c_uint32, c_uint8, c_void_p, c_size_t) -_OnSubscriptionEstablishedCallbackFunct = CFUNCTYPE(None, py_object, c_uint64) +_OnSubscriptionEstablishedCallbackFunct = CFUNCTYPE(None, py_object, c_uint32) _OnReadEventDataCallbackFunct = CFUNCTYPE( None, py_object, c_uint16, c_uint32, c_uint32, c_uint64, c_uint8, c_uint64, c_uint8, c_void_p, c_size_t, c_uint8) _OnReadErrorCallbackFunct = CFUNCTYPE( diff --git a/src/controller/python/chip/clusters/attribute.cpp b/src/controller/python/chip/clusters/attribute.cpp index 6c4e6d71fb2176..c260cb94ce4cc5 100644 --- a/src/controller/python/chip/clusters/attribute.cpp +++ b/src/controller/python/chip/clusters/attribute.cpp @@ -69,7 +69,7 @@ using OnReadEventDataCallback = void (*)(PyObject * appContext, chip:: chip::EventId eventId, chip::EventNumber eventNumber, uint8_t priority, uint64_t timestamp, uint8_t timestampType, uint8_t * data, uint32_t dataLen, std::underlying_type_t imstatus); -using OnSubscriptionEstablishedCallback = void (*)(PyObject * appContext, uint64_t subscriptionId); +using OnSubscriptionEstablishedCallback = void (*)(PyObject * appContext, SubscriptionId subscriptionId); using OnReadErrorCallback = void (*)(PyObject * appContext, uint32_t chiperror); using OnReadDoneCallback = void (*)(PyObject * appContext); using OnReportBeginCallback = void (*)(PyObject * appContext); @@ -136,7 +136,7 @@ class ReadClientCallback : public ReadClient::Callback to_underlying(aStatus.mStatus), buffer.get(), size); } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { gOnSubscriptionEstablishedCallback(mAppContext, aSubscriptionId); } diff --git a/src/controller/tests/TestEventChunking.cpp b/src/controller/tests/TestEventChunking.cpp index bc742348b54349..19b99ac0d434f8 100644 --- a/src/controller/tests/TestEventChunking.cpp +++ b/src/controller/tests/TestEventChunking.cpp @@ -154,7 +154,7 @@ class TestReadCallback : public app::ReadClient::Callback void OnReportEnd() override { mOnReportEnd = true; } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override { mOnSubscriptionEstablished = true; } + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { mOnSubscriptionEstablished = true; } uint32_t mAttributeCount = 0; uint32_t mEventCount = 0; diff --git a/src/controller/tests/TestReadChunking.cpp b/src/controller/tests/TestReadChunking.cpp index 572990d1ca70cf..d8b4d89913db41 100644 --- a/src/controller/tests/TestReadChunking.cpp +++ b/src/controller/tests/TestReadChunking.cpp @@ -132,7 +132,7 @@ class TestReadCallback : public app::ReadClient::Callback void OnReportEnd() override { mOnReportEnd = true; } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override { mOnSubscriptionEstablished = true; } + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { mOnSubscriptionEstablished = true; } uint32_t mAttributeCount = 0; bool mOnReportEnd = false; @@ -301,7 +301,7 @@ class TestMutableReadCallback : public app::ReadClient::Callback void OnReportEnd() override { mOnReportEnd = true; } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override { mOnSubscriptionEstablished = true; } + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { mOnSubscriptionEstablished = true; } uint32_t mAttributeCount = 0; // We record every dataversion field from every attribute IB. diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index a3b7941a5eddf5..8bc04d723a6460 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -1536,7 +1536,7 @@ class TestReadCallback : public app::ReadClient::Callback mLastError = aError; } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override { mOnSubscriptionEstablishedCount++; } + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { mOnSubscriptionEstablishedCount++; } void ClearCounters() { diff --git a/src/darwin/Framework/CHIP/CHIPDevice.mm b/src/darwin/Framework/CHIP/CHIPDevice.mm index ad578503b914c8..82865ae5b421c8 100644 --- a/src/darwin/Framework/CHIP/CHIPDevice.mm +++ b/src/darwin/Framework/CHIP/CHIPDevice.mm @@ -297,7 +297,7 @@ - (instancetype)initWithDevice:(chip::DeviceProxy *)device void OnDeallocatePaths(ReadPrepareParams && aReadPrepareParams) override; - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override; + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override; void ReportError(CHIP_ERROR err); void ReportError(const StatusIB & status); @@ -791,7 +791,7 @@ void OnAttributeData( void OnDone() override { mOnDone(this); } - void OnSubscriptionEstablished(uint64_t aSubscriptionId) override + void OnSubscriptionEstablished(SubscriptionId aSubscriptionId) override { if (mOnSubscriptionEstablished) { mOnSubscriptionEstablished(); @@ -1520,7 +1520,7 @@ - (instancetype)initWithPath:(const ConcreteEventPath &)path } } -void SubscriptionCallback::OnSubscriptionEstablished(uint64_t aSubscriptionId) +void SubscriptionCallback::OnSubscriptionEstablished(SubscriptionId aSubscriptionId) { if (mSubscriptionEstablishedHandler) { dispatch_async(mQueue, mSubscriptionEstablishedHandler); diff --git a/src/lib/core/DataModelTypes.h b/src/lib/core/DataModelTypes.h index a2aca450784c4f..f6e4d50cf40b8a 100644 --- a/src/lib/core/DataModelTypes.h +++ b/src/lib/core/DataModelTypes.h @@ -43,6 +43,7 @@ typedef uint16_t ListIndex; typedef uint32_t TransactionId; typedef uint16_t KeysetId; typedef uint8_t InteractionModelRevision; +typedef uint32_t SubscriptionId; constexpr FabricIndex kUndefinedFabricIndex = 0; constexpr EndpointId kInvalidEndpointId = 0xFFFF;