Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establish CASE on re-subscription #20080

Merged
merged 14 commits into from
Jul 27, 2022
4 changes: 2 additions & 2 deletions src/app/BufferedReadCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class BufferedReadCallback : public ReadClient::Callback
mCallback.OnSubscriptionEstablished(aSubscriptionId);
}

void OnResubscriptionAttempt(CHIP_ERROR aTerminationCause, uint32_t aNextResubscribeIntervalMsec) override
CHIP_ERROR OnResubscriptionNeeded(ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override
{
mCallback.OnResubscriptionAttempt(aTerminationCause, aNextResubscribeIntervalMsec);
return mCallback.OnResubscriptionNeeded(apReadClient, aTerminationCause);
}

void OnDeallocatePaths(chip::app::ReadPrepareParams && aReadPrepareParams) override
Expand Down
4 changes: 2 additions & 2 deletions src/app/ClusterStateCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ class ClusterStateCache : protected ReadClient::Callback
mCallback.OnSubscriptionEstablished(aSubscriptionId);
}

void OnResubscriptionAttempt(CHIP_ERROR aTerminationCause, uint32_t aNextResubscribeIntervalMsec) override
CHIP_ERROR OnResubscriptionNeeded(ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override
{
mCallback.OnResubscriptionAttempt(aTerminationCause, aNextResubscribeIntervalMsec);
return mCallback.OnResubscriptionNeeded(apReadClient, aTerminationCause);
}

void OnDeallocatePaths(chip::app::ReadPrepareParams && aReadPrepareParams) override
Expand Down
1 change: 0 additions & 1 deletion src/app/DeviceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#pragma once

#include <app/CommandSender.h>
#include <app/InteractionModelEngine.h>
#include <lib/core/CHIPCallback.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/DLLUtil.h>
Expand Down
22 changes: 18 additions & 4 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ InteractionModelEngine * InteractionModelEngine::GetInstance()
return &sInteractionModelEngine;
}

CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeMgr, FabricTable * apFabricTable)
CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeMgr, FabricTable * apFabricTable,
CASESessionManager * apCASESessionMgr)
{
mpExchangeMgr = apExchangeMgr;
mpFabricTable = apFabricTable;
VerifyOrReturnError(apFabricTable != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(apExchangeMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

mpExchangeMgr = apExchangeMgr;
mpFabricTable = apFabricTable;
mpCASESessionMgr = apCASESessionMgr;
mrjerryjohns marked this conversation as resolved.
Show resolved Hide resolved

ReturnErrorOnFailure(mpExchangeMgr->RegisterUnsolicitedMessageHandlerForProtocol(Protocols::InteractionModel::Id, this));
VerifyOrReturnError(mpFabricTable != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

mReportingEngine.Init();
mMagic++;
Expand Down Expand Up @@ -122,6 +126,16 @@ void InteractionModelEngine::Shutdown()
mEventPathPool.ReleaseAll();
mDataVersionFilterPool.ReleaseAll();
mpExchangeMgr->UnregisterUnsolicitedMessageHandlerForProtocol(Protocols::InteractionModel::Id);

mpCASESessionMgr = nullptr;

//
// We _should_ be clearing these out, but doing so invites a world
// of trouble. #21233 tracks fixing the underlying assumptions to make
// this possible.
//
// mpFabricTable = nullptr;
// mpExchangeMgr = nullptr;
}

uint32_t InteractionModelEngine::GetNumActiveReadHandlers() const
Expand Down
19 changes: 17 additions & 2 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
#include <app/util/attribute-metadata.h>
#include <app/util/basic-types.h>

#include <app/CASESessionManager.h>

namespace chip {
namespace app {

Expand Down Expand Up @@ -102,17 +104,28 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
* Initialize the InteractionModel Engine.
*
* @param[in] apExchangeMgr A pointer to the ExchangeManager object.
* @param[in] apFabricTable A pointer to the FabricTable object.
* @param[in] apCASESessionMgr An optional pointer to a CASESessionManager (used for re-subscriptions).
*
* @retval #CHIP_ERROR_INCORRECT_STATE If the state is not equal to
* kState_NotInitialized.
* @retval #CHIP_NO_ERROR On success.
*
*/
CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr, FabricTable * apFabricTable);
CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr, FabricTable * apFabricTable,
CASESessionManager * apCASESessionMgr = nullptr);
msandstedt marked this conversation as resolved.
Show resolved Hide resolved

void Shutdown();

Messaging::ExchangeManager * GetExchangeManager(void) const { return mpExchangeMgr; };
Messaging::ExchangeManager * GetExchangeManager(void) const { return mpExchangeMgr; }

/**
* Returns a pointer to the CASESessionManager. This can return nullptr if one wasn't
* provided in the call to Init().
*/
CASESessionManager * GetCASESessionManager() const { return mpCASESessionMgr; }
mrjerryjohns marked this conversation as resolved.
Show resolved Hide resolved

FabricTable * GetFabricTable() const { return mpFabricTable; }
mrjerryjohns marked this conversation as resolved.
Show resolved Hide resolved

/**
* Tears down an active subscription.
Expand Down Expand Up @@ -551,6 +564,8 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

FabricTable * mpFabricTable;

CASESessionManager * mpCASESessionMgr = nullptr;
mrjerryjohns marked this conversation as resolved.
Show resolved Hide resolved

// A magic number for tracking values between stack Shutdown()-s and Init()-s.
// An ObjectHandle is valid iff. its magic equals to this one.
uint32_t mMagic = 0;
Expand Down
9 changes: 4 additions & 5 deletions src/app/OperationalDeviceProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
* messages to and from the corresponding CHIP devices.
*/

#include "OperationalDeviceProxy.h"
#include <app/OperationalDeviceProxy.h>

#include "CASEClient.h"
#include "CommandSender.h"
#include "ReadPrepareParams.h"
#include "transport/SecureSession.h"
#include <app/CASEClient.h>
#include <app/InteractionModelEngine.h>
bzbarsky-apple marked this conversation as resolved.
Show resolved Hide resolved
#include <transport/SecureSession.h>

#include <lib/address_resolve/AddressResolve.h>
#include <lib/core/CHIPCore.h>
Expand Down
Loading