LCOV - code coverage report
Current view: top level - app/MessageDef - TimedRequestMessage.cpp (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 33 37 89.2 %
Date: 2024-02-15 08:20:41 Functions: 3 3 100.0 %

          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 "TimedRequestMessage.h"
      18             : #include "MessageDefHelper.h"
      19             : 
      20             : namespace chip {
      21             : namespace app {
      22             : #if CHIP_CONFIG_IM_PRETTY_PRINT
      23           4 : CHIP_ERROR TimedRequestMessage::Parser::PrettyPrint() const
      24             : {
      25           4 :     CHIP_ERROR err = CHIP_NO_ERROR;
      26             :     TLV::TLVReader reader;
      27           4 :     PRETTY_PRINT("TimedRequestMessage =");
      28           4 :     PRETTY_PRINT("{");
      29             : 
      30             :     // make a copy of the reader
      31           4 :     reader.Init(mReader);
      32             : 
      33          12 :     while (CHIP_NO_ERROR == (err = reader.Next()))
      34             :     {
      35           8 :         if (!TLV::IsContextTag(reader.GetTag()))
      36             :         {
      37           0 :             continue;
      38             :         }
      39           8 :         uint32_t tagNum = TLV::TagNumFromTag(reader.GetTag());
      40           8 :         switch (tagNum)
      41             :         {
      42           4 :         case to_underlying(Tag::kTimeoutMs):
      43           4 :             VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
      44             : #if CHIP_DETAIL_LOGGING
      45             :             {
      46             :                 uint16_t timeout;
      47           4 :                 ReturnErrorOnFailure(reader.Get(timeout));
      48           4 :                 PRETTY_PRINT("\tTimeoutMs = 0x%x,", timeout);
      49             :             }
      50             : #endif // CHIP_DETAIL_LOGGING
      51           4 :             break;
      52           4 :         case kInteractionModelRevisionTag:
      53           4 :             ReturnErrorOnFailure(MessageParser::CheckInteractionModelRevision(reader));
      54           4 :             break;
      55           0 :         default:
      56           0 :             PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
      57           0 :             break;
      58             :         }
      59             :     }
      60           4 :     PRETTY_PRINT("}");
      61           4 :     PRETTY_PRINT_BLANK_LINE();
      62           4 :     if (CHIP_END_OF_TLV == err)
      63             :     {
      64           4 :         err = CHIP_NO_ERROR;
      65             :     }
      66           4 :     ReturnErrorOnFailure(err);
      67           4 :     return reader.ExitContainer(mOuterContainerType);
      68             : }
      69             : #endif // CHIP_CONFIG_IM_PRETTY_PRINT
      70             : 
      71           4 : CHIP_ERROR TimedRequestMessage::Parser::GetTimeoutMs(uint16_t * const apTimeoutMs) const
      72             : {
      73           4 :     return GetUnsignedInteger(to_underlying(Tag::kTimeoutMs), apTimeoutMs);
      74             : }
      75             : 
      76           4 : TimedRequestMessage::Builder & TimedRequestMessage::Builder::TimeoutMs(const uint16_t aTimeoutMs)
      77             : {
      78             :     // skip if error has already been set
      79           4 :     if (mError == CHIP_NO_ERROR)
      80             :     {
      81           4 :         mError = mpWriter->Put(TLV::ContextTag(Tag::kTimeoutMs), aTimeoutMs);
      82             :     }
      83           4 :     if (mError == CHIP_NO_ERROR)
      84             :     {
      85           4 :         mError = MessageBuilder::EncodeInteractionModelRevision();
      86             :     }
      87           4 :     if (mError == CHIP_NO_ERROR)
      88             :     {
      89           4 :         EndOfContainer();
      90             :     }
      91           4 :     return *this;
      92             : }
      93             : } // namespace app
      94             : } // namespace chip

Generated by: LCOV version 1.14