Skip to content

Commit 1b5c521

Browse files
committed
* Add the missing files
Signed-off-by: Lo,Chin-Ran <chin-ran.lo@nxp.com>
1 parent 14600d9 commit 1b5c521

File tree

4 files changed

+181
-0
lines changed

4 files changed

+181
-0
lines changed

src/wifipaf/BUILD.gn

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2024 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
import("${chip_root}/src/platform/device.gni")
18+
19+
if (chip_device_config_enable_wifipaf) {
20+
static_library("wifipaf") {
21+
output_name = "libWiFiPAFLayer"
22+
23+
sources = [
24+
"WiFiPAFLayerDelegate.h",
25+
"WiFiPAFLayer.cpp",
26+
"WiFiPAFLayer.h"
27+
]
28+
29+
cflags = [ "-Wconversion" ]
30+
31+
public_deps = [
32+
"${chip_root}/src/lib/core",
33+
"${chip_root}/src/lib/support",
34+
]
35+
}
36+
} else {
37+
group("wifipaf") {
38+
}
39+
}

src/wifipaf/WiFiPAFLayer.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 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+
/**
19+
* @file
20+
* This file implements objects which provide an abstraction layer between
21+
* a platform's WiFiPAF implementation and the CHIP
22+
* stack.
23+
*
24+
*/
25+
26+
#include "WiFiPAFLayer.h"
27+
namespace chip {
28+
namespace WiFiPAF {
29+
30+
void WiFiPAFLayer::OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg)
31+
{
32+
if (mWiFiPAFTransport != nullptr) {
33+
mWiFiPAFTransport->OnWiFiPAFMessageReceived(std::move(msg));
34+
}
35+
}
36+
37+
void WiFiPAFLayer::SetWiFiPAFState(State state)
38+
{
39+
mAppState = state;
40+
return;
41+
}
42+
43+
static WiFiPAFLayer sInstance;
44+
WiFiPAFLayer* WiFiPAFLayer::GetWiFiPAFLayer()
45+
{
46+
return &sInstance;
47+
}
48+
49+
} /* namespace WiFiPAF */
50+
} /* namespace chip */

src/wifipaf/WiFiPAFLayer.h

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 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+
#pragma once
19+
20+
#include <lib/core/CHIPError.h>
21+
#include <lib/support/DLLUtil.h>
22+
#include <system/SystemPacketBuffer.h>
23+
#include "WiFiPAFLayerDelegate.h"
24+
25+
namespace chip {
26+
namespace WiFiPAF {
27+
/**
28+
* The State of the Wi-Fi-PAF connection
29+
*
30+
*/
31+
enum class State
32+
{
33+
kNotReady = 0, /**< State before initialization. */
34+
kInitialized = 1, /**< State after class is connected and ready. */
35+
kConnected = 2, /**< Endpoint connected. */
36+
};
37+
38+
class DLL_EXPORT WiFiPAFLayer
39+
{
40+
public:
41+
State mAppState = State::kNotReady;
42+
WiFiPAFLayerDelegate * mWiFiPAFTransport = nullptr;
43+
44+
WiFiPAFLayer() = default;
45+
static WiFiPAFLayer* GetWiFiPAFLayer();
46+
47+
void OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg);
48+
State GetWiFiPAFState() { return mAppState; };
49+
void SetWiFiPAFState(State state);
50+
};
51+
52+
} /* namespace WiFiPAF */
53+
} /* namespace chip */

src/wifipaf/WiFiPAFLayerDelegate.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 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+
/**
19+
* @file
20+
* This file defines the interface for downcalls from WiFiPAFLayer
21+
* to a WiFiPAF transport.
22+
*/
23+
24+
#pragma once
25+
26+
#include <system/SystemPacketBuffer.h>
27+
28+
namespace chip {
29+
namespace WiFiPAF {
30+
31+
class WiFiPAFLayerDelegate
32+
{
33+
public:
34+
virtual ~WiFiPAFLayerDelegate() = default;
35+
virtual void OnWiFiPAFMessageReceived(System::PacketBufferHandle && msg) = 0;
36+
};
37+
38+
} // namespace WiFiPAF
39+
} // namespace chip

0 commit comments

Comments
 (0)