Skip to content

Commit f29ccbe

Browse files
tv-casting-app fixes: saving prevValue before callback (project-chip#32843)
1 parent 297bea3 commit f29ccbe

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

examples/tv-casting-app/APIs.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ client's lifecycle:
158158
the Matter specification's "Onboarding Payload" section for more details on
159159
commissioning data.
160160

161-
On Linux, define a function `InitCommissionableDataProvider` to initialize
162-
initialize a `LinuxCommissionableDataProvider` that can provide the required
163-
values to the `CastingApp`.
161+
On Linux, define a function `InitCommissionableDataProvider` to initialize a
162+
`LinuxCommissionableDataProvider` that can provide the required values to
163+
the `CastingApp`.
164164

165165
```c
166166
CHIP_ERROR InitCommissionableDataProvider(LinuxCommissionableDataProvider & provider, LinuxDeviceOptions & options) {
@@ -917,14 +917,14 @@ On iOS refer to the following platform specific files:
917917
918918
1. For a list of clusters, commands and attributes supported by the Matter TV
919919
Casting library:
920-
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h)
920+
[darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCClusterObjects.h)
921921
2. For the IDs and request / response types to use with the commands:
922-
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h)
922+
[darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandObjects.h)
923923
and
924-
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h)
924+
[darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCCommandPayloads.h)
925925
3. For attribute [read operations](#read-operations) and
926926
[subscriptions](#subscriptions):
927-
[/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h](/darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h)
927+
[darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h](darwin/MatterTvCastingBridge/MatterTvCastingBridge/zap-generated/MCAttributeObjects.h)
928928
929929
### Issuing Commands
930930

examples/tv-casting-app/linux/main.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ CHIP_ERROR ProcessClusterCommand(int argc, char ** argv)
106106

107107
int main(int argc, char * argv[])
108108
{
109+
ChipLogProgress(AppServer, "chip_casting_simplified = 0"); // this file is built/run only if chip_casting_simplified = 0
109110
VerifyOrDie(CHIP_NO_ERROR == chip::Platform::MemoryInit());
110111
VerifyOrDie(CHIP_NO_ERROR == chip::DeviceLayer::PlatformMgr().InitChipStack());
111112

examples/tv-casting-app/linux/simple-app.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class CommonCaseDeviceServerInitParamsProvider : public ServerInitParamsProvider
130130

131131
int main(int argc, char * argv[])
132132
{
133+
ChipLogProgress(AppServer, "chip_casting_simplified = 1"); // this file is built/run only if chip_casting_simplified = 1
133134
// Create AppParameters that need to be passed to CastingApp.Initialize()
134135
AppParameters appParameters;
135136
RotatingDeviceIdUniqueIdProvider rotatingDeviceIdUniqueIdProvider;

examples/tv-casting-app/tv-casting-common/core/Attribute.h

+14-9
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,19 @@ class Attribute
9797
static_cast<ReadAttributeContext<TypeInfo> *>(__context);
9898
ChipLogProgress(AppServer, "<Attribute>::Read() success");
9999
Attribute<TypeInfo> * __attr = static_cast<Attribute<TypeInfo> *>(__attributeContext->mAttribute);
100-
__attr->value = response;
101100
if (__attr->hasValue)
102101
{
103-
__attributeContext->mSuccessCb(__attributeContext->mClientContext,
104-
chip::MakeOptional(__attr->value), response);
102+
typename TypeInfo::DecodableType prevValue = __attr->value;
103+
__attr->value = response;
104+
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::MakeOptional(prevValue),
105+
__attr->value);
105106
}
106107
else
107108
{
108109
__attr->hasValue = true;
109-
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, response);
110+
__attr->value = response;
111+
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional,
112+
__attr->value);
110113
}
111114
delete __attributeContext;
112115
},
@@ -269,17 +272,19 @@ class Attribute
269272
static_cast<SubscribeAttributeContext<TypeInfo> *>(__context);
270273
ChipLogProgress(AppServer, "<Attribute>::Subscribe() success");
271274
Attribute<TypeInfo> * __attr = static_cast<Attribute<TypeInfo> *>(__attributeContext->mAttribute);
272-
__attr->value = response;
273-
// TODO: Save old value and then overwrite
274275
if (__attr->hasValue)
275276
{
276-
__attributeContext->mSuccessCb(__attributeContext->mClientContext,
277-
chip::MakeOptional(__attr->value), response);
277+
typename TypeInfo::DecodableType prevValue = __attr->value;
278+
__attr->value = response;
279+
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::MakeOptional(prevValue),
280+
__attr->value);
278281
}
279282
else
280283
{
281284
__attr->hasValue = true;
282-
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional, response);
285+
__attr->value = response;
286+
__attributeContext->mSuccessCb(__attributeContext->mClientContext, chip::NullOptional,
287+
__attr->value);
283288
}
284289
delete __attributeContext;
285290
},

examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h

+7
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
#define CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_SUBJECTS_PER_ENTRY 20
5959
#define CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_ENTRIES_PER_FABRIC 20
6060

61+
/**
62+
* For casting, we need to allow for more binding table entries because the Casting App can connect to many Matter Casting Players,
63+
* each with many Content Apps. Each Casting Player will set 1 binding per endpoint on it. A Casting Player will have 1 endpoint for
64+
* every Matter Content App installed on it + 1 endpoint representing the Casting Player + 1 endpoint representing a speaker.
65+
*/
66+
#define MATTER_BINDING_TABLE_SIZE 64
67+
6168
// Enable some test-only interaction model APIs.
6269
#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1
6370

0 commit comments

Comments
 (0)