-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lo,Chin-Ran <[email protected]>
- Loading branch information
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |