@@ -231,7 +231,7 @@ bool emberAfScenesClusterAddSceneCallback(app::CommandHandler * commandObj, cons
231
231
auto & sceneName = commandData.sceneName ;
232
232
auto & extensionFieldSets = commandData.extensionFieldSets ;
233
233
234
- return emberAfPluginScenesServerParseAddScene (commandObj, emberAfCurrentCommand () , groupId, sceneId, transitionTime, sceneName,
234
+ return emberAfPluginScenesServerParseAddScene (commandObj, commandPath , groupId, sceneId, transitionTime, sceneName,
235
235
extensionFieldSets);
236
236
}
237
237
@@ -241,7 +241,7 @@ bool emberAfScenesClusterViewSceneCallback(app::CommandHandler * commandObj, con
241
241
auto & groupId = commandData.groupID ;
242
242
auto & sceneId = commandData.sceneID ;
243
243
244
- return emberAfPluginScenesServerParseViewScene (commandObj, emberAfCurrentCommand () , groupId, sceneId);
244
+ return emberAfPluginScenesServerParseViewScene (commandObj, commandPath , groupId, sceneId);
245
245
}
246
246
247
247
bool emberAfScenesClusterRemoveSceneCallback (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
@@ -256,7 +256,7 @@ bool emberAfScenesClusterRemoveSceneCallback(app::CommandHandler * commandObj, c
256
256
257
257
emberAfScenesClusterPrintln (" RX: RemoveScene 0x%2x, 0x%x" , groupId, sceneId);
258
258
259
- if (!isEndpointInGroup (fabricIndex, emberAfCurrentEndpoint () , groupId))
259
+ if (!isEndpointInGroup (fabricIndex, commandPath. mEndpointId , groupId))
260
260
{
261
261
status = EMBER_ZCL_STATUS_INVALID_COMMAND;
262
262
}
@@ -267,33 +267,27 @@ bool emberAfScenesClusterRemoveSceneCallback(app::CommandHandler * commandObj, c
267
267
{
268
268
EmberAfSceneTableEntry entry;
269
269
emberAfPluginScenesServerRetrieveSceneEntry (entry, i);
270
- if (entry.endpoint == emberAfCurrentEndpoint () && entry.groupId == groupId && entry.sceneId == sceneId)
270
+ if (entry.endpoint == commandPath. mEndpointId && entry.groupId == groupId && entry.sceneId == sceneId)
271
271
{
272
272
entry.endpoint = EMBER_AF_SCENE_TABLE_UNUSED_ENDPOINT_ID;
273
273
emberAfPluginScenesServerSaveSceneEntry (entry, i);
274
274
emberAfPluginScenesServerDecrNumSceneEntriesInUse ();
275
- emberAfScenesSetSceneCountAttribute (emberAfCurrentEndpoint () , emberAfPluginScenesServerNumSceneEntriesInUse ());
275
+ emberAfScenesSetSceneCountAttribute (commandPath. mEndpointId , emberAfPluginScenesServerNumSceneEntriesInUse ());
276
276
status = EMBER_ZCL_STATUS_SUCCESS;
277
277
break ;
278
278
}
279
279
}
280
280
}
281
281
282
- // Remove Scene commands are only responded to when they are addressed to a
283
- // single device.
284
- if (emberAfCurrentCommand ()->type == EMBER_INCOMING_UNICAST || emberAfCurrentCommand ()->type == EMBER_INCOMING_UNICAST_REPLY)
285
- {
286
- {
287
- app::ConcreteCommandPath path = { emberAfCurrentEndpoint (), Scenes::Id, RemoveSceneResponse::Id };
288
- TLV::TLVWriter * writer = nullptr ;
289
- SuccessOrExit (err = commandObj->PrepareCommand (path));
290
- VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
291
- SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
292
- SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
293
- SuccessOrExit (err = writer->Put (TLV::ContextTag (2 ), sceneId));
294
- SuccessOrExit (err = commandObj->FinishCommand ());
295
- }
296
- }
282
+ app::ConcreteCommandPath path = { commandPath.mEndpointId , Scenes::Id, RemoveSceneResponse::Id };
283
+ TLV::TLVWriter * writer = nullptr ;
284
+ SuccessOrExit (err = commandObj->PrepareCommand (path));
285
+ VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
286
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
287
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
288
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (2 ), sceneId));
289
+ SuccessOrExit (err = commandObj->FinishCommand ());
290
+
297
291
exit :
298
292
if (err != CHIP_NO_ERROR)
299
293
{
@@ -313,38 +307,31 @@ bool emberAfScenesClusterRemoveAllScenesCallback(app::CommandHandler * commandOb
313
307
314
308
emberAfScenesClusterPrintln (" RX: RemoveAllScenes 0x%2x" , groupId);
315
309
316
- if (isEndpointInGroup (fabricIndex, emberAfCurrentEndpoint () , groupId))
310
+ if (isEndpointInGroup (fabricIndex, commandPath. mEndpointId , groupId))
317
311
{
318
312
uint8_t i;
319
313
status = EMBER_ZCL_STATUS_SUCCESS;
320
314
for (i = 0 ; i < MATTER_SCENES_TABLE_SIZE; i++)
321
315
{
322
316
EmberAfSceneTableEntry entry;
323
317
emberAfPluginScenesServerRetrieveSceneEntry (entry, i);
324
- if (entry.endpoint == emberAfCurrentEndpoint () && entry.groupId == groupId)
318
+ if (entry.endpoint == commandPath. mEndpointId && entry.groupId == groupId)
325
319
{
326
320
entry.endpoint = EMBER_AF_SCENE_TABLE_UNUSED_ENDPOINT_ID;
327
321
emberAfPluginScenesServerSaveSceneEntry (entry, i);
328
322
emberAfPluginScenesServerDecrNumSceneEntriesInUse ();
329
323
}
330
324
}
331
- emberAfScenesSetSceneCountAttribute (emberAfCurrentEndpoint () , emberAfPluginScenesServerNumSceneEntriesInUse ());
325
+ emberAfScenesSetSceneCountAttribute (commandPath. mEndpointId , emberAfPluginScenesServerNumSceneEntriesInUse ());
332
326
}
333
327
334
- // Remove All Scenes commands are only responded to when they are addressed
335
- // to a single device.
336
- if (emberAfCurrentCommand ()->type == EMBER_INCOMING_UNICAST || emberAfCurrentCommand ()->type == EMBER_INCOMING_UNICAST_REPLY)
337
- {
338
- {
339
- app::ConcreteCommandPath path = { emberAfCurrentEndpoint (), Scenes::Id, RemoveAllScenesResponse::Id };
340
- TLV::TLVWriter * writer = nullptr ;
341
- SuccessOrExit (err = commandObj->PrepareCommand (path));
342
- VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
343
- SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
344
- SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
345
- SuccessOrExit (err = commandObj->FinishCommand ());
346
- }
347
- }
328
+ app::ConcreteCommandPath path = { commandPath.mEndpointId , Scenes::Id, RemoveAllScenesResponse::Id };
329
+ TLV::TLVWriter * writer = nullptr ;
330
+ SuccessOrExit (err = commandObj->PrepareCommand (path));
331
+ VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
332
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
333
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
334
+ SuccessOrExit (err = commandObj->FinishCommand ());
348
335
exit :
349
336
if (err != CHIP_NO_ERROR)
350
337
{
@@ -363,23 +350,16 @@ bool emberAfScenesClusterStoreSceneCallback(app::CommandHandler * commandObj, co
363
350
EmberAfStatus status;
364
351
CHIP_ERROR err = CHIP_NO_ERROR;
365
352
emberAfScenesClusterPrintln (" RX: StoreScene 0x%2x, 0x%x" , groupId, sceneId);
366
- status = emberAfScenesClusterStoreCurrentSceneCallback (fabricIndex, emberAfCurrentEndpoint () , groupId, sceneId);
353
+ status = emberAfScenesClusterStoreCurrentSceneCallback (fabricIndex, commandPath. mEndpointId , groupId, sceneId);
367
354
368
- // Store Scene commands are only responded to when they are addressed to a
369
- // single device.
370
- if (emberAfCurrentCommand ()->type == EMBER_INCOMING_UNICAST || emberAfCurrentCommand ()->type == EMBER_INCOMING_UNICAST_REPLY)
371
- {
372
- {
373
- app::ConcreteCommandPath path = { emberAfCurrentEndpoint (), Scenes::Id, StoreSceneResponse::Id };
374
- TLV::TLVWriter * writer = nullptr ;
375
- SuccessOrExit (err = commandObj->PrepareCommand (path));
376
- VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
377
- SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
378
- SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
379
- SuccessOrExit (err = writer->Put (TLV::ContextTag (2 ), sceneId));
380
- SuccessOrExit (err = commandObj->FinishCommand ());
381
- }
382
- }
355
+ app::ConcreteCommandPath path = { commandPath.mEndpointId , Scenes::Id, StoreSceneResponse::Id };
356
+ TLV::TLVWriter * writer = nullptr ;
357
+ SuccessOrExit (err = commandObj->PrepareCommand (path));
358
+ VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
359
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
360
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
361
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (2 ), sceneId));
362
+ SuccessOrExit (err = commandObj->FinishCommand ());
383
363
exit :
384
364
if (err != CHIP_NO_ERROR)
385
365
{
@@ -410,11 +390,11 @@ bool emberAfScenesClusterRecallSceneCallback(app::CommandHandler * commandObj, c
410
390
411
391
EmberAfStatus status;
412
392
emberAfScenesClusterPrintln (" RX: RecallScene 0x%2x, 0x%x" , groupId, sceneId);
413
- status = emberAfScenesClusterRecallSavedSceneCallback (fabricIndex, emberAfCurrentEndpoint () , groupId, sceneId);
393
+ status = emberAfScenesClusterRecallSavedSceneCallback (fabricIndex, commandPath. mEndpointId , groupId, sceneId);
414
394
#ifdef EMBER_AF_PLUGIN_ZLL_SCENES_SERVER
415
395
if (status == EMBER_ZCL_STATUS_SUCCESS)
416
396
{
417
- emberAfPluginZllScenesServerRecallSceneZllExtensions (emberAfCurrentEndpoint () );
397
+ emberAfPluginZllScenesServerRecallSceneZllExtensions (commandPath. mEndpointId );
418
398
}
419
399
#endif
420
400
CHIP_ERROR sendErr = commandObj->AddStatus (commandPath, app::ToInteractionModelStatus (status));
@@ -438,7 +418,7 @@ bool emberAfScenesClusterGetSceneMembershipCallback(app::CommandHandler * comman
438
418
439
419
emberAfScenesClusterPrintln (" RX: GetSceneMembership 0x%2x" , groupId);
440
420
441
- if (!isEndpointInGroup (fabricIndex, emberAfCurrentEndpoint () , groupId))
421
+ if (!isEndpointInGroup (fabricIndex, commandPath. mEndpointId , groupId))
442
422
{
443
423
status = EMBER_ZCL_STATUS_INVALID_COMMAND;
444
424
}
@@ -450,7 +430,7 @@ bool emberAfScenesClusterGetSceneMembershipCallback(app::CommandHandler * comman
450
430
{
451
431
EmberAfSceneTableEntry entry;
452
432
emberAfPluginScenesServerRetrieveSceneEntry (entry, i);
453
- if (entry.endpoint == emberAfCurrentEndpoint () && entry.groupId == groupId)
433
+ if (entry.endpoint == commandPath. mEndpointId && entry.groupId == groupId)
454
434
{
455
435
sceneList[sceneCount] = entry.sceneId ;
456
436
sceneCount++;
@@ -464,7 +444,7 @@ bool emberAfScenesClusterGetSceneMembershipCallback(app::CommandHandler * comman
464
444
}
465
445
466
446
{
467
- app::ConcreteCommandPath path = { emberAfCurrentEndpoint () , Scenes::Id, GetSceneMembershipResponse::Id };
447
+ app::ConcreteCommandPath path = { commandPath. mEndpointId , Scenes::Id, GetSceneMembershipResponse::Id };
468
448
TLV::TLVWriter * writer = nullptr ;
469
449
SuccessOrExit (err = commandObj->PrepareCommand (path));
470
450
VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
@@ -738,15 +718,16 @@ struct NullableUnderlyingType<app::DataModel::Nullable<T>>
738
718
};
739
719
740
720
bool emberAfPluginScenesServerParseAddScene (
741
- app::CommandHandler * commandObj, const EmberAfClusterCommand * cmd, GroupId groupId, uint8_t sceneId, uint16_t transitionTime,
742
- const CharSpan & sceneName, const app::DataModel::DecodableList<Structs::ExtensionFieldSet::DecodableType> & extensionFieldSets)
721
+ app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, GroupId groupId, uint8_t sceneId,
722
+ uint16_t transitionTime, const CharSpan & sceneName,
723
+ const app::DataModel::DecodableList<Structs::ExtensionFieldSet::DecodableType> & extensionFieldSets)
743
724
{
744
725
CHIP_ERROR err = CHIP_NO_ERROR;
745
726
EmberAfSceneTableEntry entry;
746
727
EmberAfStatus status;
747
- bool enhanced = (cmd-> commandId == EnhancedAddScene::Id);
728
+ bool enhanced = (commandPath. mCommandId == EnhancedAddScene::Id);
748
729
auto fabricIndex = commandObj->GetAccessingFabricIndex ();
749
- EndpointId endpoint = cmd-> apsFrame -> destinationEndpoint ;
730
+ EndpointId endpoint = commandPath. mEndpointId ;
750
731
uint8_t i, index = EMBER_AF_SCENE_TABLE_NULL_INDEX;
751
732
752
733
emberAfScenesClusterPrintln (" RX: %pAddScene 0x%2x, 0x%x, 0x%2x, \" %.*s\" " , (enhanced ? " Enhanced" : " " ), groupId, sceneId,
@@ -1104,26 +1085,19 @@ bool emberAfPluginScenesServerParseAddScene(
1104
1085
status = EMBER_ZCL_STATUS_SUCCESS;
1105
1086
1106
1087
kickout:
1107
- // Add Scene commands are only responded to when they are addressed to a
1108
- // single device.
1109
- if (emberAfCurrentCommand ()->type != EMBER_INCOMING_UNICAST && emberAfCurrentCommand ()->type != EMBER_INCOMING_UNICAST_REPLY)
1110
- {
1111
- return true ;
1112
- }
1088
+
1089
+ app::ConcreteCommandPath path = { commandPath.mEndpointId , Scenes::Id, AddSceneResponse::Id };
1090
+ if (enhanced)
1113
1091
{
1114
- app::ConcreteCommandPath path = { emberAfCurrentEndpoint (), Scenes::Id, AddSceneResponse::Id };
1115
- if (enhanced)
1116
- {
1117
- path = { emberAfCurrentEndpoint (), Scenes::Id, EnhancedAddSceneResponse::Id };
1118
- }
1119
- TLV::TLVWriter * writer = nullptr ;
1120
- SuccessOrExit (err = commandObj->PrepareCommand (path));
1121
- VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
1122
- SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
1123
- SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
1124
- SuccessOrExit (err = writer->Put (TLV::ContextTag (2 ), sceneId));
1125
- SuccessOrExit (err = commandObj->FinishCommand ());
1092
+ path = { commandPath.mEndpointId , Scenes::Id, EnhancedAddSceneResponse::Id };
1126
1093
}
1094
+ TLV::TLVWriter * writer = nullptr ;
1095
+ SuccessOrExit (err = commandObj->PrepareCommand (path));
1096
+ VerifyOrExit ((writer = commandObj->GetCommandDataIBTLVWriter ()) != nullptr , err = CHIP_ERROR_INCORRECT_STATE);
1097
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (0 ), status));
1098
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (1 ), groupId));
1099
+ SuccessOrExit (err = writer->Put (TLV::ContextTag (2 ), sceneId));
1100
+ SuccessOrExit (err = commandObj->FinishCommand ());
1127
1101
1128
1102
exit :
1129
1103
if (err != CHIP_NO_ERROR)
@@ -1133,15 +1107,15 @@ bool emberAfPluginScenesServerParseAddScene(
1133
1107
return true ;
1134
1108
}
1135
1109
1136
- bool emberAfPluginScenesServerParseViewScene (app::CommandHandler * commandObj, const EmberAfClusterCommand * cmd, GroupId groupId ,
1137
- uint8_t sceneId)
1110
+ bool emberAfPluginScenesServerParseViewScene (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath ,
1111
+ GroupId groupId, uint8_t sceneId)
1138
1112
{
1139
1113
CHIP_ERROR err = CHIP_NO_ERROR;
1140
1114
EmberAfSceneTableEntry entry = {};
1141
1115
EmberAfStatus status = EMBER_ZCL_STATUS_NOT_FOUND;
1142
- bool enhanced = (cmd-> commandId == EnhancedViewScene::Id);
1116
+ bool enhanced = (commandPath. mCommandId == EnhancedViewScene::Id);
1143
1117
FabricIndex fabricIndex = commandObj->GetAccessingFabricIndex ();
1144
- EndpointId endpoint = cmd-> apsFrame -> destinationEndpoint ;
1118
+ EndpointId endpoint = commandPath. mEndpointId ;
1145
1119
1146
1120
emberAfScenesClusterPrintln (" RX: %pViewScene 0x%2x, 0x%x" , (enhanced ? " Enhanced" : " " ), groupId, sceneId);
1147
1121
@@ -1167,10 +1141,10 @@ bool emberAfPluginScenesServerParseViewScene(app::CommandHandler * commandObj, c
1167
1141
// The status, group id, and scene id are always included in the response, but
1168
1142
// the transition time, name, and extension fields are only included if the
1169
1143
// scene was found.
1170
- app::ConcreteCommandPath path = { emberAfCurrentEndpoint () , Scenes::Id, ViewSceneResponse::Id };
1144
+ app::ConcreteCommandPath path = { commandPath. mEndpointId , Scenes::Id, ViewSceneResponse::Id };
1171
1145
if (enhanced)
1172
1146
{
1173
- path = { emberAfCurrentEndpoint () , Scenes::Id, EnhancedViewSceneResponse::Id };
1147
+ path = { commandPath. mEndpointId , Scenes::Id, EnhancedViewSceneResponse::Id };
1174
1148
}
1175
1149
TLV::TLVWriter * writer = nullptr ;
1176
1150
SuccessOrExit (err = commandObj->PrepareCommand (path));
@@ -1324,12 +1298,6 @@ bool emberAfPluginScenesServerParseViewScene(app::CommandHandler * commandObj, c
1324
1298
#endif
1325
1299
}
1326
1300
1327
- // View Scene commands are only responded to when they are addressed to a
1328
- // single device.
1329
- if (emberAfCurrentCommand()->type != EMBER_INCOMING_UNICAST && emberAfCurrentCommand()->type != EMBER_INCOMING_UNICAST_REPLY)
1330
- {
1331
- return true;
1332
- }
1333
1301
sendStatus = emberAfSendResponse();
1334
1302
if (EMBER_SUCCESS != sendStatus)
1335
1303
{
@@ -1358,7 +1326,7 @@ void emberAfScenesClusterRemoveScenesInGroupCallback(EndpointId endpoint, GroupI
1358
1326
entry.endpoint = EMBER_AF_SCENE_TABLE_UNUSED_ENDPOINT_ID;
1359
1327
emberAfPluginScenesServerSaveSceneEntry (entry, i);
1360
1328
emberAfPluginScenesServerDecrNumSceneEntriesInUse ();
1361
- emberAfScenesSetSceneCountAttribute (emberAfCurrentEndpoint () , emberAfPluginScenesServerNumSceneEntriesInUse ());
1329
+ emberAfScenesSetSceneCountAttribute (endpoint , emberAfPluginScenesServerNumSceneEntriesInUse ());
1362
1330
}
1363
1331
}
1364
1332
}
0 commit comments