Skip to content

Commit

Permalink
[BEKEN] add beken examples/platform files
Browse files Browse the repository at this point in the history
* add beken examples/platform files
* modify beken examples/lighting-app files
  • Loading branch information
zhengyaohan committed Sep 6, 2022
1 parent 8edae2d commit a3dcebb
Show file tree
Hide file tree
Showing 16 changed files with 567 additions and 435 deletions.
9 changes: 8 additions & 1 deletion examples/lighting-app/beken/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

examples_plat_dir = "${chip_root}/examples/platform/beken"

static_library("MatterApp") {
public_deps = [
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/src/lib",
]

sources = [
"main/CHIPDeviceManager.cpp",
"main/DeviceCallbacks.cpp",
"main/DsoHack.cpp",
"main/chipinterface.cpp",

"${examples_plat_dir}/common/BekenAppServer.cpp",
"${examples_plat_dir}/common/CHIPDeviceManager.cpp",
"${examples_plat_dir}/common/CommonDeviceCallbacks.cpp",

"${examples_plat_dir}/ota/OTAHelper.cpp",
]

output_name = "libMatterApp"
Expand Down
168 changes: 0 additions & 168 deletions examples/lighting-app/beken/main/CHIPDeviceManager.cpp

This file was deleted.

83 changes: 6 additions & 77 deletions examples/lighting-app/beken/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
* Implements all the callbacks to the application from the CHIP Stack
*
**/

#include "DeviceCallbacks.h"

#include "CHIPDeviceManager.h"
#include <common/CHIPDeviceManager.h>

#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/CommandHandler.h>
Expand All @@ -49,74 +51,7 @@ using namespace ::chip::Logging;
uint32_t identifyTimerCount;
constexpr uint32_t kIdentifyTimerDelayMS = 250;

void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
{
ChipLogProgress(Zcl, "DeviceEventCallback, event->Type:%d \r\n", event->Type);
switch (event->Type)
{
case DeviceEventType::kInternetConnectivityChange:
OnInternetConnectivityChange(event);
break;

// case DeviceEventType::kSessionEstablished:
// OnSessionEstablished(event);
// break;
case DeviceEventType::kInterfaceIpAddressChanged:
ChipLogProgress(Zcl, "IP(%s) changed event",
(event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) ? "IPv4" : "IPv6");
if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) ||
(event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned))
{
// MDNS server restart on any ip assignment: if link local ipv6 is configured, that
// will not trigger a 'internet connectivity change' as there is no internet
// connectivity. MDNS still wants to refresh its listening interfaces to include the
// newly selected address.
chip::app::DnssdServer::Instance().StartServer();
}
break;
case DeviceEventType::kCHIPoBLEConnectionEstablished:
ChipLogProgress(Zcl, "CHIPoBLE connection established");
break;
case DeviceEventType::kCHIPoBLEConnectionClosed:
ChipLogProgress(Zcl, "CHIPoBLE disconnected");
break;
case DeviceEventType::kCommissioningComplete:
ChipLogProgress(Zcl, "Commissioning complete");
break;
}
}

void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
{
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
{
ChipLogProgress(Zcl, "Server ready at:%d", CHIP_PORT);
// chip::app::DnssdServer::Instance().StartServer();
}
else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost)
{
ChipLogProgress(Zcl, "Lost IPv4 connectivity...");
}
if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
{
ChipLogProgress(Zcl, "IPv6 Server ready...");
chip::app::DnssdServer::Instance().StartServer();
}
else if (event->InternetConnectivityChange.IPv6 == kConnectivity_Lost)
{
ChipLogProgress(Zcl, "Lost IPv6 connectivity...");
}
}

void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event)
{
if (event->SessionEstablished.IsCommissioner)
{
ChipLogProgress(Zcl, "Commissioner detected!");
}
}

void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
{
switch (clusterId)
Expand All @@ -135,7 +70,7 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
}
}

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

void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
void AppDeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID,
ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId));
Expand All @@ -178,9 +113,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI
exit:
return;
}

bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj)
{
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
return true;
}
Loading

0 comments on commit a3dcebb

Please sign in to comment.