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

            Line data    Source code
       1              : /**
       2              :  *
       3              :  *    Copyright (c) 2020 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 "CommandDataIB.h"
      20              : 
      21              : #include "MessageDefHelper.h"
      22              : 
      23              : #include <inttypes.h>
      24              : #include <stdarg.h>
      25              : #include <stdio.h>
      26              : 
      27              : #include <app/AppConfig.h>
      28              : 
      29              : namespace chip {
      30              : namespace app {
      31              : #if CHIP_CONFIG_IM_PRETTY_PRINT
      32           69 : CHIP_ERROR CommandDataIB::Parser::PrettyPrint() const
      33              : {
      34           69 :     CHIP_ERROR err = CHIP_NO_ERROR;
      35           69 :     TLV::TLVReader reader;
      36              : 
      37           69 :     PRETTY_PRINT("CommandDataIB =");
      38           69 :     PRETTY_PRINT("{");
      39              : 
      40              :     // make a copy of the reader
      41           69 :     reader.Init(mReader);
      42              : 
      43          213 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      44              :     {
      45          144 :         if (!TLV::IsContextTag(reader.GetTag()))
      46              :         {
      47            0 :             continue;
      48              :         }
      49          144 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      50              : 
      51          144 :         switch (tagNum)
      52              :         {
      53           69 :         case to_underlying(Tag::kPath): {
      54           69 :             CommandPathIB::Parser path;
      55           69 :             ReturnErrorOnFailure(path.Init(reader));
      56           69 :             PRETTY_PRINT_INCDEPTH();
      57           69 :             ReturnErrorOnFailure(path.PrettyPrint());
      58           69 :             PRETTY_PRINT_DECDEPTH();
      59              :         }
      60              : 
      61           69 :         break;
      62           64 :         case to_underlying(Tag::kFields):
      63           64 :             PRETTY_PRINT_INCDEPTH();
      64           64 :             ReturnErrorOnFailure(CheckIMPayload(reader, 0, "CommandFields"));
      65           64 :             PRETTY_PRINT_DECDEPTH();
      66           64 :             break;
      67           10 :         case to_underlying(Tag::kRef):
      68           10 :             VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      69              :             {
      70              :                 uint16_t reference;
      71           10 :                 ReturnErrorOnFailure(reader.Get(reference));
      72           10 :                 PRETTY_PRINT("\tRef = 0x%x,", reference);
      73              :             }
      74           10 :             break;
      75            1 :         default:
      76            1 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      77            1 :             break;
      78              :         }
      79              :     }
      80              : 
      81           69 :     PRETTY_PRINT("},");
      82           69 :     PRETTY_PRINT_BLANK_LINE();
      83              : 
      84           69 :     if (CHIP_END_OF_TLV == err)
      85              :     {
      86           69 :         err = CHIP_NO_ERROR;
      87              :     }
      88              : 
      89           69 :     ReturnErrorOnFailure(err);
      90           69 :     return reader.ExitContainer(mOuterContainerType);
      91              : }
      92              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      93              : 
      94          100 : CHIP_ERROR CommandDataIB::Parser::GetPath(CommandPathIB::Parser * const apPath) const
      95              : {
      96          100 :     TLV::TLVReader reader;
      97          100 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kPath), reader));
      98          100 :     return apPath->Init(reader);
      99              : }
     100              : 
     101           41 : CHIP_ERROR CommandDataIB::Parser::GetFields(TLV::TLVReader * const apReader) const
     102              : {
     103           41 :     ReturnErrorOnFailure(mReader.FindElementWithTag(TLV::ContextTag(Tag::kFields), *apReader));
     104           39 :     return CHIP_NO_ERROR;
     105              : }
     106              : 
     107           56 : CHIP_ERROR CommandDataIB::Parser::GetRef(uint16_t * const apRef) const
     108              : {
     109           56 :     return GetUnsignedInteger(to_underlying(Tag::kRef), apRef);
     110              : }
     111              : 
     112           89 : CommandPathIB::Builder & CommandDataIB::Builder::CreatePath()
     113              : {
     114           89 :     mError = mPath.Init(mpWriter, to_underlying(Tag::kPath));
     115           89 :     return mPath;
     116              : }
     117              : 
     118           23 : CHIP_ERROR CommandDataIB::Builder::Ref(const uint16_t aRef)
     119              : {
     120           23 :     return mpWriter->Put(TLV::ContextTag(Tag::kRef), aRef);
     121              : }
     122              : 
     123           84 : CHIP_ERROR CommandDataIB::Builder::EndOfCommandDataIB()
     124              : {
     125           84 :     EndOfContainer();
     126           84 :     return GetError();
     127              : }
     128              : } // namespace app
     129              : } // namespace chip
        

Generated by: LCOV version 2.0-1