@@ -80,26 +80,20 @@ struct CopyAndAdjustDeltaTimeContext
80
80
EventLoadOutContext * mpContext = nullptr ;
81
81
};
82
82
83
- void EventManagement::Init (Messaging::ExchangeManager * apExchangeManager, uint32_t aNumBuffers,
84
- CircularEventBuffer * apCircularEventBuffer, const LogStorageResources * const apLogStorageResources,
85
- MonotonicallyIncreasingCounter<EventNumber> * apEventNumberCounter,
86
- System::Clock::Milliseconds64 aMonotonicStartupTime, EventReporter * apEventReporter)
83
+ CHIP_ERROR EventManagement::Init (Messaging::ExchangeManager * apExchangeManager, uint32_t aNumBuffers,
84
+ CircularEventBuffer * apCircularEventBuffer,
85
+ const LogStorageResources * const apLogStorageResources,
86
+ MonotonicallyIncreasingCounter<EventNumber> * apEventNumberCounter,
87
+ System::Clock::Milliseconds64 aMonotonicStartupTime, EventReporter * apEventReporter)
87
88
{
89
+ VerifyOrReturnError (apEventReporter != nullptr , CHIP_ERROR_INVALID_ARGUMENT);
90
+ VerifyOrReturnError (aNumBuffers != 0 , CHIP_ERROR_INVALID_ARGUMENT);
91
+ VerifyOrReturnError (mState == EventManagementStates::Shutdown, CHIP_ERROR_INCORRECT_STATE);
92
+
88
93
CircularEventBuffer * current = nullptr ;
89
94
CircularEventBuffer * prev = nullptr ;
90
95
CircularEventBuffer * next = nullptr ;
91
96
92
- if (aNumBuffers == 0 )
93
- {
94
- ChipLogError (EventLogging, " Invalid aNumBuffers" );
95
- return ;
96
- }
97
-
98
- if (mState != EventManagementStates::Shutdown)
99
- {
100
- ChipLogError (EventLogging, " Invalid EventManagement State" );
101
- return ;
102
- }
103
97
mpExchangeMgr = apExchangeManager;
104
98
105
99
for (uint32_t bufferIndex = 0 ; bufferIndex < aNumBuffers; bufferIndex++)
@@ -125,15 +119,9 @@ void EventManagement::Init(Messaging::ExchangeManager * apExchangeManager, uint3
125
119
126
120
mMonotonicStartupTime = aMonotonicStartupTime;
127
121
128
- // TODO(#36890): Should remove using the global instance and rely only on passed in variable.
129
- if (apEventReporter == nullptr )
130
- {
131
- mpEventReporter = &InteractionModelEngine::GetInstance ()->GetReportingEngine ();
132
- }
133
- else
134
- {
135
- mpEventReporter = apEventReporter;
136
- }
122
+ mpEventReporter = apEventReporter;
123
+
124
+ return CHIP_NO_ERROR;
137
125
}
138
126
139
127
CHIP_ERROR EventManagement::CopyToNextBuffer (CircularEventBuffer * apEventBuffer)
@@ -355,7 +343,7 @@ void EventManagement::CreateEventManagement(Messaging::ExchangeManager * apExcha
355
343
{
356
344
357
345
sInstance .Init (apExchangeManager, aNumBuffers, apCircularEventBuffer, apLogStorageResources, apEventNumberCounter,
358
- aMonotonicStartupTime);
346
+ aMonotonicStartupTime, & InteractionModelEngine::GetInstance ()-> GetReportingEngine () );
359
347
}
360
348
361
349
/* *
0 commit comments