Matter SDK Coverage Report
Current view: top level - app/MessageDef - InvokeResponseIBs.cpp (source / functions) Coverage Total Hit
Test: SHA:4d2388ac7eed75b2fe5e05e20de377999c632502 Lines: 100.0 % 40 40
Test Date: 2025-07-26 07:12:52 Functions: 100.0 % 5 5

            Line data    Source code
       1              : /**
       2              :  *
       3              :  *    Copyright (c) 2021 Project CHIP Authors
       4              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       5              :  *    you may not use this file except in compliance with the License.
       6              :  *    You may obtain a copy of the License at
       7              :  *
       8              :  *        http://www.apache.org/licenses/LICENSE-2.0
       9              :  *
      10              :  *    Unless required by applicable law or agreed to in writing, software
      11              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      12              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13              :  *    See the License for the specific language governing permissions and
      14              :  *    limitations under the License.
      15              :  */
      16              : 
      17              : #include "InvokeResponseIBs.h"
      18              : 
      19              : #include "MessageDefHelper.h"
      20              : 
      21              : #include <inttypes.h>
      22              : #include <stdarg.h>
      23              : #include <stdio.h>
      24              : 
      25              : #include <app/AppConfig.h>
      26              : 
      27              : namespace chip {
      28              : namespace app {
      29              : #if CHIP_CONFIG_IM_PRETTY_PRINT
      30           37 : CHIP_ERROR InvokeResponseIBs::Parser::PrettyPrint() const
      31              : {
      32           37 :     CHIP_ERROR err            = CHIP_NO_ERROR;
      33           37 :     size_t numInvokeResponses = 0;
      34           37 :     TLV::TLVReader reader;
      35              : 
      36           37 :     PRETTY_PRINT("InvokeResponseIBs =");
      37           37 :     PRETTY_PRINT("[");
      38              : 
      39              :     // make a copy of the reader
      40           37 :     reader.Init(mReader);
      41              : 
      42           81 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      43              :     {
      44           44 :         VerifyOrReturnError(TLV::AnonymousTag() == reader.GetTag(), CHIP_ERROR_INVALID_TLV_TAG);
      45              :         {
      46           44 :             InvokeResponseIB::Parser invokeResponse;
      47           44 :             ReturnErrorOnFailure(invokeResponse.Init(reader));
      48           44 :             PRETTY_PRINT_INCDEPTH();
      49           44 :             ReturnErrorOnFailure(invokeResponse.PrettyPrint());
      50           44 :             PRETTY_PRINT_DECDEPTH();
      51              :         }
      52              : 
      53           44 :         ++numInvokeResponses;
      54              :     }
      55              : 
      56           37 :     PRETTY_PRINT("],");
      57           37 :     PRETTY_PRINT_BLANK_LINE();
      58              : 
      59              :     // if we have exhausted this container
      60           37 :     if (CHIP_END_OF_TLV == err)
      61              :     {
      62              :         // if we have at least one response
      63           37 :         if (numInvokeResponses > 0)
      64              :         {
      65           37 :             err = CHIP_NO_ERROR;
      66              :         }
      67              :     }
      68           37 :     ReturnErrorOnFailure(err);
      69           37 :     return reader.ExitContainer(mOuterContainerType);
      70              : }
      71              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      72              : 
      73           57 : CHIP_ERROR InvokeResponseIBs::Builder::InitWithEndBufferReserved(TLV::TLVWriter * const apWriter, const uint8_t aContextTagToUse)
      74              : {
      75           57 :     ReturnErrorOnFailure(Init(apWriter, aContextTagToUse));
      76           57 :     ReturnErrorOnFailure(GetWriter()->ReserveBuffer(GetSizeToEndInvokeResponses()));
      77           57 :     mIsEndBufferReserved = true;
      78           57 :     return CHIP_NO_ERROR;
      79              : }
      80              : 
      81           75 : InvokeResponseIB::Builder & InvokeResponseIBs::Builder::CreateInvokeResponse()
      82              : {
      83           75 :     if (mError == CHIP_NO_ERROR)
      84              :     {
      85           75 :         mError = mInvokeResponse.Init(mpWriter);
      86              :     }
      87           75 :     return mInvokeResponse;
      88              : }
      89              : 
      90           55 : CHIP_ERROR InvokeResponseIBs::Builder::EndOfInvokeResponses()
      91              : {
      92              :     // If any changes are made to how we end the invoke responses that involves how many bytes are
      93              :     // needed, a corresponding change to GetSizeToEndInvokeResponses indicating the new size that
      94              :     // will be required.
      95           55 :     if (mIsEndBufferReserved)
      96              :     {
      97           49 :         ReturnErrorOnFailure(GetWriter()->UnreserveBuffer(GetSizeToEndInvokeResponses()));
      98           49 :         mIsEndBufferReserved = false;
      99              :     }
     100           55 :     EndOfContainer();
     101           55 :     return GetError();
     102              : }
     103              : 
     104          106 : uint32_t InvokeResponseIBs::Builder::GetSizeToEndInvokeResponses()
     105              : {
     106          106 :     uint32_t kEndOfContainerSize = 1;
     107          106 :     return kEndOfContainerSize;
     108              : }
     109              : } // namespace app
     110              : } // namespace chip
        

Generated by: LCOV version 2.0-1