From 48937695ce4880c13e19ced448c227619f765c54 Mon Sep 17 00:00:00 2001 From: cbucht200 <100870495+cbucht200@users.noreply.github.com> Date: Mon, 20 Mar 2023 16:18:01 -0400 Subject: [PATCH] Fixes #25733 - Add External Attribute callbacks for static endpoints when ContentAppPlatform is enabled (#25735) * The ContentAppPlatform source file implements the emberAfExternalAttributeReadCallback / emberAfExternalAttributeWriteCallback callbacks. The current logic checks to see if the request can be handled by one of the ContentApps, and if not, failure is returned. If static endpoints have external attributes and ContentAppPlatform is enabled, it is not possible to serve those requests as the callbacks are implemented in the AppPlatform. * Remove Af from callback names * Remove Af from callback names * Restyled by clang-format --------- Co-authored-by: Restyled.io --- src/app/app-platform/ContentAppPlatform.cpp | 22 +++++++++++++++++++++ src/app/app-platform/ContentAppPlatform.h | 11 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/app/app-platform/ContentAppPlatform.cpp b/src/app/app-platform/ContentAppPlatform.cpp index 1a611500ef5db4..d162ec4bbab7ad 100644 --- a/src/app/app-platform/ContentAppPlatform.cpp +++ b/src/app/app-platform/ContentAppPlatform.cpp @@ -60,6 +60,10 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI { ret = app->HandleReadAttribute(clusterId, attributeMetadata->attributeId, buffer, maxReadLength); } + else + { + ret = AppPlatformExternalAttributeReadCallback(endpoint, clusterId, attributeMetadata, buffer, maxReadLength); + } return ret; } @@ -78,6 +82,10 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster { ret = app->HandleWriteAttribute(clusterId, attributeMetadata->attributeId, buffer); } + else + { + ret = AppPlatformExternalAttributeWriteCallback(endpoint, clusterId, attributeMetadata, buffer); + } return ret; } @@ -85,6 +93,20 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster namespace chip { namespace AppPlatform { +EmberAfStatus __attribute__((weak)) AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength) +{ + return (EMBER_ZCL_STATUS_FAILURE); +} + +EmberAfStatus __attribute__((weak)) +AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer) +{ + return (EMBER_ZCL_STATUS_FAILURE); +} + EndpointId ContentAppPlatform::AddContentApp(ContentApp * app, EmberAfEndpointType * ep, const Span & dataVersionStorage, const Span & deviceTypeList) diff --git a/src/app/app-platform/ContentAppPlatform.h b/src/app/app-platform/ContentAppPlatform.h index 69248cd431e3c7..8ab9efab8250c6 100644 --- a/src/app/app-platform/ContentAppPlatform.h +++ b/src/app/app-platform/ContentAppPlatform.h @@ -38,6 +38,17 @@ using BindingListType = chip::app::Clusters::Binding::Attributes::Binding::TypeI namespace chip { namespace AppPlatform { +// The AppPlatform overrides emberAfExternalAttributeReadCallback to handle external attribute reads for ContentApps. +// This callback can be used to handle external attribute reads for attributes belonging to static endpoints. +EmberAfStatus AppPlatformExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength); + +// The AppPlatform overrides emberAfExternalAttributeWriteCallback to handle external attribute writes for ContentApps. +// This callback can be used to handle external attribute writes for attributes belonging to static endpoints. +EmberAfStatus AppPlatformExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer); + constexpr EndpointId kTargetBindingClusterEndpointId = 0; constexpr EndpointId kLocalVideoPlayerEndpointId = 1; constexpr EndpointId kLocalSpeakerEndpointId = 2;