Line data Source code
1 : /** 2 : * 3 : * Copyright (c) 2020-2021 Project CHIP Authors 4 : * Copyright (c) 2018 Google LLC. 5 : * Copyright (c) 2016-2017 Nest Labs, Inc. 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 : #include "AttributeStatusIBs.h" 20 : #include "AttributeStatusIB.h" 21 : 22 : #include "MessageDefHelper.h" 23 : 24 : #include <inttypes.h> 25 : #include <stdarg.h> 26 : #include <stdio.h> 27 : 28 : #include <app/AppConfig.h> 29 : 30 : namespace chip { 31 : namespace app { 32 2497 : AttributeStatusIB::Builder & AttributeStatusIBs::Builder::CreateAttributeStatus() 33 : { 34 2497 : if (mError == CHIP_NO_ERROR) 35 : { 36 2497 : mError = mAttributeStatus.Init(mpWriter); 37 : } 38 2497 : return mAttributeStatus; 39 : } 40 : 41 1736 : CHIP_ERROR AttributeStatusIBs::Builder::EndOfAttributeStatuses() 42 : { 43 1736 : EndOfContainer(); 44 1736 : return GetError(); 45 : } 46 : 47 : #if CHIP_CONFIG_IM_PRETTY_PRINT 48 1728 : CHIP_ERROR AttributeStatusIBs::Parser::PrettyPrint() const 49 : { 50 1728 : CHIP_ERROR err = CHIP_NO_ERROR; 51 : TLV::TLVReader reader; 52 : 53 1728 : PRETTY_PRINT("AttributeStatusIBs ="); 54 1728 : PRETTY_PRINT("["); 55 : 56 : // make a copy of the AttributeStatusIBs reader 57 1728 : reader.Init(mReader); 58 : 59 4211 : while (CHIP_NO_ERROR == (err = reader.Next())) 60 : { 61 2483 : VerifyOrReturnError(TLV::AnonymousTag() == reader.GetTag(), CHIP_ERROR_INVALID_TLV_TAG); 62 : { 63 2483 : AttributeStatusIB::Parser status; 64 2483 : ReturnErrorOnFailure(status.Init(reader)); 65 : 66 2483 : PRETTY_PRINT_INCDEPTH(); 67 2483 : ReturnErrorOnFailure(status.PrettyPrint()); 68 2483 : PRETTY_PRINT_DECDEPTH(); 69 : } 70 : } 71 : 72 1728 : PRETTY_PRINT("],"); 73 1728 : PRETTY_PRINT_BLANK_LINE(); 74 : // if we have exhausted this container 75 1728 : if (CHIP_END_OF_TLV == err) 76 : { 77 1728 : err = CHIP_NO_ERROR; 78 : } 79 1728 : ReturnErrorOnFailure(err); 80 1728 : return reader.ExitContainer(mOuterContainerType); 81 : } 82 : #endif // CHIP_CONFIG_IM_PRETTY_PRINT 83 : }; // namespace app 84 : }; // namespace chip