File tree 7 files changed +638
-509
lines changed
all-clusters-app/telink/src
all-clusters-minimal-app/telink/src
contact-sensor-app/telink/src
light-switch-app/telink/src
ota-requestor-app/telink/src
7 files changed +638
-509
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,17 @@ using namespace ::chip::DeviceLayer::Internal;
110
110
111
111
AppTask AppTask::sAppTask ;
112
112
113
+ class AppFabricTableDelegate : public FabricTable ::Delegate
114
+ {
115
+ void OnFabricRemoved (const FabricTable & fabricTable, FabricIndex fabricIndex)
116
+ {
117
+ if (chip::Server::GetInstance ().GetFabricTable ().FabricCount () == 0 )
118
+ {
119
+ chip::Server::GetInstance ().ScheduleFactoryReset ();
120
+ }
121
+ }
122
+ };
123
+
113
124
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE ;
114
125
115
126
CHIP_ERROR AppTask::Init ()
@@ -176,6 +187,13 @@ CHIP_ERROR AppTask::Init()
176
187
return ret;
177
188
}
178
189
190
+ ret = chip::Server::GetInstance ().GetFabricTable ().AddFabricDelegate (new AppFabricTableDelegate);
191
+ if (ret != CHIP_NO_ERROR)
192
+ {
193
+ LOG_ERR (" AppFabricTableDelegate fail" );
194
+ return ret;
195
+ }
196
+
179
197
return CHIP_NO_ERROR;
180
198
}
181
199
Original file line number Diff line number Diff line change @@ -73,6 +73,17 @@ using namespace ::chip::DeviceLayer::Internal;
73
73
74
74
AppTask AppTask::sAppTask ;
75
75
76
+ class AppFabricTableDelegate : public FabricTable ::Delegate
77
+ {
78
+ void OnFabricRemoved (const FabricTable & fabricTable, FabricIndex fabricIndex)
79
+ {
80
+ if (chip::Server::GetInstance ().GetFabricTable ().FabricCount () == 0 )
81
+ {
82
+ chip::Server::GetInstance ().ScheduleFactoryReset ();
83
+ }
84
+ }
85
+ };
86
+
76
87
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE ;
77
88
78
89
CHIP_ERROR AppTask::Init ()
@@ -136,6 +147,13 @@ CHIP_ERROR AppTask::Init()
136
147
return ret;
137
148
}
138
149
150
+ ret = chip::Server::GetInstance ().GetFabricTable ().AddFabricDelegate (new AppFabricTableDelegate);
151
+ if (ret != CHIP_NO_ERROR)
152
+ {
153
+ LOG_ERR (" AppFabricTableDelegate fail" );
154
+ return ret;
155
+ }
156
+
139
157
return CHIP_NO_ERROR;
140
158
}
141
159
You can’t perform that action at this time.
0 commit comments