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 implementation of Device class. The objects of this 22 : * class will be used by Controller applications to interact with CHIP 23 : * devices. The class provides mechanism to construct, send and receive 24 : * messages to and from the corresponding CHIP devices. 25 : */ 26 : 27 : #include <app/DeviceProxy.h> 28 : 29 : #include <app/CommandSender.h> 30 : #include <app/ReadPrepareParams.h> 31 : #include <lib/core/CHIPCore.h> 32 : #include <lib/core/CHIPEncoding.h> 33 : #include <lib/dnssd/Resolver.h> 34 : #include <lib/support/CodeUtils.h> 35 : #include <lib/support/logging/CHIPLogging.h> 36 : 37 : using namespace chip::Callback; 38 : 39 : namespace chip { 40 : 41 0 : CHIP_ERROR DeviceProxy::SendCommands(app::CommandSender * commandObj, Optional<System::Clock::Timeout> timeout) 42 : { 43 0 : VerifyOrReturnLogError(IsSecureConnected(), CHIP_ERROR_INCORRECT_STATE); 44 0 : VerifyOrReturnError(commandObj != nullptr, CHIP_ERROR_INVALID_ARGUMENT); 45 0 : return commandObj->SendCommandRequest(GetSecureSession().Value(), timeout); 46 : } 47 : 48 0 : CHIP_ERROR DeviceProxy::GetAttestationChallenge(ByteSpan & attestationChallenge) 49 : { 50 0 : Optional<SessionHandle> secureSessionHandle; 51 : 52 0 : secureSessionHandle = GetSecureSession(); 53 0 : VerifyOrReturnError(secureSessionHandle.HasValue(), CHIP_ERROR_INCORRECT_STATE); 54 : 55 0 : attestationChallenge = secureSessionHandle.Value()->AsSecureSession()->GetCryptoContext().GetAttestationChallenge(); 56 0 : return CHIP_NO_ERROR; 57 0 : } 58 : 59 : } // namespace chip