19
19
#include " DeviceSynchronization.h"
20
20
21
21
#include " DeviceSubscriptionManager.h"
22
+
23
+ #if defined(PW_RPC_ENABLED)
22
24
#include " rpc/RpcClient.h"
25
+ #endif
23
26
24
27
#include < app/InteractionModelEngine.h>
25
28
#include < app/server/Server.h>
@@ -44,6 +47,7 @@ void OnDeviceConnectionFailureWrapper(void * context, const ScopedNodeId & peerI
44
47
reinterpret_cast <DeviceSynchronizer *>(context)->OnDeviceConnectionFailure (peerId, error);
45
48
}
46
49
50
+ #if defined(PW_RPC_ENABLED)
47
51
bool SuccessOrLog (CHIP_ERROR err, const char * name)
48
52
{
49
53
if (err == CHIP_NO_ERROR)
@@ -55,6 +59,7 @@ bool SuccessOrLog(CHIP_ERROR err, const char * name)
55
59
56
60
return false ;
57
61
}
62
+ #endif
58
63
59
64
} // namespace
60
65
@@ -82,6 +87,7 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path,
82
87
83
88
switch (path.mAttributeId )
84
89
{
90
+ #if defined(PW_RPC_ENABLED)
85
91
case Clusters::BasicInformation::Attributes::UniqueID ::Id:
86
92
mCurrentDeviceData .has_unique_id =
87
93
SuccessOrLog (data->GetString (mCurrentDeviceData .unique_id , sizeof (mCurrentDeviceData .unique_id )), " UniqueId" );
@@ -120,6 +126,7 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path,
120
126
data->GetString (mCurrentDeviceData .software_version_string , sizeof (mCurrentDeviceData .software_version_string )),
121
127
" SoftwareVersionString" );
122
128
break ;
129
+ #endif // #if defined(PW_RPC_ENABLED)
123
130
default :
124
131
break ;
125
132
}
@@ -134,7 +141,7 @@ void DeviceSynchronizer::OnReportEnd()
134
141
void DeviceSynchronizer::OnDone (chip::app::ReadClient * apReadClient)
135
142
{
136
143
#if defined(PW_RPC_ENABLED)
137
- if (mState == State::ReceivedResponse && !DeviceMgr ().IsCurrentBridgeDevice (mCurrentDeviceData . node_id ))
144
+ if (mState == State::ReceivedResponse && !DeviceMgr ().IsCurrentBridgeDevice (mNodeId ))
138
145
{
139
146
GetUniqueId ();
140
147
if (mState == State::GettingUid)
@@ -197,10 +204,14 @@ void DeviceSynchronizer::StartDeviceSynchronization(chip::Controller::DeviceCont
197
204
return ;
198
205
}
199
206
207
+ mNodeId = nodeId;
208
+
209
+ #if defined(PW_RPC_ENABLED)
200
210
mCurrentDeviceData = chip_rpc_SynchronizedDevice_init_default;
201
211
mCurrentDeviceData .node_id = nodeId;
202
212
mCurrentDeviceData .has_is_icd = true ;
203
213
mCurrentDeviceData .is_icd = deviceIsIcd;
214
+ #endif
204
215
205
216
ReturnOnFailure (controller->GetConnectedDevice (nodeId, &mOnDeviceConnectedCallback , &mOnDeviceConnectionFailureCallback ));
206
217
mController = controller;
@@ -212,10 +223,12 @@ void DeviceSynchronizer::GetUniqueId()
212
223
VerifyOrDie (mState == State::ReceivedResponse);
213
224
VerifyOrDie (mController );
214
225
226
+ #if defined(PW_RPC_ENABLED)
215
227
// If we have a UniqueId we can return leaving state in ReceivedResponse.
216
228
VerifyOrReturn (!mCurrentDeviceData .has_unique_id , ChipLogDetail (NotSpecified, " We already have UniqueId" ));
229
+ #endif
217
230
218
- auto * device = DeviceMgr ().FindDeviceByNode (mCurrentDeviceData . node_id );
231
+ auto * device = DeviceMgr ().FindDeviceByNode (mNodeId );
219
232
// If there is no associated remote Fabric Sync Aggregator there is no other place for us to try
220
233
// getting the UniqueId from and can return leaving the state in ReceivedResponse.
221
234
VerifyOrReturn (device, ChipLogDetail (NotSpecified, " No remote Fabric Sync Aggregator to get UniqueId from" ));
@@ -231,8 +244,10 @@ void DeviceSynchronizer::GetUniqueId()
231
244
[this ](std::optional<CharSpan> aUniqueId) {
232
245
if (aUniqueId.has_value ())
233
246
{
247
+ #if defined(PW_RPC_ENABLED)
234
248
this ->mCurrentDeviceData .has_unique_id = true ;
235
249
memcpy (this ->mCurrentDeviceData .unique_id , aUniqueId.value ().data (), aUniqueId.value ().size ());
250
+ #endif
236
251
}
237
252
else
238
253
{
@@ -255,19 +270,22 @@ void DeviceSynchronizer::GetUniqueId()
255
270
void DeviceSynchronizer::SynchronizationCompleteAddDevice ()
256
271
{
257
272
VerifyOrDie (mState == State::ReceivedResponse || mState == State::GettingUid);
273
+
274
+ #if defined(PW_RPC_ENABLED)
258
275
AddSynchronizedDevice (mCurrentDeviceData );
259
276
// TODO(#35077) Figure out how we should reflect CADMIN values of ICD.
260
277
if (!mCurrentDeviceData .is_icd )
261
278
{
262
279
VerifyOrDie (mController );
263
280
// TODO(#35333) Figure out how we should recover in this circumstance.
264
- CHIP_ERROR err = DeviceSubscriptionManager::Instance ().StartSubscription (*mController , mCurrentDeviceData . node_id );
281
+ CHIP_ERROR err = DeviceSubscriptionManager::Instance ().StartSubscription (*mController , mNodeId );
265
282
if (err != CHIP_NO_ERROR)
266
283
{
267
- ChipLogError (NotSpecified, " Failed start subscription to NodeId:" ChipLogFormatX64,
268
- ChipLogValueX64 (mCurrentDeviceData .node_id ));
284
+ ChipLogError (NotSpecified, " Failed start subscription to NodeId:" ChipLogFormatX64, ChipLogValueX64 (mNodeId ));
269
285
}
270
286
}
287
+ #endif
288
+
271
289
MoveToState (State::Idle);
272
290
}
273
291
0 commit comments