blob: 739c4bd4cb91772b5376ca719b613341026accbe [file] [log] [blame]
Pankaj Garga04576d2021-11-08 15:04:13 -08001/*
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>
Pankaj Garga04576d2021-11-08 15:04:13 -080030#include <lib/core/CHIPCallback.h>
31#include <lib/core/CHIPCore.h>
32#include <lib/support/DLLUtil.h>
Boris Zbarskye42b5332023-03-14 00:13:25 -040033#include <system/SystemClock.h>
Pankaj Garga04576d2021-11-08 15:04:13 -080034
35namespace chip {
36
37class DLL_EXPORT DeviceProxy
38{
39public:
40 virtual ~DeviceProxy() {}
41 DeviceProxy() {}
42
43 /**
Pankaj Garga04576d2021-11-08 15:04:13 -080044 * Mark any open session with the device as expired.
45 */
Michael Spang63870492022-06-28 08:41:08 -040046 virtual void Disconnect() = 0;
Pankaj Garga04576d2021-11-08 15:04:13 -080047
48 virtual NodeId GetDeviceId() const = 0;
49
C Freeman8ee96e42022-01-21 11:43:45 -050050 virtual CHIP_ERROR SendCommands(app::CommandSender * commandObj, chip::Optional<System::Clock::Timeout> timeout = NullOptional);
Pankaj Garga04576d2021-11-08 15:04:13 -080051
Pankaj Garga04576d2021-11-08 15:04:13 -080052 virtual Messaging::ExchangeManager * GetExchangeManager() const = 0;
53
54 virtual chip::Optional<SessionHandle> GetSecureSession() const = 0;
55
C Freeman09a49212022-01-24 21:19:43 -050056 virtual CHIP_ERROR SetPeerId(ByteSpan rcac, ByteSpan noc) { return CHIP_ERROR_NOT_IMPLEMENTED; }
57
Boris Zbarskye42b5332023-03-14 00:13:25 -040058 /**
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 void SetFailSafeExpirationTimestamp(System::Clock::Timestamp timestamp) { mFailSafeExpirationTimestamp = timestamp; }
63 System::Clock::Timestamp GetFailSafeExpirationTimestamp() const { return mFailSafeExpirationTimestamp; }
Pankaj Garga04576d2021-11-08 15:04:13 -080064
Kevin Coppock2d6bb3a2022-05-31 08:54:33 -050065 /**
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 */
Kevin Coppock91117572022-06-01 11:58:16 -050073 virtual CHIP_ERROR GetAttestationChallenge(ByteSpan & attestationChallenge);
Kevin Coppock2d6bb3a2022-05-31 08:54:33 -050074
Pankaj Garga04576d2021-11-08 15:04:13 -080075protected:
76 virtual bool IsSecureConnected() const = 0;
77
Boris Zbarskye42b5332023-03-14 00:13:25 -040078 System::Clock::Timestamp mFailSafeExpirationTimestamp = System::Clock::kZero;
Pankaj Garga04576d2021-11-08 15:04:13 -080079};
80
Pankaj Garga04576d2021-11-08 15:04:13 -080081} // namespace chip