From 444578053a44a88db9c2ff18aef7770b5cf1d627 Mon Sep 17 00:00:00 2001 From: "Lo,Chin-Ran" Date: Sat, 3 Aug 2024 20:07:32 +0800 Subject: [PATCH] * Add the missing files Signed-off-by: Lo,Chin-Ran --- src/wifipaf/BUILD.gn | 39 ++++++++++++++++++++++ src/wifipaf/WiFiPAFLayer.cpp | 50 ++++++++++++++++++++++++++++ src/wifipaf/WiFiPAFLayer.h | 53 ++++++++++++++++++++++++++++++ src/wifipaf/WiFiPAFLayerDelegate.h | 39 ++++++++++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 src/wifipaf/BUILD.gn create mode 100644 src/wifipaf/WiFiPAFLayer.cpp create mode 100644 src/wifipaf/WiFiPAFLayer.h create mode 100644 src/wifipaf/WiFiPAFLayerDelegate.h diff --git a/src/wifipaf/BUILD.gn b/src/wifipaf/BUILD.gn new file mode 100644 index 00000000000000..ab56001a92d2b8 --- /dev/null +++ b/src/wifipaf/BUILD.gn @@ -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") { + } +} diff --git a/src/wifipaf/WiFiPAFLayer.cpp b/src/wifipaf/WiFiPAFLayer.cpp new file mode 100644 index 00000000000000..d5bd6c992a7d63 --- /dev/null +++ b/src/wifipaf/WiFiPAFLayer.cpp @@ -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 */ diff --git a/src/wifipaf/WiFiPAFLayer.h b/src/wifipaf/WiFiPAFLayer.h new file mode 100644 index 00000000000000..41e0dd976f4d03 --- /dev/null +++ b/src/wifipaf/WiFiPAFLayer.h @@ -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 +#include +#include +#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 */ diff --git a/src/wifipaf/WiFiPAFLayerDelegate.h b/src/wifipaf/WiFiPAFLayerDelegate.h new file mode 100644 index 00000000000000..6b91704035e73a --- /dev/null +++ b/src/wifipaf/WiFiPAFLayerDelegate.h @@ -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 + +namespace chip { +namespace WiFiPAF { + +class WiFiPAFLayerDelegate +{ +public: + virtual ~WiFiPAFLayerDelegate() = default; + virtual void OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg) = 0; +}; + +} // namespace WiFiPAF +} // namespace chip