LCOV - code coverage report
Current view: top level - protocols/interaction_model - Constants.h (source / functions) Hit Total Coverage
Test: lcov_final.info Lines: 3 3 100.0 %
Date: 2024-02-15 08:20:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  *
       3             :  *    Copyright (c) 2021 Project CHIP Authors
       4             :  *    All rights reserved.
       5             :  *
       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             : /**
      20             :  *    @file
      21             :  *      The defines constants for the CHIP Interaction Model Protocol, present in
      22             :  *      every CHIP device.
      23             :  *
      24             :  */
      25             : 
      26             : #pragma once
      27             : 
      28             : #include <type_traits>
      29             : 
      30             : #include <array>
      31             : #include <protocols/Protocols.h>
      32             : #include <protocols/interaction_model/StatusCode.h>
      33             : 
      34             : /**
      35             :  *   @namespace chip::Protocols::InteractionModel
      36             :  *
      37             :  *   @brief
      38             :  *     This namespace includes all interfaces within CHIP for the
      39             :  *     CHIP InteractionModel protocol.
      40             :  *
      41             :  *     The interfaces define message types.
      42             :  */
      43             : 
      44             : namespace chip {
      45             : namespace Protocols {
      46             : namespace InteractionModel {
      47             : 
      48             : inline constexpr char kProtocolName[] = "IM";
      49             : 
      50             : /**
      51             :  * Version of the Interaction Model used by the node.
      52             :  */
      53             : inline constexpr uint16_t kVersion = 0;
      54             : 
      55             : /**
      56             :  * Interaction Model Protocol Message Types
      57             :  */
      58             : enum class MsgType : uint8_t
      59             : {
      60             :     StatusResponse        = 0x01,
      61             :     ReadRequest           = 0x02,
      62             :     SubscribeRequest      = 0x03,
      63             :     SubscribeResponse     = 0x04,
      64             :     ReportData            = 0x05,
      65             :     WriteRequest          = 0x06,
      66             :     WriteResponse         = 0x07,
      67             :     InvokeCommandRequest  = 0x08,
      68             :     InvokeCommandResponse = 0x09,
      69             :     TimedRequest          = 0x0a,
      70             : };
      71             : 
      72             : } // namespace InteractionModel
      73             : 
      74             : template <>
      75             : struct MessageTypeTraits<InteractionModel::MsgType>
      76             : {
      77       16940 :     static constexpr const Protocols::Id & ProtocolId() { return InteractionModel::Id; }
      78             : 
      79       31218 :     static auto GetTypeToNameTable()
      80             :     {
      81             :         static const std::array<MessageTypeNameLookup, 10> typeToNameTable = {
      82             :             {
      83             :                 { InteractionModel::MsgType::StatusResponse, "StatusResponse" },
      84             :                 { InteractionModel::MsgType::ReadRequest, "ReadRequest" },
      85             :                 { InteractionModel::MsgType::SubscribeRequest, "SubscribeRequest" },
      86             :                 { InteractionModel::MsgType::SubscribeResponse, "SubscribeResponse" },
      87             :                 { InteractionModel::MsgType::ReportData, "ReportData" },
      88             :                 { InteractionModel::MsgType::WriteRequest, "WriteRequest" },
      89             :                 { InteractionModel::MsgType::WriteResponse, "WriteResponse" },
      90             :                 { InteractionModel::MsgType::InvokeCommandRequest, "InvokeCommandRequest" },
      91             :                 { InteractionModel::MsgType::InvokeCommandResponse, "InvokeCommandResponse" },
      92             :                 { InteractionModel::MsgType::TimedRequest, "TimedRequest" },
      93             :             },
      94             :         };
      95             : 
      96       31218 :         return &typeToNameTable;
      97             :     }
      98             : };
      99             : 
     100             : } // namespace Protocols
     101             : } // namespace chip

Generated by: LCOV version 1.14