27
27
#include < app/CommandHandler.h>
28
28
#include < app/ConcreteAttributePath.h>
29
29
#include < app/ConcreteCommandPath.h>
30
+ #include < app/server/Server.h>
30
31
#include < lib/core/CHIPEncoding.h>
31
32
#include < platform/internal/CHIPDeviceLayerInternal.h>
32
33
@@ -112,7 +113,7 @@ void TimerExpiredCallback(System::Layer * systemLayer, void * callbackContext)
112
113
{
113
114
EndpointId endpoint = static_cast <EndpointId>(reinterpret_cast <uintptr_t >(callbackContext));
114
115
115
- Delegate * delegate = GetDelegate (endpoint);
116
+ auto delegate = GetDelegate (endpoint);
116
117
VerifyOrReturn (delegate != nullptr , ChipLogError (Zcl, " Delegate is null. Unable to handle timer expired" ));
117
118
118
119
delegate->ClearPendingPresetList ();
@@ -731,7 +732,7 @@ CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
731
732
}
732
733
break ;
733
734
case PresetTypes::Id: {
734
- Delegate * delegate = GetDelegate (aPath.mEndpointId );
735
+ auto delegate = GetDelegate (aPath.mEndpointId );
735
736
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
736
737
737
738
return aEncoder.EncodeList ([delegate](const auto & encoder) -> CHIP_ERROR {
@@ -750,14 +751,14 @@ CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
750
751
}
751
752
break ;
752
753
case NumberOfPresets::Id: {
753
- Delegate * delegate = GetDelegate (aPath.mEndpointId );
754
+ auto delegate = GetDelegate (aPath.mEndpointId );
754
755
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
755
756
756
757
ReturnErrorOnFailure (aEncoder.Encode (delegate->GetNumberOfPresets ()));
757
758
}
758
759
break ;
759
760
case Presets::Id: {
760
- Delegate * delegate = GetDelegate (aPath.mEndpointId );
761
+ auto delegate = GetDelegate (aPath.mEndpointId );
761
762
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
762
763
763
764
auto & subjectDescriptor = aEncoder.GetSubjectDescriptor ();
@@ -793,7 +794,7 @@ CHIP_ERROR ThermostatAttrAccess::Read(const ConcreteReadAttributePath & aPath, A
793
794
}
794
795
break ;
795
796
case ActivePresetHandle::Id: {
796
- Delegate * delegate = GetDelegate (aPath.mEndpointId );
797
+ auto delegate = GetDelegate (aPath.mEndpointId );
797
798
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
798
799
799
800
uint8_t buffer[kPresetHandleSize ];
@@ -839,7 +840,7 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath,
839
840
{
840
841
case Presets::Id: {
841
842
842
- Delegate * delegate = GetDelegate (endpoint);
843
+ auto delegate = GetDelegate (endpoint);
843
844
VerifyOrReturnError (delegate != nullptr , CHIP_ERROR_INCORRECT_STATE, ChipLogError (Zcl, " Delegate is null" ));
844
845
845
846
// Presets are not editable, return INVALID_IN_STATE.
@@ -924,7 +925,7 @@ CHIP_ERROR ThermostatAttrAccess::Write(const ConcreteDataAttributePath & aPath,
924
925
return CHIP_NO_ERROR;
925
926
}
926
927
927
- CHIP_ERROR ThermostatAttrAccess::AppendPendingPreset (Delegate * delegate, const PresetStruct::Type & preset)
928
+ CHIP_ERROR ThermostatAttrAccess::AppendPendingPreset (Thermostat:: Delegate * delegate, const PresetStruct::Type & preset)
928
929
{
929
930
if (!IsValidPresetEntry (preset))
930
931
{
@@ -978,6 +979,19 @@ CHIP_ERROR ThermostatAttrAccess::AppendPendingPreset(Delegate * delegate, const
978
979
return delegate->AppendToPendingPresetList (preset);
979
980
}
980
981
982
+ void ThermostatAttrAccess::OnFabricRemoved (const FabricTable & fabricTable, FabricIndex fabricIndex)
983
+ {
984
+ for (size_t i = 0 ; i < ArraySize (mAtomicWriteNodeIds ); ++i)
985
+ {
986
+ auto nodeId = mAtomicWriteNodeIds [i];
987
+ if (nodeId.GetFabricIndex () == fabricIndex)
988
+ {
989
+ mAtomicWriteNodeIds [i] = ScopedNodeId ();
990
+ mAtomicWriteState [i] = false ;
991
+ }
992
+ }
993
+ }
994
+
981
995
} // namespace Thermostat
982
996
} // namespace Clusters
983
997
} // namespace app
@@ -1309,7 +1323,7 @@ bool emberAfThermostatClusterSetActivePresetRequestCallback(
1309
1323
const Clusters::Thermostat::Commands::SetActivePresetRequest::DecodableType & commandData)
1310
1324
{
1311
1325
EndpointId endpoint = commandPath.mEndpointId ;
1312
- Delegate * delegate = GetDelegate (endpoint);
1326
+ auto delegate = GetDelegate (endpoint);
1313
1327
1314
1328
if (delegate == nullptr )
1315
1329
{
@@ -1399,7 +1413,7 @@ void handleAtomicBegin(CommandHandler * commandObj, const ConcreteCommandPath &
1399
1413
{
1400
1414
EndpointId endpoint = commandPath.mEndpointId ;
1401
1415
1402
- Delegate * delegate = GetDelegate (endpoint);
1416
+ auto delegate = GetDelegate (endpoint);
1403
1417
1404
1418
if (delegate == nullptr )
1405
1419
{
@@ -1585,7 +1599,7 @@ void handleAtomicCommit(CommandHandler * commandObj, const ConcreteCommandPath &
1585
1599
return ;
1586
1600
}
1587
1601
1588
- Delegate * delegate = GetDelegate (endpoint);
1602
+ auto delegate = GetDelegate (endpoint);
1589
1603
1590
1604
if (delegate == nullptr )
1591
1605
{
@@ -1618,7 +1632,7 @@ void handleAtomicRollback(CommandHandler * commandObj, const ConcreteCommandPath
1618
1632
return ;
1619
1633
}
1620
1634
1621
- Delegate * delegate = GetDelegate (endpoint);
1635
+ auto delegate = GetDelegate (endpoint);
1622
1636
1623
1637
if (delegate == nullptr )
1624
1638
{
@@ -1895,5 +1909,6 @@ bool emberAfThermostatClusterSetpointRaiseLowerCallback(app::CommandHandler * co
1895
1909
1896
1910
void MatterThermostatPluginServerInitCallback ()
1897
1911
{
1912
+ Server::GetInstance ().GetFabricTable ().AddFabricDelegate (&gThermostatAttrAccess );
1898
1913
registerAttributeAccessOverride (&gThermostatAttrAccess );
1899
1914
}
0 commit comments