21
21
namespace chip {
22
22
namespace bdx {
23
23
24
+ /* *
25
+ * Releases the exchange, resets the transfer session and schedules calling the DestroySelf
26
+ * virtual method implemented by the subclass to delete the subclass.
27
+ */
24
28
void AsyncTransferFacilitator::CleanUp ()
25
29
{
26
30
mExchange .Release ();
@@ -52,6 +56,11 @@ bdx::StatusCode AsyncTransferFacilitator::GetBdxStatusCodeFromChipError(CHIP_ERR
52
56
return bdx::StatusCode::kUnknown ;
53
57
}
54
58
59
+ /* *
60
+ * Calls the GetNextAction on the TransferSession to get the next output events until it receives TransferSession::OutputEventType::kNone
61
+ * If the output event is of type TransferSession::OutputEventType::kMsgToSend, it sends the message over the exchange context, otherwise it
62
+ * calls the HandleTransferSessionOutput method implemented by the subclass to handle the BDX message.
63
+ */
55
64
void AsyncTransferFacilitator::HandleNextOutputEvents ()
56
65
{
57
66
if (mHandlingOutputEvents )
@@ -64,7 +73,7 @@ void AsyncTransferFacilitator::HandleNextOutputEvents()
64
73
65
74
// Get the next output event and handle it based on the type of event.
66
75
// If its of type kMsgToSend send it over the exchange, otherwise call the HandleTransferSessionOutput
67
- // virtual method that must be implemeted by the subclass to handle the output events .
76
+ // virtual method that must be implemeted by the subclass of this class to handle the BDX message .
68
77
TransferSession::OutputEvent outEvent;
69
78
70
79
mTransfer .GetNextAction (outEvent);
@@ -103,9 +112,9 @@ CHIP_ERROR AsyncTransferFacilitator::SendMessage(const TransferSession::MessageT
103
112
104
113
CHIP_ERROR err = ec->SendMessage (msgTypeData.ProtocolId , msgTypeData.MessageType , std::move (msgBuf), sendFlags);
105
114
106
- // If we failed to send the message across the exchange or if we just sent a status report , there is no way to let the other side know there was
107
- // and error sending the message so call CleanUp to release the exchange and clean up so the other side can get notified the exchange is closing
108
- // and clean up as needed.
115
+ // If we failed to send the message across the exchange, there is no way to let the other side know there was an error sending
116
+ // the message so call CleanUp to release the exchange so the other side can get notified the exchange is closing
117
+ // and clean up as needed. Also the CleanUp API resets the transfer session and destroys the subclass.
109
118
if (err != CHIP_NO_ERROR)
110
119
{
111
120
CleanUp ();
@@ -127,7 +136,7 @@ CHIP_ERROR AsyncTransferFacilitator::OnMessageReceived(Messaging::ExchangeContex
127
136
ChipLogError (BDX, " OnMessageReceived: Failed to handle message: %" CHIP_ERROR_FORMAT, err.Format ());
128
137
129
138
// This should notify the tranfer object to abort transfer so it can send a status report across the exchange
130
- // and clean up when we call HandleNextOutputEvents below.
139
+ // when we call HandleNextOutputEvents below.
131
140
mTransfer .AbortTransfer (AsyncResponder::GetBdxStatusCodeFromChipError (err));
132
141
133
142
}
@@ -176,8 +185,7 @@ void AsyncResponder::NotifyEventHandled(TransferSession::OutputEvent & event, CH
176
185
ChipLogDetail (BDX, " NotifyEventHandled : Event %s Error %" CHIP_ERROR_FORMAT, event.ToString (event.EventType ), error.Format ());
177
186
178
187
// If it's a message indicating either the end of the transfer or a timeout reported by the transfer session
179
- // or an error occured, we need to call the CleanUp method that calls the DestroySelf virtual method implemented
180
- // by the subclass to delete both the sublcass and base class objects.
188
+ // or an error occured, we need to call CleanUp.
181
189
if (event.EventType == TransferSession::OutputEventType::kAckEOFReceived ||
182
190
event.EventType == TransferSession::OutputEventType::kInternalError ||
183
191
event.EventType == TransferSession::OutputEventType::kTransferTimeout ||
@@ -187,8 +195,8 @@ void AsyncResponder::NotifyEventHandled(TransferSession::OutputEvent & event, CH
187
195
return ;
188
196
}
189
197
190
- // If there was an error, this should notify the tranfer object to abort transfer so it can send a status report
191
- // across the exchange and clean up when we call HandleNextOutputEvents below.
198
+ // If there was an error handling the output event , this should notify the tranfer object to abort transfer so it can send a status report
199
+ // across the exchange when we call HandleNextOutputEvents below.
192
200
if (error != CHIP_NO_ERROR)
193
201
{
194
202
mTransfer .AbortTransfer (GetBdxStatusCodeFromChipError (error));
0 commit comments