Skip to content

Commit a3cd500

Browse files
committedSep 6, 2024
Add GetNextAction API so that a caller that might want to implement an event driven mechanism to drive the BDX transfer can get the next output event from the TransferSession on demand
Currently we have the PollOutput API where the expectation is the caller needs to poll frequently for the next output event from the TransferSession which introduces a delay based on the poll interval in handling every single BDX message or transfer session event handled by the caller.
1 parent 96e687b commit a3cd500

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
 

‎src/protocols/bdx/BdxTransferSession.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ void TransferSession::PollOutput(OutputEvent & event, System::Clock::Timestamp c
134134
mPendingOutput = OutputEventType::kNone;
135135
}
136136

137+
void TransferSession::GetNextAction(OutputEvent & event)
138+
{
139+
PollOutput(event, System::SystemClock().GetMonotonicTimestamp());
140+
}
141+
137142
CHIP_ERROR TransferSession::StartTransfer(TransferRole role, const TransferInitData & initData, System::Clock::Timeout timeout)
138143
{
139144
VerifyOrReturnError(mState == TransferState::kUnitialized, CHIP_ERROR_INCORRECT_STATE);

‎src/protocols/bdx/BdxTransferSession.h

+18
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,24 @@ class DLL_EXPORT TransferSession
165165
*/
166166
void PollOutput(OutputEvent & event, System::Clock::Timestamp curTime);
167167

168+
/**
169+
* @brief
170+
* Gets the pending output event from the transfer session in the event param passed in by the caller.
171+
* The output event may contain some data for the caller to act upon.
172+
*
173+
* It is possible that consecutive calls to this method may emit different outputs depending on the state of the
174+
* TransferSession object and so we need to call this until we get an event of type - OutputEventType::kNone
175+
*
176+
* Note that if the event type is kMsgToSend, the caller is expected to send the message immediately over the
177+
* exchange otherwise the caller is expected to pass the event to HandleTransferSessionOutput to handle the BDX
178+
* message or any other TransferSession event.
179+
*
180+
* See OutputEventType for all possible output event types.
181+
*
182+
* @param event Reference to an OutputEvent struct that will be filled out with any pending output event data
183+
*/
184+
void GetNextAction(OutputEvent & event);
185+
168186
/**
169187
* @brief
170188
* Initializes the TransferSession object and prepares a TransferInit message (emitted via PollOutput()).

0 commit comments

Comments
 (0)