Matter SDK Coverage Report
Current view: top level - app/MessageDef - ClusterPathIB.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 92.9 % 56 52
Test Date: 2025-01-17 19:00:11 Functions: 100.0 % 8 8

            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 "ClusterPathIB.h"
      18              : #include "MessageDefHelper.h"
      19              : 
      20              : #include <inttypes.h>
      21              : #include <stdarg.h>
      22              : #include <stdio.h>
      23              : 
      24              : #include <app/AppConfig.h>
      25              : 
      26              : namespace chip {
      27              : namespace app {
      28              : #if CHIP_CONFIG_IM_PRETTY_PRINT
      29         2497 : CHIP_ERROR ClusterPathIB::Parser::PrettyPrint() const
      30              : {
      31         2497 :     CHIP_ERROR err = CHIP_NO_ERROR;
      32         2497 :     TLV::TLVReader reader;
      33              : 
      34         2497 :     PRETTY_PRINT("ClusterPathIB =");
      35         2497 :     PRETTY_PRINT("{");
      36              : 
      37              :     // make a copy of the Path reader
      38         2497 :     reader.Init(mReader);
      39              : 
      40         7496 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      41              :     {
      42         4999 :         if (!TLV::IsContextTag(reader.GetTag()))
      43              :         {
      44            0 :             continue;
      45              :         }
      46         4999 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      47         4999 :         switch (tagNum)
      48              :         {
      49            5 :         case to_underlying(Tag::kNode):
      50            5 :             VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
      51              : 
      52              : #if CHIP_DETAIL_LOGGING
      53              :             {
      54              :                 NodeId node;
      55            5 :                 reader.Get(node);
      56            5 :                 PRETTY_PRINT("\tNode = 0x" ChipLogFormatX64 ",", ChipLogValueX64(node));
      57              :             }
      58              : #endif // CHIP_DETAIL_LOGGING
      59            5 :             break;
      60         2497 :         case to_underlying(Tag::kEndpoint):
      61         2497 :             VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      62              : #if CHIP_DETAIL_LOGGING
      63              :             {
      64              :                 EndpointId endpoint;
      65         2497 :                 reader.Get(endpoint);
      66         2497 :                 PRETTY_PRINT("\tEndpoint = 0x%x,", endpoint);
      67              :             }
      68              : #endif // CHIP_DETAIL_LOGGING
      69         2497 :             break;
      70         2497 :         case to_underlying(Tag::kCluster):
      71         2497 :             VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
      72              : 
      73              : #if CHIP_DETAIL_LOGGING
      74              :             {
      75              :                 ClusterId cluster;
      76         2497 :                 ReturnErrorOnFailure(reader.Get(cluster));
      77         2497 :                 PRETTY_PRINT("\tCluster = 0x%" PRIx32 ",", cluster);
      78              :             }
      79              : #endif // CHIP_DETAIL_LOGGING
      80         2497 :             break;
      81            0 :         default:
      82            0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      83            0 :             break;
      84              :         }
      85              :     }
      86              : 
      87         2497 :     PRETTY_PRINT("}");
      88         2497 :     PRETTY_PRINT("\t");
      89              :     // if we have exhausted this container
      90         2497 :     if (CHIP_END_OF_TLV == err)
      91              :     {
      92         2497 :         err = CHIP_NO_ERROR;
      93              :     }
      94              : 
      95         2497 :     ReturnErrorOnFailure(err);
      96         2497 :     return reader.ExitContainer(mOuterContainerType);
      97              : }
      98              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      99              : 
     100            1 : CHIP_ERROR ClusterPathIB::Parser::GetNode(NodeId * const apNode) const
     101              : {
     102            1 :     return GetUnsignedInteger(to_underlying(Tag::kNode), apNode);
     103              : }
     104              : 
     105         2493 : CHIP_ERROR ClusterPathIB::Parser::GetEndpoint(EndpointId * const apEndpoint) const
     106              : {
     107         2493 :     return GetUnsignedInteger(to_underlying(Tag::kEndpoint), apEndpoint);
     108              : }
     109              : 
     110         2493 : CHIP_ERROR ClusterPathIB::Parser::GetCluster(ClusterId * const apCluster) const
     111              : {
     112         2493 :     return GetUnsignedInteger(to_underlying(Tag::kCluster), apCluster);
     113              : }
     114              : 
     115            5 : ClusterPathIB::Builder & ClusterPathIB::Builder::Node(const NodeId aNode)
     116              : {
     117              :     // skip if error has already been set
     118            5 :     if (mError == CHIP_NO_ERROR)
     119              :     {
     120            5 :         mError = mpWriter->Put(TLV::ContextTag(Tag::kNode), aNode);
     121              :     }
     122            5 :     return *this;
     123              : }
     124              : 
     125         2994 : ClusterPathIB::Builder & ClusterPathIB::Builder::Endpoint(const EndpointId aEndpoint)
     126              : {
     127              :     // skip if error has already been set
     128         2994 :     if (mError == CHIP_NO_ERROR)
     129              :     {
     130         2994 :         mError = mpWriter->Put(TLV::ContextTag(Tag::kEndpoint), aEndpoint);
     131              :     }
     132         2994 :     return *this;
     133              : }
     134              : 
     135         2994 : ClusterPathIB::Builder & ClusterPathIB::Builder::Cluster(const ClusterId aCluster)
     136              : {
     137              :     // skip if error has already been set
     138         2994 :     if (mError == CHIP_NO_ERROR)
     139              :     {
     140         2966 :         mError = mpWriter->Put(TLV::ContextTag(Tag::kCluster), aCluster);
     141              :     }
     142         2994 :     return *this;
     143              : }
     144              : 
     145         2994 : CHIP_ERROR ClusterPathIB::Builder::EndOfClusterPathIB()
     146              : {
     147         2994 :     EndOfContainer();
     148         2994 :     return GetError();
     149              : }
     150              : } // namespace app
     151              : } // namespace chip
        

Generated by: LCOV version 2.0-1