diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 89ae89e5f434d0..b21d5b5a976604 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -531,9 +531,7 @@ Status InteractionModelEngine::OnUnsolicitedReportData(Messaging::ExchangeContex { continue; } - - VerifyOrReturnError(readClient->OnUnsolicitedReportData(apExchangeContext, std::move(aPayload)) == CHIP_NO_ERROR, - Status::InvalidAction); + readClient->OnUnsolicitedReportData(apExchangeContext, std::move(aPayload)); return Status::Success; } diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index 08a9a512083027..007cc6d0192133 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -409,19 +409,18 @@ CHIP_ERROR ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchange System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; - + Status status = Status::InvalidAction; VerifyOrExit(!IsIdle(), err = CHIP_ERROR_INCORRECT_STATE); if (aPayloadHeader.HasMessageType(Protocols::InteractionModel::MsgType::ReportData)) { err = ProcessReportData(std::move(aPayload)); - SuccessOrExit(err); } else if (aPayloadHeader.HasMessageType(Protocols::InteractionModel::MsgType::SubscribeResponse)) { + ChipLogProgress(DataManagement, "SubscribeResponse is received"); VerifyOrExit(apExchangeContext == mExchange.Get(), err = CHIP_ERROR_INCORRECT_STATE); err = ProcessSubscribeResponse(std::move(aPayload)); - SuccessOrExit(err); } else if (aPayloadHeader.HasMessageType(Protocols::InteractionModel::MsgType::StatusResponse)) { @@ -439,9 +438,11 @@ CHIP_ERROR ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchange exit: if (err != CHIP_NO_ERROR) { - // TODO: if we get here with a ReportData that has an incorrect subscription id, we need to send status with - // InvalidSubscription - StatusResponse::Send(Status::InvalidAction, apExchangeContext, false /*aExpectResponse*/); + if (err == CHIP_ERROR_INVALID_SUBSCRIPTION) + { + status = Status::InvalidSubscription; + } + StatusResponse::Send(status, apExchangeContext, false /*aExpectResponse*/); } if ((!IsSubscriptionType() && !mPendingMoreChunks) || err != CHIP_NO_ERROR) @@ -452,18 +453,26 @@ CHIP_ERROR ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchange return err; } -CHIP_ERROR ReadClient::OnUnsolicitedReportData(Messaging::ExchangeContext * apExchangeContext, - System::PacketBufferHandle && aPayload) +void ReadClient::OnUnsolicitedReportData(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload) { + Status status = Status::Success; mExchange.Grab(apExchangeContext); CHIP_ERROR err = ProcessReportData(std::move(aPayload)); if (err != CHIP_NO_ERROR) { + if (err == CHIP_ERROR_INVALID_SUBSCRIPTION) + { + status = Status::InvalidSubscription; + } + else + { + status = Status::InvalidAction; + } + + StatusResponse::Send(status, mExchange.Get(), false /*aExpectResponse*/); Close(err); } - - return err; } CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload) @@ -501,7 +510,7 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload) } else if (!IsMatchingClient(subscriptionId)) { - err = CHIP_ERROR_INVALID_ARGUMENT; + err = CHIP_ERROR_INVALID_SUBSCRIPTION; } } else if (CHIP_END_OF_TLV == err) @@ -827,8 +836,8 @@ CHIP_ERROR ReadClient::ProcessSubscribeResponse(System::PacketBufferHandle && aP #endif SubscriptionId subscriptionId = 0; - ReturnErrorOnFailure(subscribeResponse.GetSubscriptionId(&subscriptionId)); - VerifyOrReturnError(IsMatchingClient(subscriptionId), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(subscribeResponse.GetSubscriptionId(&subscriptionId) == CHIP_NO_ERROR, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsMatchingClient(subscriptionId), CHIP_ERROR_INVALID_SUBSCRIPTION); ReturnErrorOnFailure(subscribeResponse.GetMaxInterval(&mMaxInterval)); ChipLogProgress(DataManagement, diff --git a/src/app/ReadClient.h b/src/app/ReadClient.h index 78291fa5fddc7a..6a4f1505b5d7a8 100644 --- a/src/app/ReadClient.h +++ b/src/app/ReadClient.h @@ -293,7 +293,7 @@ class ReadClient : public Messaging::ExchangeDelegate */ CHIP_ERROR SendRequest(ReadPrepareParams & aReadPrepareParams); - CHIP_ERROR OnUnsolicitedReportData(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload); + void OnUnsolicitedReportData(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload); auto GetSubscriptionId() const { diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 47cdac5c074e65..20921bf72794d4 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -324,6 +324,10 @@ class TestReadInteraction static void TestSubscribeClientReceiveWellFormedStatusResponse(nlTestSuite * apSuite, void * apContext); static void TestSubscribeClientReceiveInvalidReportMessage(nlTestSuite * apSuite, void * apContext); static void TestSubscribeClientReceiveUnsolicitedInvalidReportMessage(nlTestSuite * apSuite, void * apContext); + static void TestSubscribeClientReceiveInvalidSubscribeResponseMessage(nlTestSuite * apSuite, void * apContext); + static void TestSubscribeClientReceiveUnsolicitedReportMessageWithInvalidSubscriptionId(nlTestSuite * apSuite, + void * apContext); + static void TestReadChunkingInvalidSubscriptionId(nlTestSuite * apSuite, void * apContext); private: static void GenerateReportData(nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload, @@ -2798,10 +2802,10 @@ void TestReadInteraction::TestSubscribeClientReceiveInvalidStatusResponse(nlTest ctx.DrainAndServiceIO(); // TODO: Need to validate what status is being sent to the ReadHandler - // The ReadHandler's exchange is still open when we synthesize the StatusResponse. - // Since we synthesized the StatusResponse to the ReadClient, instead of sending it from the ReadHandler, + // The ReadHandler's exchange is closed when we synthesize the subscribe response, since it sent the + // Subscribe Response as the last message in the transaction. + // Since we synthesized the subscribe response to the ReadClient, instead of sending it from the ReadHandler, // the only messages here are the ReadClient's StatusResponse to the unexpected message and an MRP ack. - // The ReadHandler should have sent a StatusResponse too, but it's buggy and does not do that. NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 2); NL_TEST_ASSERT(apSuite, delegate.mError == CHIP_IM_GLOBAL_STATUS(Busy)); @@ -3068,6 +3072,263 @@ void TestReadInteraction::TestSubscribeClientReceiveUnsolicitedInvalidReportMess engine->Shutdown(); } +// Read Client sends the subscribe request, Read Handler drops the subscribe response, then test injects invalid subscribe response +// message +void TestReadInteraction::TestSubscribeClientReceiveInvalidSubscribeResponseMessage(nlTestSuite * apSuite, void * apContext) +{ + TestContext & ctx = *static_cast(apContext); + CHIP_ERROR err = CHIP_NO_ERROR; + + Messaging::ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); + // Shouldn't have anything in the retransmit table when starting the test. + NL_TEST_ASSERT(apSuite, rm->TestGetCountRetransTable() == 0); + + MockInteractionModelApp delegate; + auto * engine = chip::app::InteractionModelEngine::GetInstance(); + err = engine->Init(&ctx.GetExchangeManager(), &ctx.GetFabricTable()); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + + ReadPrepareParams readPrepareParams(ctx.GetSessionBobToAlice()); + + chip::app::AttributePathParams attributePathParams[2]; + readPrepareParams.mpAttributePathParamsList = attributePathParams; + readPrepareParams.mpAttributePathParamsList[0].mEndpointId = kTestEndpointId; + readPrepareParams.mpAttributePathParamsList[0].mClusterId = kTestClusterId; + readPrepareParams.mpAttributePathParamsList[0].mAttributeId = 1; + + readPrepareParams.mpAttributePathParamsList[1].mEndpointId = kTestEndpointId; + readPrepareParams.mpAttributePathParamsList[1].mClusterId = kTestClusterId; + readPrepareParams.mpAttributePathParamsList[1].mAttributeId = 2; + + readPrepareParams.mAttributePathParamsListSize = 2; + + readPrepareParams.mMinIntervalFloorSeconds = 2; + readPrepareParams.mMaxIntervalCeilingSeconds = 5; + + { + app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &ctx.GetExchangeManager(), delegate, + chip::app::ReadClient::InteractionType::Subscribe); + + ctx.GetLoopback().mSentMessageCount = 0; + ctx.GetLoopback().mNumMessagesToDrop = 1; + ctx.GetLoopback().mNumMessagesToAllowBeforeDropping = 3; + ctx.GetLoopback().mDroppedMessageCount = 0; + err = readClient.SendRequest(readPrepareParams); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + ctx.DrainAndServiceIO(); + + System::PacketBufferHandle msgBuf = System::PacketBufferHandle::New(kMaxSecureSduLengthBytes); + NL_TEST_ASSERT(apSuite, !msgBuf.IsNull()); + System::PacketBufferTLVWriter writer; + writer.Init(std::move(msgBuf)); + SubscribeResponseMessage::Builder response; + response.Init(&writer); + response.SubscriptionId(readClient.mSubscriptionId + 1); + response.MaxInterval(1); + response.EndOfSubscribeResponseMessage(); + NL_TEST_ASSERT(apSuite, writer.Finalize(&msgBuf) == CHIP_NO_ERROR); + PayloadHeader payloadHeader; + payloadHeader.SetExchangeID(0); + payloadHeader.SetMessageType(chip::Protocols::InteractionModel::MsgType::SubscribeResponse); + + rm->ClearRetransTable(readClient.mExchange.Get()); + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 4); + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mDroppedMessageCount == 1); + NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers() == 1); + NL_TEST_ASSERT(apSuite, engine->ActiveHandlerAt(0) != nullptr); + rm->ClearRetransTable(engine->ActiveHandlerAt(0)->mExchangeCtx.Get()); + + ctx.GetLoopback().mSentMessageCount = 0; + ctx.GetLoopback().mNumMessagesToDrop = 0; + ctx.GetLoopback().mNumMessagesToAllowBeforeDropping = 0; + ctx.GetLoopback().mDroppedMessageCount = 0; + + readClient.OnMessageReceived(readClient.mExchange.Get(), payloadHeader, std::move(msgBuf)); + ctx.DrainAndServiceIO(); + + // TODO: Need to validate what status is being sent to the ReadHandler + // The ReadHandler's exchange is still open when we synthesize the subscribe response. + // Since we synthesized the subscribe response to the ReadClient, instead of sending it from the ReadHandler, + // the only messages here are the ReadClient's StatusResponse to the unexpected message and an MRP ack. + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 2); + + NL_TEST_ASSERT(apSuite, delegate.mError == CHIP_ERROR_INVALID_SUBSCRIPTION); + } + NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadClients() == 0); + engine->Shutdown(); + ctx.ExpireSessionAliceToBob(); + ctx.ExpireSessionBobToAlice(); + ctx.CreateSessionAliceToBob(); + ctx.CreateSessionBobToAlice(); +} + +// Read Client create the subscription, handler sends unsolicited malformed report with invalid subscription id to client, +// InteractionModelEngine::OnUnsolicitedReportData would process this malformed report and sends out status report +void TestReadInteraction::TestSubscribeClientReceiveUnsolicitedReportMessageWithInvalidSubscriptionId(nlTestSuite * apSuite, + void * apContext) +{ + TestContext & ctx = *static_cast(apContext); + CHIP_ERROR err = CHIP_NO_ERROR; + + Messaging::ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); + // Shouldn't have anything in the retransmit table when starting the test. + NL_TEST_ASSERT(apSuite, rm->TestGetCountRetransTable() == 0); + + MockInteractionModelApp delegate; + auto * engine = chip::app::InteractionModelEngine::GetInstance(); + err = engine->Init(&ctx.GetExchangeManager(), &ctx.GetFabricTable()); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + + ReadPrepareParams readPrepareParams(ctx.GetSessionBobToAlice()); + + chip::app::AttributePathParams attributePathParams[2]; + readPrepareParams.mpAttributePathParamsList = attributePathParams; + readPrepareParams.mpAttributePathParamsList[0].mEndpointId = kTestEndpointId; + readPrepareParams.mpAttributePathParamsList[0].mClusterId = kTestClusterId; + readPrepareParams.mpAttributePathParamsList[0].mAttributeId = 1; + + readPrepareParams.mpAttributePathParamsList[1].mEndpointId = kTestEndpointId; + readPrepareParams.mpAttributePathParamsList[1].mClusterId = kTestClusterId; + readPrepareParams.mpAttributePathParamsList[1].mAttributeId = 2; + + readPrepareParams.mAttributePathParamsListSize = 2; + + readPrepareParams.mMinIntervalFloorSeconds = 2; + readPrepareParams.mMaxIntervalCeilingSeconds = 5; + + { + ctx.GetLoopback().mSentMessageCount = 0; + app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &ctx.GetExchangeManager(), delegate, + chip::app::ReadClient::InteractionType::Subscribe); + + err = readClient.SendRequest(readPrepareParams); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + ctx.DrainAndServiceIO(); + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 5); + NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers() == 1); + NL_TEST_ASSERT(apSuite, engine->ActiveHandlerAt(0) != nullptr); + delegate.mpReadHandler = engine->ActiveHandlerAt(0); + + System::PacketBufferHandle msgBuf = System::PacketBufferHandle::New(kMaxSecureSduLengthBytes); + NL_TEST_ASSERT(apSuite, !msgBuf.IsNull()); + System::PacketBufferTLVWriter writer; + writer.Init(std::move(msgBuf)); + ReportDataMessage::Builder response; + response.Init(&writer); + response.SubscriptionId(readClient.mSubscriptionId + 1); + response.EndOfReportDataMessage(); + + NL_TEST_ASSERT(apSuite, writer.Finalize(&msgBuf) == CHIP_NO_ERROR); + + ctx.GetLoopback().mSentMessageCount = 0; + auto exchange = InteractionModelEngine::GetInstance()->GetExchangeManager()->NewContext( + delegate.mpReadHandler->mSessionHandle.Get().Value(), delegate.mpReadHandler); + delegate.mpReadHandler->mExchangeCtx.Grab(exchange); + err = delegate.mpReadHandler->mExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::ReportData, std::move(msgBuf), + Messaging::SendMessageFlags::kExpectResponse); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + ctx.DrainAndServiceIO(); + + // The server sends a data report. + // The client receives the data report data and sends out status report with invalid subsciption. + // The server should respond with a status report of its own, leading to 4 messages (because + // the client would ack the server's status report), just sends an ack to the status report it got. + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 3); + } + NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadClients() == 0); + engine->Shutdown(); +} + +// TestReadChunkingInvalidSubscriptionId will try to read a few large attributes, the report won't fit into the MTU and result in +// chunking, second report has different subscription id from the first one, read client sends out the status report with invalid +// subscription +void TestReadInteraction::TestReadChunkingInvalidSubscriptionId(nlTestSuite * apSuite, void * apContext) +{ + TestContext & ctx = *static_cast(apContext); + CHIP_ERROR err = CHIP_NO_ERROR; + + Messaging::ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); + // Shouldn't have anything in the retransmit table when starting the test. + NL_TEST_ASSERT(apSuite, rm->TestGetCountRetransTable() == 0); + + GenerateEvents(apSuite, apContext); + + MockInteractionModelApp delegate; + auto * engine = chip::app::InteractionModelEngine::GetInstance(); + err = engine->Init(&ctx.GetExchangeManager(), &ctx.GetFabricTable()); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(apSuite, !delegate.mGotEventResponse); + + chip::app::AttributePathParams attributePathParams[1]; + // Mock Attribute 4 is a big attribute, with 6 large OCTET_STRING + attributePathParams[0].mEndpointId = Test::kMockEndpoint3; + attributePathParams[0].mClusterId = Test::MockClusterId(2); + attributePathParams[0].mAttributeId = Test::MockAttributeId(4); + + ReadPrepareParams readPrepareParams(ctx.GetSessionBobToAlice()); + readPrepareParams.mpEventPathParamsList = nullptr; + readPrepareParams.mEventPathParamsListSize = 0; + readPrepareParams.mpAttributePathParamsList = attributePathParams; + readPrepareParams.mAttributePathParamsListSize = 1; + + { + app::ReadClient readClient(chip::app::InteractionModelEngine::GetInstance(), &ctx.GetExchangeManager(), delegate, + chip::app::ReadClient::InteractionType::Subscribe); + + ctx.GetLoopback().mSentMessageCount = 0; + ctx.GetLoopback().mNumMessagesToDrop = 1; + ctx.GetLoopback().mNumMessagesToAllowBeforeDropping = 3; + ctx.GetLoopback().mDroppedMessageCount = 0; + err = readClient.SendRequest(readPrepareParams); + NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + + ctx.DrainAndServiceIO(); + + System::PacketBufferHandle msgBuf = System::PacketBufferHandle::New(kMaxSecureSduLengthBytes); + NL_TEST_ASSERT(apSuite, !msgBuf.IsNull()); + System::PacketBufferTLVWriter writer; + writer.Init(std::move(msgBuf)); + ReportDataMessage::Builder response; + response.Init(&writer); + response.SubscriptionId(readClient.mSubscriptionId + 1); + response.EndOfReportDataMessage(); + PayloadHeader payloadHeader; + payloadHeader.SetExchangeID(0); + payloadHeader.SetMessageType(chip::Protocols::InteractionModel::MsgType::ReportData); + + NL_TEST_ASSERT(apSuite, writer.Finalize(&msgBuf) == CHIP_NO_ERROR); + + rm->ClearRetransTable(readClient.mExchange.Get()); + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 4); + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mDroppedMessageCount == 1); + NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadHandlers() == 1); + NL_TEST_ASSERT(apSuite, engine->ActiveHandlerAt(0) != nullptr); + + ctx.GetLoopback().mSentMessageCount = 0; + ctx.GetLoopback().mNumMessagesToDrop = 0; + ctx.GetLoopback().mNumMessagesToAllowBeforeDropping = 0; + ctx.GetLoopback().mDroppedMessageCount = 0; + + readClient.OnMessageReceived(readClient.mExchange.Get(), payloadHeader, std::move(msgBuf)); + ctx.DrainAndServiceIO(); + + // TODO: Need to validate what status is being sent to the ReadHandler + // The ReadHandler's exchange is still open when we synthesize the report data message. + // Since we synthesized the second report data message to the ReadClient with invalid subscription id, instead of sending it + // from the ReadHandler, the only messages here are the ReadClient's StatusResponse to the unexpected message and an MRP + // ack. + NL_TEST_ASSERT(apSuite, ctx.GetLoopback().mSentMessageCount == 2); + + NL_TEST_ASSERT(apSuite, delegate.mError == CHIP_ERROR_INVALID_SUBSCRIPTION); + } + NL_TEST_ASSERT(apSuite, engine->GetNumActiveReadClients() == 0); + engine->Shutdown(); + ctx.ExpireSessionAliceToBob(); + ctx.ExpireSessionBobToAlice(); + ctx.CreateSessionAliceToBob(); + ctx.CreateSessionBobToAlice(); +} + } // namespace app } // namespace chip @@ -3103,6 +3364,9 @@ const nlTest sTests[] = NL_TEST_DEF("TestSubscribeClientReceiveWellFormedStatusResponse", chip::app::TestReadInteraction::TestSubscribeClientReceiveWellFormedStatusResponse), NL_TEST_DEF("TestSubscribeClientReceiveInvalidReportMessage", chip::app::TestReadInteraction::TestSubscribeClientReceiveInvalidReportMessage), NL_TEST_DEF("TestSubscribeClientReceiveUnsolicitedInvalidReportMessage", chip::app::TestReadInteraction::TestSubscribeClientReceiveUnsolicitedInvalidReportMessage), + NL_TEST_DEF("TestSubscribeClientReceiveInvalidSubscribeResponseMessage", chip::app::TestReadInteraction::TestSubscribeClientReceiveInvalidSubscribeResponseMessage), + NL_TEST_DEF("TestSubscribeClientReceiveUnsolicitedReportMessageWithInvalidSubscriptionId", chip::app::TestReadInteraction::TestSubscribeClientReceiveUnsolicitedReportMessageWithInvalidSubscriptionId), + NL_TEST_DEF("TestReadChunkingInvalidSubscriptionId", chip::app::TestReadInteraction::TestReadChunkingInvalidSubscriptionId), NL_TEST_DEF("TestSubscribeUrgentWildcardEvent", chip::app::TestReadInteraction::TestSubscribeUrgentWildcardEvent), NL_TEST_DEF("TestSubscribeWildcard", chip::app::TestReadInteraction::TestSubscribeWildcard), NL_TEST_DEF("TestSubscribePartialOverlap", chip::app::TestReadInteraction::TestSubscribePartialOverlap), diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index 706972fa59b567..c66f2d3cd51321 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -242,8 +242,8 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_LISTENER_ALREADY_STOPPED.AsInteger(): desc = "Listener already stopped"; break; - case CHIP_ERROR_UNKNOWN_TOPIC.AsInteger(): - desc = "Unknown Topic"; + case CHIP_ERROR_INVALID_SUBSCRIPTION.AsInteger(): + desc = "Invalid Subscription Id"; break; case CHIP_ERROR_TIMEOUT.AsInteger(): desc = "Timeout"; diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index b09071be369d27..be898418b86b8e 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -1395,13 +1395,13 @@ using CHIP_ERROR = ::chip::ChipError; #define CHIP_ERROR_LISTENER_ALREADY_STOPPED CHIP_CORE_ERROR(0x6a) /** - * @def CHIP_ERROR_UNKNOWN_TOPIC + * @def CHIP_ERROR_INVALID_SUBSCRIPTION * * @brief - * A topic ID was unknown to the recipient. + * A message was received as part of a subscription exchange that has a mis-matching subscription id. * */ -#define CHIP_ERROR_UNKNOWN_TOPIC CHIP_CORE_ERROR(0x6b) +#define CHIP_ERROR_INVALID_SUBSCRIPTION CHIP_CORE_ERROR(0x6b) /** * @def CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index 67a9c40775455a..e071d13b55b792 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -155,7 +155,7 @@ static const CHIP_ERROR kTestElements[] = CHIP_ERROR_TRANSACTION_CANCELED, CHIP_ERROR_LISTENER_ALREADY_STARTED, CHIP_ERROR_LISTENER_ALREADY_STOPPED, - CHIP_ERROR_UNKNOWN_TOPIC, + CHIP_ERROR_INVALID_SUBSCRIPTION, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE, CHIP_ERROR_PASE_RECONFIGURE_REQUIRED, CHIP_ERROR_INVALID_PASE_CONFIGURATION,