@@ -97,16 +97,19 @@ class Attribute
97
97
static_cast <ReadAttributeContext<TypeInfo> *>(__context);
98
98
ChipLogProgress (AppServer, " <Attribute>::Read() success" );
99
99
Attribute<TypeInfo> * __attr = static_cast <Attribute<TypeInfo> *>(__attributeContext->mAttribute );
100
- __attr->value = response;
101
100
if (__attr->hasValue )
102
101
{
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 );
105
106
}
106
107
else
107
108
{
108
109
__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 );
110
113
}
111
114
delete __attributeContext;
112
115
},
@@ -269,17 +272,19 @@ class Attribute
269
272
static_cast <SubscribeAttributeContext<TypeInfo> *>(__context);
270
273
ChipLogProgress (AppServer, " <Attribute>::Subscribe() success" );
271
274
Attribute<TypeInfo> * __attr = static_cast <Attribute<TypeInfo> *>(__attributeContext->mAttribute );
272
- __attr->value = response;
273
- // TODO: Save old value and then overwrite
274
275
if (__attr->hasValue )
275
276
{
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 );
278
281
}
279
282
else
280
283
{
281
284
__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 );
283
288
}
284
289
delete __attributeContext;
285
290
},
0 commit comments