@@ -65,6 +65,13 @@ uint8_t emberAfPluginScenesServerEntriesInUse = 0;
65
65
EmberAfSceneTableEntry emberAfPluginScenesServerSceneTable[EMBER_AF_PLUGIN_SCENES_TABLE_SIZE];
66
66
#endif
67
67
68
+ static FabricIndex GetFabricIndex (app::CommandHandler * commandObj)
69
+ {
70
+ VerifyOrReturnError (nullptr != commandObj, 0 );
71
+ VerifyOrReturnError (nullptr != commandObj->GetExchangeContext (), 0 );
72
+ return commandObj->GetExchangeContext ()->GetSessionHandle ().GetFabricIndex ();
73
+ }
74
+
68
75
static bool readServerAttribute (EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, const char * name,
69
76
uint8_t * data, uint8_t size)
70
77
{
@@ -95,10 +102,11 @@ static EmberAfStatus writeServerAttribute(EndpointId endpoint, ClusterId cluster
95
102
return status;
96
103
}
97
104
98
- bool isEndpointInGroup (EndpointId endpoint, GroupId groupId)
105
+ bool isEndpointInGroup (chip::FabricIndex fabricIndex, EndpointId endpoint, GroupId groupId)
99
106
{
100
107
#ifdef EMBER_AF_PLUGIN_GROUPS_SERVER
101
- return (groupId == ZCL_SCENES_GLOBAL_SCENE_GROUP_ID || emberAfGroupsClusterEndpointInGroupCallback (endpoint, groupId));
108
+ return (groupId == ZCL_SCENES_GLOBAL_SCENE_GROUP_ID ||
109
+ emberAfGroupsClusterEndpointInGroupCallback (fabricIndex, endpoint, groupId));
102
110
#else
103
111
return (groupId == ZCL_SCENES_GLOBAL_SCENE_GROUP_ID);
104
112
#endif // EMBER_AF_PLUGIN_GROUPS_SERVER
@@ -244,15 +252,16 @@ bool emberAfScenesClusterViewSceneCallback(app::CommandHandler * commandObj, con
244
252
bool emberAfScenesClusterRemoveSceneCallback (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
245
253
const Commands::RemoveScene::DecodableType & commandData)
246
254
{
247
- auto & groupId = commandData.groupId ;
248
- auto & sceneId = commandData.sceneId ;
255
+ auto fabricIndex = GetFabricIndex (commandObj);
256
+ auto & groupId = commandData.groupId ;
257
+ auto & sceneId = commandData.sceneId ;
249
258
250
259
EmberAfStatus status = EMBER_ZCL_STATUS_NOT_FOUND;
251
260
CHIP_ERROR err = CHIP_NO_ERROR;
252
261
253
262
emberAfScenesClusterPrintln (" RX: RemoveScene 0x%2x, 0x%x" , groupId, sceneId);
254
263
255
- if (!isEndpointInGroup (emberAfCurrentEndpoint (), groupId))
264
+ if (!isEndpointInGroup (fabricIndex, emberAfCurrentEndpoint (), groupId))
256
265
{
257
266
status = EMBER_ZCL_STATUS_INVALID_FIELD;
258
267
}
@@ -302,14 +311,15 @@ bool emberAfScenesClusterRemoveSceneCallback(app::CommandHandler * commandObj, c
302
311
bool emberAfScenesClusterRemoveAllScenesCallback (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
303
312
const Commands::RemoveAllScenes::DecodableType & commandData)
304
313
{
305
- auto & groupId = commandData.groupId ;
314
+ auto fabricIndex = GetFabricIndex (commandObj);
315
+ auto & groupId = commandData.groupId ;
306
316
307
317
EmberAfStatus status = EMBER_ZCL_STATUS_INVALID_FIELD;
308
318
CHIP_ERROR err = CHIP_NO_ERROR;
309
319
310
320
emberAfScenesClusterPrintln (" RX: RemoveAllScenes 0x%2x" , groupId);
311
321
312
- if (isEndpointInGroup (emberAfCurrentEndpoint (), groupId))
322
+ if (isEndpointInGroup (fabricIndex, emberAfCurrentEndpoint (), groupId))
313
323
{
314
324
uint8_t i;
315
325
status = EMBER_ZCL_STATUS_SUCCESS;
@@ -354,13 +364,14 @@ bool emberAfScenesClusterRemoveAllScenesCallback(app::CommandHandler * commandOb
354
364
bool emberAfScenesClusterStoreSceneCallback (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
355
365
const Commands::StoreScene::DecodableType & commandData)
356
366
{
357
- auto & groupId = commandData.groupId ;
358
- auto & sceneId = commandData.sceneId ;
367
+ auto fabricIndex = GetFabricIndex (commandObj);
368
+ auto & groupId = commandData.groupId ;
369
+ auto & sceneId = commandData.sceneId ;
359
370
360
371
EmberAfStatus status;
361
372
CHIP_ERROR err = CHIP_NO_ERROR;
362
373
emberAfScenesClusterPrintln (" RX: StoreScene 0x%2x, 0x%x" , groupId, sceneId);
363
- status = emberAfScenesClusterStoreCurrentSceneCallback (emberAfCurrentEndpoint (), groupId, sceneId);
374
+ status = emberAfScenesClusterStoreCurrentSceneCallback (fabricIndex, emberAfCurrentEndpoint (), groupId, sceneId);
364
375
365
376
// Store Scene commands are only responded to when they are addressed to a
366
377
// single device.
@@ -389,8 +400,9 @@ bool emberAfScenesClusterStoreSceneCallback(app::CommandHandler * commandObj, co
389
400
bool emberAfScenesClusterRecallSceneCallback (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
390
401
const Commands::RecallScene::DecodableType & commandData)
391
402
{
392
- auto & groupId = commandData.groupId ;
393
- auto & sceneId = commandData.sceneId ;
403
+ auto fabricIndex = GetFabricIndex (commandObj);
404
+ auto & groupId = commandData.groupId ;
405
+ auto & sceneId = commandData.sceneId ;
394
406
395
407
// NOTE: TransitionTime field in the RecallScene command is currently
396
408
// ignored. Per Zigbee Alliance ZCL 7 (07-5123-07):
@@ -408,7 +420,7 @@ bool emberAfScenesClusterRecallSceneCallback(app::CommandHandler * commandObj, c
408
420
EmberAfStatus status;
409
421
EmberStatus sendStatus = EMBER_SUCCESS;
410
422
emberAfScenesClusterPrintln (" RX: RecallScene 0x%2x, 0x%x" , groupId, sceneId);
411
- status = emberAfScenesClusterRecallSavedSceneCallback (emberAfCurrentEndpoint (), groupId, sceneId);
423
+ status = emberAfScenesClusterRecallSavedSceneCallback (fabricIndex, emberAfCurrentEndpoint (), groupId, sceneId);
412
424
#ifdef EMBER_AF_PLUGIN_ZLL_SCENES_SERVER
413
425
if (status == EMBER_ZCL_STATUS_SUCCESS)
414
426
{
@@ -426,7 +438,8 @@ bool emberAfScenesClusterRecallSceneCallback(app::CommandHandler * commandObj, c
426
438
bool emberAfScenesClusterGetSceneMembershipCallback (app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath,
427
439
const Commands::GetSceneMembership::DecodableType & commandData)
428
440
{
429
- auto & groupId = commandData.groupId ;
441
+ auto fabricIndex = GetFabricIndex (commandObj);
442
+ auto & groupId = commandData.groupId ;
430
443
431
444
CHIP_ERROR err = CHIP_NO_ERROR;
432
445
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
@@ -435,7 +448,7 @@ bool emberAfScenesClusterGetSceneMembershipCallback(app::CommandHandler * comman
435
448
436
449
emberAfScenesClusterPrintln (" RX: GetSceneMembership 0x%2x" , groupId);
437
450
438
- if (!isEndpointInGroup (emberAfCurrentEndpoint (), groupId))
451
+ if (!isEndpointInGroup (fabricIndex, emberAfCurrentEndpoint (), groupId))
439
452
{
440
453
status = EMBER_ZCL_STATUS_INVALID_FIELD;
441
454
}
@@ -485,12 +498,13 @@ bool emberAfScenesClusterGetSceneMembershipCallback(app::CommandHandler * comman
485
498
return true ;
486
499
}
487
500
488
- EmberAfStatus emberAfScenesClusterStoreCurrentSceneCallback (EndpointId endpoint, GroupId groupId, uint8_t sceneId)
501
+ EmberAfStatus emberAfScenesClusterStoreCurrentSceneCallback (chip::FabricIndex fabricIndex, EndpointId endpoint, GroupId groupId,
502
+ uint8_t sceneId)
489
503
{
490
504
EmberAfSceneTableEntry entry;
491
505
uint8_t i, index = EMBER_AF_SCENE_TABLE_NULL_INDEX;
492
506
493
- if (!isEndpointInGroup (endpoint, groupId))
507
+ if (!isEndpointInGroup (fabricIndex, endpoint, groupId))
494
508
{
495
509
return EMBER_ZCL_STATUS_INVALID_FIELD;
496
510
}
@@ -610,9 +624,10 @@ EmberAfStatus emberAfScenesClusterStoreCurrentSceneCallback(EndpointId endpoint,
610
624
return EMBER_ZCL_STATUS_SUCCESS;
611
625
}
612
626
613
- EmberAfStatus emberAfScenesClusterRecallSavedSceneCallback (EndpointId endpoint, GroupId groupId, uint8_t sceneId)
627
+ EmberAfStatus emberAfScenesClusterRecallSavedSceneCallback (chip::FabricIndex fabricIndex, EndpointId endpoint, GroupId groupId,
628
+ uint8_t sceneId)
614
629
{
615
- if (!isEndpointInGroup (endpoint, groupId))
630
+ if (!isEndpointInGroup (fabricIndex, endpoint, groupId))
616
631
{
617
632
return EMBER_ZCL_STATUS_INVALID_FIELD;
618
633
}
@@ -755,6 +770,7 @@ bool emberAfPluginScenesServerParseAddScene(
755
770
EmberAfSceneTableEntry entry;
756
771
EmberAfStatus status;
757
772
bool enhanced = (cmd->commandId == ZCL_ENHANCED_ADD_SCENE_COMMAND_ID);
773
+ auto fabricIndex = GetFabricIndex (commandObj);
758
774
EndpointId endpoint = cmd->apsFrame ->destinationEndpoint ;
759
775
uint8_t i, index = EMBER_AF_SCENE_TABLE_NULL_INDEX;
760
776
@@ -764,7 +780,7 @@ bool emberAfPluginScenesServerParseAddScene(
764
780
auto fieldSetIter = extensionFieldSets.begin ();
765
781
766
782
// Add Scene commands can only reference groups to which we belong.
767
- if (!isEndpointInGroup (endpoint, groupId))
783
+ if (!isEndpointInGroup (fabricIndex, endpoint, groupId))
768
784
{
769
785
status = EMBER_ZCL_STATUS_INVALID_FIELD;
770
786
goto kickout;
@@ -1092,12 +1108,13 @@ bool emberAfPluginScenesServerParseViewScene(app::CommandHandler * commandObj, c
1092
1108
EmberAfSceneTableEntry entry = {};
1093
1109
EmberAfStatus status = EMBER_ZCL_STATUS_NOT_FOUND;
1094
1110
bool enhanced = (cmd->commandId == ZCL_ENHANCED_VIEW_SCENE_COMMAND_ID);
1111
+ FabricIndex fabricIndex = GetFabricIndex (commandObj);
1095
1112
EndpointId endpoint = cmd->apsFrame ->destinationEndpoint ;
1096
1113
1097
1114
emberAfScenesClusterPrintln (" RX: %pViewScene 0x%2x, 0x%x" , (enhanced ? " Enhanced" : " " ), groupId, sceneId);
1098
1115
1099
1116
// View Scene commands can only reference groups which we belong to.
1100
- if (!isEndpointInGroup (endpoint, groupId))
1117
+ if (!isEndpointInGroup (fabricIndex, endpoint, groupId))
1101
1118
{
1102
1119
status = EMBER_ZCL_STATUS_INVALID_FIELD;
1103
1120
}
0 commit comments