Matter SDK Coverage Report
Current view: top level - transport/raw - WiFiPAF.h (source / functions) Coverage Total Hit
Test: SHA:4cbce7f768f16e614f5a8ccb8cd93c92cbeae70d Lines: 50.0 % 8 4
Test Date: 2025-04-26 07:09:35 Functions: 57.1 % 7 4

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2025 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              :  *      This file defines the Matter Connection object that maintains a Wi-Fi PAF connection.
      22              :  *
      23              :  */
      24              : 
      25              : #pragma once
      26              : 
      27              : #include <lib/core/CHIPCore.h>
      28              : #include <lib/support/DLLUtil.h>
      29              : #include <system/SystemPacketBuffer.h>
      30              : #include <transport/raw/Base.h>
      31              : #include <utility>
      32              : #include <wifipaf/WiFiPAFLayer.h>
      33              : 
      34              : namespace chip {
      35              : namespace Transport {
      36              : class WiFiPAFListenParameters;
      37              : 
      38              : /**
      39              :  * Implements a transport using Wi-Fi-PAF
      40              :  */
      41              : class DLL_EXPORT WiFiPAFBase : public Base, public WiFiPAF::WiFiPAFLayerDelegate
      42              : {
      43              : public:
      44            2 :     WiFiPAFBase() = default;
      45            0 :     WiFiPAFBase(System::PacketBufferHandle * packetBuffers, size_t packetBuffersSize) :
      46            0 :         mPendingPackets(packetBuffers), mPendingPacketsSize(packetBuffersSize)
      47            0 :     {}
      48            2 :     ~WiFiPAFBase() override {}
      49              : 
      50              :     /**
      51              :      * Initialize a Wi-Fi-PAF transport
      52              :      *
      53              :      * @param param        Wi-Fi-PAF configuration parameters for this transport
      54              :      */
      55              :     CHIP_ERROR Init(const WiFiPAFListenParameters & param);
      56              :     bool CanSendToPeer(const Transport::PeerAddress & address) override;
      57            1 :     void SetWiFiPAFLayerTransportToSelf() { mWiFiPAFLayer->mWiFiPAFTransport = this; }
      58              :     bool IsWiFiPAFLayerTransportSetToSelf() { return mWiFiPAFLayer->mWiFiPAFTransport == this; }
      59              :     /**
      60              :      * Interface of Base
      61              :      */
      62              :     CHIP_ERROR SendMessage(const Transport::PeerAddress & address, System::PacketBufferHandle && msgBuf) override;
      63              :     /**
      64              :      * Interfaces of WiFiPAFLayerDelegate
      65              :      */
      66              :     CHIP_ERROR WiFiPAFMessageReceived(WiFiPAF::WiFiPAFSession & RxInfo, System::PacketBufferHandle && buffer) override;
      67              :     CHIP_ERROR WiFiPAFMessageSend(WiFiPAF::WiFiPAFSession & TxInfo, System::PacketBufferHandle && msg) override;
      68              :     CHIP_ERROR WiFiPAFCloseSession(WiFiPAF::WiFiPAFSession & SessionInfo) override;
      69              : 
      70              : private:
      71              :     /**
      72              :      * Sends the specified message once a connection has been established.
      73              :      * @param msg - what buffer to send once a connection has been established.
      74              :      */
      75              :     CHIP_ERROR SendAfterConnect(System::PacketBufferHandle && msg);
      76              : 
      77              :     WiFiPAF::WiFiPAFLayer * mWiFiPAFLayer = nullptr; ///< Associated wifipaf layer
      78              : 
      79              :     System::PacketBufferHandle * mPendingPackets;
      80              :     size_t mPendingPacketsSize;
      81              : };
      82              : 
      83              : template <size_t kPendingPacketSize>
      84              : class WiFiPAF : public WiFiPAFBase
      85              : {
      86              : public:
      87            0 :     WiFiPAF() : WiFiPAFBase(mPendingPackets, kPendingPacketSize) {}
      88              : 
      89              : private:
      90              :     System::PacketBufferHandle mPendingPackets[kPendingPacketSize];
      91              : };
      92              : 
      93              : /** Defines parameters for setting up the Wi-Fi PAF transport */
      94              : class WiFiPAFListenParameters
      95              : {
      96              : public:
      97              :     WiFiPAFListenParameters() = default;
      98            1 :     explicit WiFiPAFListenParameters(WiFiPAFBase * layer) : mWiFiPAF(layer) {}
      99              :     WiFiPAFBase * GetWiFiPAFTransport() const { return mWiFiPAF; }
     100              : 
     101              : private:
     102              :     WiFiPAFBase * mWiFiPAF;
     103              : };
     104              : 
     105              : } // namespace Transport
     106              : } // namespace chip
        

Generated by: LCOV version 2.0-1