Matter SDK Coverage Report
Current view: top level - lib/support - ThreadDiscoveryCode.cpp (source / functions) Coverage Total Hit
Test: SHA:4a1dff731dfd17f3623faad23ee07f07df60cba7 Lines: 100.0 % 6 6
Test Date: 2026-02-11 08:13:42 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2026 Project CHIP Authors
       4              :  *
       5              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       6              :  *    you may not use this file except in compliance with the License.
       7              :  *    You may obtain a copy of the License at
       8              :  *
       9              :  *        http://www.apache.org/licenses/LICENSE-2.0
      10              :  *
      11              :  *    Unless required by applicable law or agreed to in writing, software
      12              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      13              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14              :  *    See the License for the specific language governing permissions and
      15              :  *    limitations under the License.
      16              :  */
      17              : 
      18              : #include "ThreadDiscoveryCode.h"
      19              : 
      20              : #include <stdint.h>
      21              : 
      22              : #include <lib/core/CHIPEncoding.h>
      23              : #include <lib/support/CodeUtils.h>
      24              : 
      25              : namespace chip {
      26              : namespace Thread {
      27              : 
      28              : namespace {
      29              : // Magic number "MT" in ASCII
      30              : constexpr uint32_t kMagicNumber = 0x4d540000;
      31              : } // namespace
      32              : 
      33            3 : DiscoveryCode::DiscoveryCode(uint16_t discriminator)
      34              : {
      35              :     // The discovery code packing:
      36              :     // Bits 32-63: Magic number "MT" (0x4D540000)
      37              :     // Bits 8-15: Lower 8 bits of the 12-bit discriminator
      38              :     // Bits 0-3: Upper 4 bits of the 12-bit discriminator
      39              : 
      40            3 :     uint64_t magic     = static_cast<uint64_t>(kMagicNumber) << 32;
      41            3 :     uint64_t discLow8  = static_cast<uint64_t>(discriminator & 0xFF) << 8;
      42            3 :     uint64_t discHigh4 = static_cast<uint64_t>((discriminator >> 8) & 0x0F);
      43              : 
      44            3 :     mCode = magic | discLow8 | discHigh4;
      45            3 : }
      46              : 
      47              : } // namespace Thread
      48              : } // namespace chip
        

Generated by: LCOV version 2.0-1