Skip to content

Commit

Permalink
Add a way to update ReadPrepareParams based on CASE session. (#28078)
Browse files Browse the repository at this point in the history
If the ReadClient is doing the CASE establishment itself, it should give the
client a way to modify the ReadPrepareParams based on the session information.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Feb 1, 2024
1 parent f44c975 commit 1017152
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/BufferedReadCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class BufferedReadCallback : public ReadClient::Callback
return mCallback.OnUnsolicitedMessageFromPublisher(apReadClient);
}

void OnCASESessionEstablished(const SessionHandle & aSession, ReadPrepareParams & aSubscriptionParams) override
{
return mCallback.OnCASESessionEstablished(aSession, aSubscriptionParams);
}

/*
* Given a reader positioned at a list element, allocate a packet buffer, copy the list item where
* the reader is positioned into that buffer and add it to our buffered list for tracking.
Expand Down
5 changes: 5 additions & 0 deletions src/app/ClusterStateCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,11 @@ class ClusterStateCache : protected ReadClient::Callback
return mCallback.OnUnsolicitedMessageFromPublisher(apReadClient);
}

void OnCASESessionEstablished(const SessionHandle & aSession, ReadPrepareParams & aSubscriptionParams) override
{
return mCallback.OnCASESessionEstablished(aSession, aSubscriptionParams);
}

// Commit the pending cluster data version, if there is one.
void CommitPendingDataVersion();

Expand Down
2 changes: 2 additions & 0 deletions src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,8 @@ void ReadClient::HandleDeviceConnected(void * context, Messaging::ExchangeManage
_this->mReadPrepareParams.mSessionHolder.Grab(sessionHandle);
_this->mpExchangeMgr = &exchangeMgr;

_this->mpCallback.OnCASESessionEstablished(sessionHandle, _this->mReadPrepareParams);

auto err = _this->SendSubscribeRequest(_this->mReadPrepareParams);
if (err != CHIP_NO_ERROR)
{
Expand Down
10 changes: 10 additions & 0 deletions src/app/ReadClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ class ReadClient : public Messaging::ExchangeDelegate
* @param[in] apReadClient the ReadClient for the subscription.
*/
virtual void OnUnsolicitedMessageFromPublisher(ReadClient * apReadClient) {}

/**
* OnCASESessionEstablished will be called for a subscription ReadClient when
* it finishes setting up a CASE session, as part of either automatic
* re-subscription or doing an initial subscribe based on ScopedNodeId.
*
* The callee is allowed to modify the ReadPrepareParams (e.g. to change
* things like min/max intervals based on the session parameters).
*/
virtual void OnCASESessionEstablished(const SessionHandle & aSession, ReadPrepareParams & aSubscriptionParams) {}
};

enum class InteractionType : uint8_t
Expand Down

0 comments on commit 1017152

Please sign in to comment.