@@ -56,10 +56,6 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeCon
56
56
InteractionType aInteractionType, Observer * observer) :
57
57
mExchangeCtx (*this ),
58
58
mManagementCallback (apCallback)
59
- #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
60
- ,
61
- mOnConnectedCallback (HandleDeviceConnected, this ), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this )
62
- #endif
63
59
{
64
60
VerifyOrDie (apExchangeContext != nullptr );
65
61
@@ -84,8 +80,7 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeCon
84
80
85
81
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
86
82
ReadHandler::ReadHandler (ManagementCallback & apCallback, Observer * observer) :
87
- mExchangeCtx(*this ), mManagementCallback(apCallback), mOnConnectedCallback(HandleDeviceConnected, this ),
88
- mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this )
83
+ mExchangeCtx(*this ), mManagementCallback(apCallback)
89
84
{
90
85
mInteractionType = InteractionType::Subscribe;
91
86
mFlags .ClearAll ();
@@ -94,41 +89,57 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Observer * observer) :
94
89
mObserver = observer;
95
90
}
96
91
97
- void ReadHandler::ResumeSubscription (CASESessionManager & caseSessionManager ,
98
- SubscriptionResumptionStorage::SubscriptionInfo & subscriptionInfo )
92
+ void ReadHandler::OnSubscriptionResumed ( const SessionHandle & sessionHandle ,
93
+ SubscriptionResumptionSessionEstablisher & resumptionSessionEstablisher )
99
94
{
100
- mSubscriptionId = subscriptionInfo .mSubscriptionId ;
101
- mMinIntervalFloorSeconds = subscriptionInfo .mMinInterval ;
102
- mMaxInterval = subscriptionInfo .mMaxInterval ;
103
- SetStateFlag (ReadHandlerFlags::FabricFiltered, subscriptionInfo .mFabricFiltered );
95
+ mSubscriptionId = resumptionSessionEstablisher. mSubscriptionInfo .mSubscriptionId ;
96
+ mMinIntervalFloorSeconds = resumptionSessionEstablisher. mSubscriptionInfo .mMinInterval ;
97
+ mMaxInterval = resumptionSessionEstablisher. mSubscriptionInfo .mMaxInterval ;
98
+ SetStateFlag (ReadHandlerFlags::FabricFiltered, resumptionSessionEstablisher. mSubscriptionInfo .mFabricFiltered );
104
99
105
100
// Move dynamically allocated attributes and events from the SubscriptionInfo struct into
106
101
// the object pool managed by the IM engine
107
- for (size_t i = 0 ; i < subscriptionInfo .mAttributePaths .AllocatedSize (); i++)
102
+ for (size_t i = 0 ; i < resumptionSessionEstablisher. mSubscriptionInfo .mAttributePaths .AllocatedSize (); i++)
108
103
{
109
- AttributePathParams attributePathParams = subscriptionInfo.mAttributePaths [i].GetParams ();
110
- CHIP_ERROR err =
111
- InteractionModelEngine::GetInstance ()->PushFrontAttributePathList (mpAttributePathList, attributePathParams);
104
+ AttributePathParams params = resumptionSessionEstablisher.mSubscriptionInfo .mAttributePaths [i].GetParams ();
105
+ CHIP_ERROR err = InteractionModelEngine::GetInstance ()->PushFrontAttributePathList (mpAttributePathList, params);
112
106
if (err != CHIP_NO_ERROR)
113
107
{
114
108
Close ();
115
109
return ;
116
110
}
117
111
}
118
- for (size_t i = 0 ; i < subscriptionInfo .mEventPaths .AllocatedSize (); i++)
112
+ for (size_t i = 0 ; i < resumptionSessionEstablisher. mSubscriptionInfo .mEventPaths .AllocatedSize (); i++)
119
113
{
120
- EventPathParams eventPathParams = subscriptionInfo .mEventPaths [i].GetParams ();
121
- CHIP_ERROR err = InteractionModelEngine::GetInstance ()->PushFrontEventPathParamsList (mpEventPathList, eventPathParams );
114
+ EventPathParams params = resumptionSessionEstablisher. mSubscriptionInfo .mEventPaths [i].GetParams ();
115
+ CHIP_ERROR err = InteractionModelEngine::GetInstance ()->PushFrontEventPathParamsList (mpEventPathList, params );
122
116
if (err != CHIP_NO_ERROR)
123
117
{
124
118
Close ();
125
119
return ;
126
120
}
127
121
}
128
122
129
- // Ask IM engine to start CASE session with subscriber
130
- ScopedNodeId peerNode = ScopedNodeId (subscriptionInfo.mNodeId , subscriptionInfo.mFabricIndex );
131
- caseSessionManager.FindOrEstablishSession (peerNode, &mOnConnectedCallback , &mOnConnectionFailureCallback );
123
+ mSessionHandle .Grab (sessionHandle);
124
+
125
+ SetStateFlag (ReadHandlerFlags::ActiveSubscription);
126
+
127
+ auto * appCallback = mManagementCallback .GetAppCallback ();
128
+ if (appCallback)
129
+ {
130
+ appCallback->OnSubscriptionEstablished (*this );
131
+ }
132
+ // Notify the observer that a subscription has been resumed
133
+ mObserver ->OnSubscriptionEstablished (this );
134
+
135
+ MoveToState (HandlerState::CanStartReporting);
136
+
137
+ ObjectList<AttributePathParams> * attributePath = mpAttributePathList;
138
+ while (attributePath)
139
+ {
140
+ InteractionModelEngine::GetInstance ()->GetReportingEngine ().SetDirty (attributePath->mValue );
141
+ attributePath = attributePath->mpNext ;
142
+ }
132
143
}
133
144
134
145
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
@@ -893,43 +904,5 @@ void ReadHandler::ClearStateFlag(ReadHandlerFlags aFlag)
893
904
SetStateFlag (aFlag, false );
894
905
}
895
906
896
- void ReadHandler::HandleDeviceConnected (void * context, Messaging::ExchangeManager & exchangeMgr,
897
- const SessionHandle & sessionHandle)
898
- {
899
- ReadHandler * const _this = static_cast <ReadHandler *>(context);
900
-
901
- _this->mSessionHandle .Grab (sessionHandle);
902
-
903
- _this->SetStateFlag (ReadHandlerFlags::ActiveSubscription);
904
-
905
- auto * appCallback = _this->mManagementCallback .GetAppCallback ();
906
- if (appCallback)
907
- {
908
- appCallback->OnSubscriptionEstablished (*_this);
909
- }
910
- // Notify the observer that a subscription has been resumed
911
- _this->mObserver ->OnSubscriptionEstablished (_this);
912
-
913
- _this->MoveToState (HandlerState::CanStartReporting);
914
-
915
- ObjectList<AttributePathParams> * attributePath = _this->mpAttributePathList ;
916
- while (attributePath)
917
- {
918
- InteractionModelEngine::GetInstance ()->GetReportingEngine ().SetDirty (attributePath->mValue );
919
- attributePath = attributePath->mpNext ;
920
- }
921
- }
922
-
923
- void ReadHandler::HandleDeviceConnectionFailure (void * context, const ScopedNodeId & peerId, CHIP_ERROR err)
924
- {
925
- ReadHandler * const _this = static_cast <ReadHandler *>(context);
926
- VerifyOrDie (_this != nullptr );
927
-
928
- // TODO: Have a retry mechanism tied to wake interval for IC devices
929
- ChipLogError (DataManagement, " Failed to establish CASE for subscription-resumption with error '%" CHIP_ERROR_FORMAT " '" ,
930
- err.Format ());
931
- _this->Close ();
932
- }
933
-
934
907
} // namespace app
935
908
} // namespace chip
0 commit comments