tv-casting-app fixes: saving prevValue before callback (#32843)
diff --git a/examples/tv-casting-app/APIs.md b/examples/tv-casting-app/APIs.md index 5d80fca..12f5fdf 100644 --- a/examples/tv-casting-app/APIs.md +++ b/examples/tv-casting-app/APIs.md
@@ -158,9 +158,9 @@ the Matter specification's "Onboarding Payload" section for more details on commissioning data. - On Linux, define a function `InitCommissionableDataProvider` to initialize - initialize a `LinuxCommissionableDataProvider` that can provide the required - values to the `CastingApp`. + On Linux, define a function `InitCommissionableDataProvider` to initialize a + `LinuxCommissionableDataProvider` that can provide the required values to + the `CastingApp`. ```c CHIP_ERROR InitCommissionableDataProvider(LinuxCommissionableDataProvider & provider, LinuxDeviceOptions & options) { @@ -917,14 +917,14 @@ 1. For a list of clusters, commands and attributes supported by the Matter TV Casting library: - [/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h) + [darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h) 2. For the IDs and request / response types to use with the commands: - [/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h) + [darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h) and - [/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h) + [darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h) 3. For attribute [read operations](#read-operations) and [subscriptions](#subscriptions): - [/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h) + [darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h) ### Issuing Commands
diff --git a/examples/tv-casting-app/linux/main.cpp b/examples/tv-casting-app/linux/main.cpp index 45c53c8..0dde8a2 100644 --- a/examples/tv-casting-app/linux/main.cpp +++ b/examples/tv-casting-app/linux/main.cpp
@@ -106,6 +106,7 @@ int main(int argc, char * argv[]) { + ChipLogProgress(AppServer, "chip_casting_simplified = 0"); // this file is built/run only if chip_casting_simplified = 0 VerifyOrDie(CHIP_NO_ERROR == chip::Platform::MemoryInit()); VerifyOrDie(CHIP_NO_ERROR == chip::DeviceLayer::PlatformMgr().InitChipStack());
diff --git a/examples/tv-casting-app/linux/simple-app.cpp b/examples/tv-casting-app/linux/simple-app.cpp index 26d35b4..01e3346 100644 --- a/examples/tv-casting-app/linux/simple-app.cpp +++ b/examples/tv-casting-app/linux/simple-app.cpp
@@ -130,6 +130,7 @@ int main(int argc, char * argv[]) { + ChipLogProgress(AppServer, "chip_casting_simplified = 1"); // this file is built/run only if chip_casting_simplified = 1 // Create AppParameters that need to be passed to CastingApp.Initialize() AppParameters appParameters; RotatingDeviceIdUniqueIdProvider rotatingDeviceIdUniqueIdProvider;
diff --git a/examples/tv-casting-app/tv-casting-common/core/Attribute.h b/examples/tv-casting-app/tv-casting-common/core/Attribute.h index 958c7ab..6e717d3 100644 --- a/examples/tv-casting-app/tv-casting-common/core/Attribute.h +++ b/examples/tv-casting-app/tv-casting-common/core/Attribute.h
@@ -97,16 +97,19 @@ static_cast<ReadAttributeContext<TypeInfo> *>(__context); ChipLogProgress(AppServer, "<Attribute>::Read() success"); Attribute<TypeInfo> * __attr = static_cast<Attribute<TypeInfo> *>(__attributeContext->mAttribute); - __attr->value = response; if (__attr->hasValue) { - __attributeContext->mSuccessCb(__attributeContext->mClientContext, - chip::MakeOptional(__attr->value), response); + typename TypeInfo::DecodableType prevValue = __attr->value; + __attr->value = response; + __attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::MakeOptional(prevValue), + __attr->value); } else { __attr->hasValue = true; - __attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, response); + __attr->value = response; + __attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, + __attr->value); } delete __attributeContext; }, @@ -269,17 +272,19 @@ static_cast<SubscribeAttributeContext<TypeInfo> *>(__context); ChipLogProgress(AppServer, "<Attribute>::Subscribe() success"); Attribute<TypeInfo> * __attr = static_cast<Attribute<TypeInfo> *>(__attributeContext->mAttribute); - __attr->value = response; - // TODO: Save old value and then overwrite if (__attr->hasValue) { - __attributeContext->mSuccessCb(__attributeContext->mClientContext, - chip::MakeOptional(__attr->value), response); + typename TypeInfo::DecodableType prevValue = __attr->value; + __attr->value = response; + __attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::MakeOptional(prevValue), + __attr->value); } else { __attr->hasValue = true; - __attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, response); + __attr->value = response; + __attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, + __attr->value); } delete __attributeContext; },
diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h index 6a9549e..74926b0 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h
@@ -58,6 +58,13 @@ #define CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_SUBJECTS_PER_ENTRY 20 #define CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_ENTRIES_PER_FABRIC 20 +/** + * For casting, we need to allow for more binding table entries because the Casting App can connect to many Matter Casting Players, + * each with many Content Apps. Each Casting Player will set 1 binding per endpoint on it. A Casting Player will have 1 endpoint for + * every Matter Content App installed on it + 1 endpoint representing the Casting Player + 1 endpoint representing a speaker. + */ +#define MATTER_BINDING_TABLE_SIZE 64 + // Enable some test-only interaction model APIs. #define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1