Matter SDK Coverage Report
Current view: top level - app/MessageDef - EventFilterIB.cpp (source / functions) Coverage Total Hit
Test: SHA:b879ecb8e99e175eea0a293a888bda853da2b19c Lines: 90.7 % 43 39
Test Date: 2025-01-17 19:00:11 Functions: 100.0 % 6 6

            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              :  *    @file
      18              :  *      This file defines EventFilterIB parser and builder in CHIP interaction model
      19              :  *
      20              :  */
      21              : 
      22              : #include "EventFilterIB.h"
      23              : 
      24              : #include "MessageDefHelper.h"
      25              : 
      26              : #include <inttypes.h>
      27              : #include <stdarg.h>
      28              : #include <stdio.h>
      29              : 
      30              : #include <app/AppConfig.h>
      31              : 
      32              : namespace chip {
      33              : namespace app {
      34              : #if CHIP_CONFIG_IM_PRETTY_PRINT
      35          318 : CHIP_ERROR EventFilterIB::Parser::PrettyPrint() const
      36              : {
      37          318 :     CHIP_ERROR err = CHIP_NO_ERROR;
      38          318 :     TLV::TLVReader reader;
      39              : 
      40          318 :     PRETTY_PRINT("EventFilterIB =");
      41          318 :     PRETTY_PRINT("{");
      42              : 
      43              :     // make a copy of the reader
      44          318 :     reader.Init(mReader);
      45              : 
      46          640 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      47              :     {
      48          322 :         if (!TLV::IsContextTag(reader.GetTag()))
      49              :         {
      50            0 :             continue;
      51              :         }
      52          322 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      53          322 :         switch (tagNum)
      54              :         {
      55            4 :         case to_underlying(Tag::kNode):
      56              : #if CHIP_DETAIL_LOGGING
      57              :         {
      58              :             NodeId node;
      59            4 :             ReturnErrorOnFailure(reader.Get(node));
      60            4 :             PRETTY_PRINT("\tNode = 0x" ChipLogFormatX64 ",", ChipLogValueX64(node));
      61              :         }
      62              : #endif // CHIP_DETAIL_LOGGING
      63            4 :         break;
      64          318 :         case to_underlying(Tag::kEventMin):
      65              : #if CHIP_DETAIL_LOGGING
      66              :         {
      67              :             uint64_t eventMin;
      68          318 :             ReturnErrorOnFailure(reader.Get(eventMin));
      69          318 :             PRETTY_PRINT("\tEventMin = 0x" ChipLogFormatX64 ",", ChipLogValueX64(eventMin));
      70              :         }
      71              : #endif // CHIP_DETAIL_LOGGING
      72          318 :         break;
      73            0 :         default:
      74            0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      75            0 :             break;
      76              :         }
      77              :     }
      78              : 
      79          318 :     PRETTY_PRINT("},");
      80          318 :     PRETTY_PRINT_BLANK_LINE();
      81              : 
      82          318 :     if (CHIP_END_OF_TLV == err)
      83              :     {
      84          318 :         err = CHIP_NO_ERROR;
      85              :     }
      86              : 
      87          318 :     ReturnErrorOnFailure(err);
      88          318 :     return reader.ExitContainer(mOuterContainerType);
      89              : }
      90              : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      91              : 
      92            1 : CHIP_ERROR EventFilterIB::Parser::GetNode(NodeId * const apNode) const
      93              : {
      94            1 :     return GetUnsignedInteger(to_underlying(Tag::kNode), apNode);
      95              : }
      96              : 
      97          315 : CHIP_ERROR EventFilterIB::Parser::GetEventMin(uint64_t * const apEventMin) const
      98              : {
      99          315 :     return GetUnsignedInteger(to_underlying(Tag::kEventMin), apEventMin);
     100              : }
     101              : 
     102            4 : EventFilterIB::Builder & EventFilterIB::Builder::Node(const NodeId aNode)
     103              : {
     104              :     // skip if error has already been set
     105            4 :     if (mError == CHIP_NO_ERROR)
     106              :     {
     107            4 :         mError = mpWriter->Put(TLV::ContextTag(Tag::kNode), aNode);
     108              :     }
     109            4 :     return *this;
     110              : }
     111              : 
     112          318 : EventFilterIB::Builder & EventFilterIB::Builder::EventMin(const uint64_t aEventMin)
     113              : {
     114              :     // skip if error has already been set
     115          318 :     if (mError == CHIP_NO_ERROR)
     116              :     {
     117          318 :         mError = mpWriter->Put(TLV::ContextTag(Tag::kEventMin), aEventMin);
     118              :     }
     119          318 :     return *this;
     120              : }
     121              : 
     122          318 : CHIP_ERROR EventFilterIB::Builder::EndOfEventFilterIB()
     123              : {
     124          318 :     EndOfContainer();
     125          318 :     return GetError();
     126              : }
     127              : }; // namespace app
     128              : }; // namespace chip
        

Generated by: LCOV version 2.0-1