Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2020-2021 Project CHIP Authors
4 : * All rights reserved.
5 : *
6 : * Licensed under the Apache License, Version 2.0 (the "License");
7 : * you may not use this file except in compliance with the License.
8 : * You may obtain a copy of the License at
9 : *
10 : * http://www.apache.org/licenses/LICENSE-2.0
11 : *
12 : * Unless required by applicable law or agreed to in writing, software
13 : * distributed under the License is distributed on an "AS IS" BASIS,
14 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 : * See the License for the specific language governing permissions and
16 : * limitations under the License.
17 : */
18 :
19 : /**
20 : * @file
21 : * This file contains definitions for DeviceProxy base class. The objects of this
22 : * class will be used by applications to interact with peer CHIP devices.
23 : * The class provides mechanism to construct, send and receive messages to and
24 : * from the corresponding CHIP devices.
25 : */
26 :
27 : #pragma once
28 :
29 : #include <app/CommandSender.h>
30 : #include <lib/core/CHIPCallback.h>
31 : #include <lib/core/CHIPCore.h>
32 : #include <lib/support/DLLUtil.h>
33 : #include <system/SystemClock.h>
34 :
35 : namespace chip {
36 :
37 : class DLL_EXPORT DeviceProxy
38 : {
39 : public:
40 0 : virtual ~DeviceProxy() {}
41 0 : DeviceProxy() {}
42 :
43 : /**
44 : * Mark any open session with the device as expired.
45 : */
46 : virtual void Disconnect() = 0;
47 :
48 : virtual NodeId GetDeviceId() const = 0;
49 :
50 : virtual CHIP_ERROR SendCommands(app::CommandSender * commandObj, chip::Optional<System::Clock::Timeout> timeout = NullOptional);
51 :
52 : virtual Messaging::ExchangeManager * GetExchangeManager() const = 0;
53 :
54 : virtual chip::Optional<SessionHandle> GetSecureSession() const = 0;
55 :
56 0 : virtual CHIP_ERROR SetPeerId(ByteSpan rcac, ByteSpan noc) { return CHIP_ERROR_NOT_IMPLEMENTED; }
57 :
58 : /**
59 : * Facilities for keeping track of the latest point we can expect the
60 : * fail-safe to last through. These timestamp values use the monotonic clock.
61 : */
62 0 : void SetFailSafeExpirationTimestamp(System::Clock::Timestamp timestamp) { mFailSafeExpirationTimestamp = timestamp; }
63 0 : System::Clock::Timestamp GetFailSafeExpirationTimestamp() const { return mFailSafeExpirationTimestamp; }
64 :
65 : /**
66 : * @brief
67 : * This function returns the attestation challenge for the secure session.
68 : *
69 : * @param[out] attestationChallenge The output for the attestationChallenge
70 : *
71 : * @return CHIP_ERROR CHIP_NO_ERROR on success, or CHIP_ERROR_INVALID_ARGUMENT if no secure session is active
72 : */
73 : virtual CHIP_ERROR GetAttestationChallenge(ByteSpan & attestationChallenge);
74 :
75 : protected:
76 : virtual bool IsSecureConnected() const = 0;
77 :
78 : System::Clock::Timestamp mFailSafeExpirationTimestamp = System::Clock::kZero;
79 : };
80 :
81 : } // namespace chip
|