forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMTROTAImageTransferHandler.h
83 lines (60 loc) · 3.03 KB
/
MTROTAImageTransferHandler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
*
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Matter/MTROTAProviderDelegate.h>
#include <protocols/bdx/AsyncTransferFacilitator.h>
NS_ASSUME_NONNULL_BEGIN
@class MTROTAImageTransferHandlerWrapper;
/**
* This class handles the BDX events for a BDX transfer session.
*
* This object may be destroyed directly, when not processing some call it made, to interrupt the BDX
* transfer. Specifically, this has to be done if the fabric it's associated with is shut down. This
* method of interrupting the BDX transfer will not notify the peer that we are interrupting and it will
* keep waiting until it times out.
*
* If not otherwise destroyed, this object will destroy itself when the transfer completes.
*/
class MTROTAImageTransferHandler : public chip::bdx::AsyncResponder {
public:
MTROTAImageTransferHandler(chip::System::Layer * layer);
~MTROTAImageTransferHandler();
chip::FabricIndex GetPeerFabricIndex() { return mPeer.GetFabricIndex(); }
protected:
CHIP_ERROR OnMessageReceived(chip::Messaging::ExchangeContext * ec, const chip::PayloadHeader & payloadHeader,
chip::System::PacketBufferHandle && payload) override;
void HandleTransferSessionOutput(chip::bdx::TransferSession::OutputEvent & event) override;
private:
CHIP_ERROR Init(chip::Messaging::ExchangeContext * exchangeCtx);
CHIP_ERROR OnTransferSessionBegin(const chip::bdx::TransferSession::OutputEventType event);
CHIP_ERROR OnTransferSessionEnd(const chip::bdx::TransferSession::OutputEventType eventType);
CHIP_ERROR OnBlockQuery(const chip::bdx::TransferSession::OutputEventType eventType, uint64_t bytesToSkip);
chip::ScopedNodeId GetPeerScopedNodeId(chip::Messaging::ExchangeContext * exchangeCtx);
void InvokeTransferSessionEndCallback(CHIP_ERROR error);
void DestroySelf() override;
// The scoped node id of the node with which the BDX session is established.
chip::ScopedNodeId mPeer;
// The OTA provider delegate that is responding to the BDX transfer request.
id<MTROTAProviderDelegate> mDelegate = nil;
chip::System::Layer * mSystemLayer = nil;
// The queue mDelegate must be called on.
dispatch_queue_t mDelegateNotificationQueue = nil;
MTROTAImageTransferHandlerWrapper * mOTAImageTransferHandlerWrapper;
bool mNeedToCallTransferSessionEnd = false;
bool mIsPeerNodeAKnownThreadDevice = NO;
chip::System::Clock::Milliseconds32 mBDXThrottleIntervalForThreadDevices;
};
NS_ASSUME_NONNULL_END