17
17
18
18
#include " thermostat-server.h"
19
19
20
+ #include < app/GlobalAttributes.h>
20
21
#include < platform/internal/CHIPDeviceLayerInternal.h>
21
22
22
23
using namespace chip ;
@@ -47,6 +48,8 @@ void TimerExpiredCallback(System::Layer * systemLayer, void * callbackContext)
47
48
gThermostatAttrAccess .ResetAtomicWrite (endpoint);
48
49
}
49
50
51
+ namespace {
52
+
50
53
/* *
51
54
* @brief Schedules a timer for the given timeout in milliseconds.
52
55
*
@@ -185,15 +188,25 @@ Status BuildAttributeStatuses(const EndpointId endpoint, const DataModel::Decoda
185
188
const EmberAfAttributeMetadata * metadata =
186
189
emberAfLocateAttributeMetadata (endpoint, Thermostat::Id, attributeStatus.attributeID );
187
190
188
- if (metadata == nullptr )
191
+ if (metadata != nullptr )
192
+ {
193
+ // This is definitely an attribute we know about.
194
+ continue ;
195
+ }
196
+
197
+ if (IsSupportedGlobalAttributeNotInMetadata (attributeStatus.attributeID ))
189
198
{
190
- // This is not a valid attribute on the Thermostat cluster on the supplied endpoint
191
- return Status::InvalidCommand;
199
+ continue ;
192
200
}
201
+
202
+ // This is not a valid attribute on the Thermostat cluster on the supplied endpoint
203
+ return Status::InvalidCommand;
193
204
}
194
205
return Status::Success;
195
206
}
196
207
208
+ } // anonymous namespace
209
+
197
210
bool ThermostatAttrAccess::InAtomicWrite (EndpointId endpoint, Optional<AttributeId> attributeId)
198
211
{
199
212
@@ -422,6 +435,10 @@ void ThermostatAttrAccess::BeginAtomicWrite(CommandHandler * commandObj, const C
422
435
status = Status::Success;
423
436
for (size_t i = 0 ; i < attributeStatuses.AllocatedSize (); ++i)
424
437
{
438
+ // If we've gotten this far, then the client has manage permission to call AtomicRequest,
439
+ // which is also the privilege necessary to write to the atomic attributes, so no need to do
440
+ // the "If the client does not have sufficient privilege to write to the attribute" check
441
+ // from the spec.
425
442
auto & attributeStatus = attributeStatuses[i];
426
443
auto statusCode = Status::Success;
427
444
switch (attributeStatus.attributeID )
@@ -442,11 +459,6 @@ void ThermostatAttrAccess::BeginAtomicWrite(CommandHandler * commandObj, const C
442
459
}
443
460
444
461
auto timeout = std::min (System::Clock::Milliseconds16 (commandData.timeout .Value ()), maximumTimeout);
445
- if (timeout.count () == 0 )
446
- {
447
- commandObj->AddStatus (commandPath, Status::InvalidInState);
448
- return ;
449
- }
450
462
451
463
if (status == Status::Success)
452
464
{
@@ -605,9 +617,6 @@ bool emberAfThermostatClusterAtomicRequestCallback(CommandHandler * commandObj,
605
617
{
606
618
auto & requestType = commandData.requestType ;
607
619
608
- // If we've gotten this far, then the client has manage permission to call AtomicRequest, which is also the
609
- // privilege necessary to write to the atomic attributes, so no need to check
610
-
611
620
switch (requestType)
612
621
{
613
622
case Globals::AtomicRequestTypeEnum::kBeginWrite :
0 commit comments