Skip to content

Commit

Permalink
* Add the missing files
Browse files Browse the repository at this point in the history
Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
  • Loading branch information
crlonxp committed Aug 21, 2024
1 parent 469086a commit 4445780
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/wifipaf/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("${chip_root}/src/platform/device.gni")

if (chip_device_config_enable_wifipaf) {
static_library("wifipaf") {
output_name = "libWiFiPAFLayer"

sources = [
"WiFiPAFLayerDelegate.h",
"WiFiPAFLayer.cpp",
"WiFiPAFLayer.h"
]

cflags = [ "-Wconversion" ]

public_deps = [
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/support",
]
}
} else {
group("wifipaf") {
}
}
50 changes: 50 additions & 0 deletions src/wifipaf/WiFiPAFLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
* This file implements objects which provide an abstraction layer between
* a platform's WiFiPAF implementation and the CHIP
* stack.
*
*/

#include "WiFiPAFLayer.h"
namespace chip {
namespace WiFiPAF {

void WiFiPAFLayer::OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg)
{
if (mWiFiPAFTransport != nullptr) {
mWiFiPAFTransport->OnWiFiPAFMessageReceived(std::move(msg));
}
}

void WiFiPAFLayer::SetWiFiPAFState(State state)
{
mAppState = state;
return;
}

static WiFiPAFLayer sInstance;
WiFiPAFLayer* WiFiPAFLayer::GetWiFiPAFLayer()
{
return &sInstance;
}

} /* namespace WiFiPAF */
} /* namespace chip */
53 changes: 53 additions & 0 deletions src/wifipaf/WiFiPAFLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <lib/core/CHIPError.h>
#include <lib/support/DLLUtil.h>
#include <system/SystemPacketBuffer.h>
#include "WiFiPAFLayerDelegate.h"

namespace chip {
namespace WiFiPAF {
/**
* The State of the Wi-Fi-PAF connection
*
*/
enum class State
{
kNotReady = 0, /**< State before initialization. */
kInitialized = 1, /**< State after class is connected and ready. */
kConnected = 2, /**< Endpoint connected. */
};

class DLL_EXPORT WiFiPAFLayer
{
public:
State mAppState = State::kNotReady;
WiFiPAFLayerDelegate * mWiFiPAFTransport = nullptr;

WiFiPAFLayer() = default;
static WiFiPAFLayer* GetWiFiPAFLayer();

void OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg);
State GetWiFiPAFState() { return mAppState; };
void SetWiFiPAFState(State state);
};

} /* namespace WiFiPAF */
} /* namespace chip */
39 changes: 39 additions & 0 deletions src/wifipaf/WiFiPAFLayerDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
* This file defines the interface for downcalls from WiFiPAFLayer
* to a WiFiPAF transport.
*/

#pragma once

#include <system/SystemPacketBuffer.h>

namespace chip {
namespace WiFiPAF {

class WiFiPAFLayerDelegate
{
public:
virtual ~WiFiPAFLayerDelegate() = default;
virtual void OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg) = 0;
};

} // namespace WiFiPAF
} // namespace chip

0 comments on commit 4445780

Please sign in to comment.