Skip to content

Commit

Permalink
Fixes #25733 - Add External Attribute callbacks for static endpoints …
Browse files Browse the repository at this point in the history
…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 <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed May 3, 2023
1 parent 45679dd commit 4893769
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/app-platform/ContentAppPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -78,13 +82,31 @@ EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, Cluster
{
ret = app->HandleWriteAttribute(clusterId, attributeMetadata->attributeId, buffer);
}
else
{
ret = AppPlatformExternalAttributeWriteCallback(endpoint, clusterId, attributeMetadata, buffer);
}

return ret;
}

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<DataVersion> & dataVersionStorage,
const Span<const EmberAfDeviceType> & deviceTypeList)
Expand Down
11 changes: 11 additions & 0 deletions src/app/app-platform/ContentAppPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4893769

Please sign in to comment.