diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index fdeac7ed454518..11cabe42dabc44 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -44,7 +44,6 @@ ReadClient::ReadClient(InteractionModelEngine * apImEngine, Messaging::ExchangeM mpCallback(apCallback), mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) { - // Error if already initialized. mpExchangeMgr = apExchangeMgr; mpCallback = apCallback; mInteractionType = aInteractionType; @@ -1094,6 +1093,7 @@ void ReadClient::HandleDeviceConnected(void * context, Messaging::ExchangeManage ChipLogProgress(DataManagement, "HandleDeviceConnected"); _this->mReadPrepareParams.mSessionHolder.Grab(sessionHandle); + _this->mpExchangeMgr = &exchangeMgr; auto err = _this->SendSubscribeRequest(_this->mReadPrepareParams); if (err != CHIP_NO_ERROR) diff --git a/src/app/ReadClient.h b/src/app/ReadClient.h index 0951b0bec1cc0e..4b0868c98798ef 100644 --- a/src/app/ReadClient.h +++ b/src/app/ReadClient.h @@ -267,7 +267,9 @@ class ReadClient : public Messaging::ExchangeDelegate * this object will cease to function correctly since it depends on the engine for a number of critical functions. * * @param[in] apImEngine A valid pointer to the IM engine. - * @param[in] apExchangeMgr A pointer to the ExchangeManager object. + * @param[in] apExchangeMgr A pointer to the ExchangeManager object. Allowed to be null + * if the version of SendAutoResubscribeRequest that takes a + * ScopedNodeId is used. * @param[in] apCallback Callback set by application. * @param[in] aInteractionType Type of interaction (read or subscribe) *