Skip to content

Commit faa31fd

Browse files
authored
[BEKEN] add beken examples/platform files (#22405)
* [BEKEN] add beken examples/platform files * add beken examples/platform files * modify beken examples/lighting-app files * [BEKEN] optimize by reviewer's suggestion * remove commented-out code * modify class members attr
1 parent b9832a2 commit faa31fd

16 files changed

+556
-436
lines changed

examples/lighting-app/beken/BUILD.gn

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
1717

18+
examples_plat_dir = "${chip_root}/examples/platform/beken"
19+
1820
static_library("MatterApp") {
1921
public_deps = [
2022
"${chip_root}/examples/lighting-app/lighting-common",
2123
"${chip_root}/src/lib",
2224
]
2325

2426
sources = [
25-
"main/CHIPDeviceManager.cpp",
27+
"${examples_plat_dir}/common/BekenAppServer.cpp",
28+
"${examples_plat_dir}/common/CHIPDeviceManager.cpp",
29+
"${examples_plat_dir}/common/CommonDeviceCallbacks.cpp",
30+
"${examples_plat_dir}/ota/OTAHelper.cpp",
2631
"main/DeviceCallbacks.cpp",
2732
"main/DsoHack.cpp",
2833
"main/chipinterface.cpp",

examples/lighting-app/beken/main/CHIPDeviceManager.cpp

-168
This file was deleted.

examples/lighting-app/beken/main/DeviceCallbacks.cpp

+7-78
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
* Implements all the callbacks to the application from the CHIP Stack
2323
*
2424
**/
25+
2526
#include "DeviceCallbacks.h"
2627

27-
#include "CHIPDeviceManager.h"
28+
#include <common/CHIPDeviceManager.h>
29+
2830
#include <app-common/zap-generated/attribute-id.h>
2931
#include <app-common/zap-generated/cluster-id.h>
3032
#include <app/CommandHandler.h>
@@ -49,75 +51,8 @@ using namespace ::chip::Logging;
4951
uint32_t identifyTimerCount;
5052
constexpr uint32_t kIdentifyTimerDelayMS = 250;
5153

52-
void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
53-
{
54-
ChipLogProgress(Zcl, "DeviceEventCallback, event->Type:%d \r\n", event->Type);
55-
switch (event->Type)
56-
{
57-
case DeviceEventType::kInternetConnectivityChange:
58-
OnInternetConnectivityChange(event);
59-
break;
60-
61-
// case DeviceEventType::kSessionEstablished:
62-
// OnSessionEstablished(event);
63-
// break;
64-
case DeviceEventType::kInterfaceIpAddressChanged:
65-
ChipLogProgress(Zcl, "IP(%s) changed event",
66-
(event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) ? "IPv4" : "IPv6");
67-
if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) ||
68-
(event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned))
69-
{
70-
// MDNS server restart on any ip assignment: if link local ipv6 is configured, that
71-
// will not trigger a 'internet connectivity change' as there is no internet
72-
// connectivity. MDNS still wants to refresh its listening interfaces to include the
73-
// newly selected address.
74-
chip::app::DnssdServer::Instance().StartServer();
75-
}
76-
break;
77-
case DeviceEventType::kCHIPoBLEConnectionEstablished:
78-
ChipLogProgress(Zcl, "CHIPoBLE connection established");
79-
break;
80-
case DeviceEventType::kCHIPoBLEConnectionClosed:
81-
ChipLogProgress(Zcl, "CHIPoBLE disconnected");
82-
break;
83-
case DeviceEventType::kCommissioningComplete:
84-
ChipLogProgress(Zcl, "Commissioning complete");
85-
break;
86-
}
87-
}
88-
89-
void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
90-
{
91-
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
92-
{
93-
ChipLogProgress(Zcl, "Server ready at:%d", CHIP_PORT);
94-
// chip::app::DnssdServer::Instance().StartServer();
95-
}
96-
else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost)
97-
{
98-
ChipLogProgress(Zcl, "Lost IPv4 connectivity...");
99-
}
100-
if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
101-
{
102-
ChipLogProgress(Zcl, "IPv6 Server ready...");
103-
chip::app::DnssdServer::Instance().StartServer();
104-
}
105-
else if (event->InternetConnectivityChange.IPv6 == kConnectivity_Lost)
106-
{
107-
ChipLogProgress(Zcl, "Lost IPv6 connectivity...");
108-
}
109-
}
110-
111-
void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event)
112-
{
113-
if (event->SessionEstablished.IsCommissioner)
114-
{
115-
ChipLogProgress(Zcl, "Commissioner detected!");
116-
}
117-
}
118-
119-
void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
120-
uint8_t type, uint16_t size, uint8_t * value)
54+
void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId,
55+
uint8_t type, uint16_t size, uint8_t * value)
12156
{
12257
switch (clusterId)
12358
{
@@ -135,7 +70,7 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
13570
}
13671
}
13772

138-
void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
73+
void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
13974
{
14075
VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID,
14176
ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId));
@@ -161,7 +96,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState)
16196
}
16297
}
16398

164-
void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
99+
void AppDeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
165100
{
166101
VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID,
167102
ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId));
@@ -178,9 +113,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI
178113
exit:
179114
return;
180115
}
181-
182-
bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj)
183-
{
184-
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
185-
return true;
186-
}

0 commit comments

Comments
 (0)