@@ -144,7 +144,6 @@ void DeviceManager::OpenRemoteDeviceCommissioningWindow(EndpointId remoteEndpoin
144
144
commandBuilder.Add (" pairing open-commissioning-window " );
145
145
commandBuilder.AddFormat (" %lu %d %d %d %d %d" , mRemoteBridgeNodeId , remoteEndpointId, kEnhancedCommissioningMethod ,
146
146
kWindowTimeout , kIteration , discriminator);
147
- commandBuilder.Add (" --setup-pin 20202021" );
148
147
149
148
PushCommand (commandBuilder.c_str ());
150
149
}
@@ -215,8 +214,8 @@ void DeviceManager::SubscribeRemoteFabricBridge()
215
214
216
215
// Prepare and push the commissioner control subscribe command
217
216
commandBuilder.Add (" commissionercontrol subscribe-event commissioning-request-result " );
218
- commandBuilder.AddFormat (" %d %d %lu %d --is-urgent true" , kSubscribeMinInterval , kSubscribeMaxInterval , mRemoteBridgeNodeId ,
219
- kRootEndpointId );
217
+ commandBuilder.AddFormat (" %d %d %lu %d --is-urgent true --keepSubscriptions true " , kSubscribeMinInterval , kSubscribeMaxInterval ,
218
+ mRemoteBridgeNodeId , kRootEndpointId );
220
219
PushCommand (commandBuilder.c_str ());
221
220
}
222
221
@@ -238,6 +237,25 @@ void DeviceManager::ReadSupportedDeviceCategories()
238
237
PushCommand (commandBuilder.c_str ());
239
238
}
240
239
240
+ void DeviceManager::HandleReadSupportedDeviceCategories (chip::TLV::TLVReader & data)
241
+ {
242
+ ChipLogProgress (NotSpecified, " Attribute SupportedDeviceCategories detected." );
243
+
244
+ BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> value;
245
+ CHIP_ERROR error = app::DataModel::Decode (data, value);
246
+ if (error != CHIP_NO_ERROR)
247
+ {
248
+ ChipLogError (NotSpecified, " Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
249
+ return ;
250
+ }
251
+
252
+ if (value.Has (CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization ))
253
+ {
254
+ ChipLogProgress (NotSpecified, " Remote Fabric-Bridge supports Fabric Synchronization, start reverse commissioning." );
255
+ RequestCommissioningApproval ();
256
+ }
257
+ }
258
+
241
259
void DeviceManager::RequestCommissioningApproval ()
242
260
{
243
261
ChipLogProgress (NotSpecified, " Starting reverse commissioning for bridge device: NodeId: " ChipLogFormatX64,
@@ -255,12 +273,12 @@ void DeviceManager::RequestCommissioningApproval()
255
273
PushCommand (commandBuilder.c_str ());
256
274
}
257
275
258
- void DeviceManager::HandleCommissioningRequestResult (TLV::TLVReader * data)
276
+ void DeviceManager::HandleCommissioningRequestResult (TLV::TLVReader & data)
259
277
{
260
278
ChipLogProgress (NotSpecified, " CommissioningRequestResult event received." );
261
279
262
280
CommissionerControl::Events::CommissioningRequestResult::DecodableType value;
263
- CHIP_ERROR error = app::DataModel::Decode (* data, value);
281
+ CHIP_ERROR error = app::DataModel::Decode (data, value);
264
282
if (error != CHIP_NO_ERROR)
265
283
{
266
284
ChipLogError (NotSpecified, " Failed to decode event value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
@@ -284,82 +302,12 @@ void DeviceManager::HandleCommissioningRequestResult(TLV::TLVReader * data)
284
302
SendCommissionNodeRequest (value.requestId , kResponseTimeoutSeconds );
285
303
}
286
304
287
- void DeviceManager::SendCommissionNodeRequest (uint64_t requestId, uint16_t responseTimeoutSeconds)
288
- {
289
- ChipLogProgress (NotSpecified, " Request the Commissioner Control Server to begin commissioning a previously approved request." );
290
-
291
- StringBuilder<kMaxCommandSize > commandBuilder;
292
- commandBuilder.Add (" commissionercontrol commission-node " );
293
- commandBuilder.AddFormat (" %lu %u %lu %d" , requestId, responseTimeoutSeconds, mRemoteBridgeNodeId , kRootEndpointId );
294
-
295
- PushCommand (commandBuilder.c_str ());
296
- }
297
-
298
- void DeviceManager::HandleReverseOpenCommissioningWindow (TLV::TLVReader * data)
305
+ void DeviceManager::HandleAttributePartsListUpdate (chip::TLV::TLVReader & data)
299
306
{
300
- CommissionerControl::Commands::ReverseOpenCommissioningWindow::DecodableType value;
301
- CHIP_ERROR error = app::DataModel::Decode (*data, value);
302
- if (error != CHIP_NO_ERROR)
303
- {
304
- ChipLogError (NotSpecified, " Failed to decode command response value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
305
- return ;
306
- }
307
-
308
- // Log all fields
309
- ChipLogProgress (NotSpecified, " DecodableType fields:" );
310
- ChipLogProgress (NotSpecified, " commissioningTimeout: %u" , value.commissioningTimeout );
311
- ChipLogProgress (NotSpecified, " discriminator: %u" , value.discriminator );
312
- ChipLogProgress (NotSpecified, " iterations: %u" , value.iterations );
313
-
314
- char verifierHex[Crypto::kSpake2p_VerifierSerialized_Length * 2 + 1 ];
315
- Encoding::BytesToHex (value.PAKEPasscodeVerifier .data (), value.PAKEPasscodeVerifier .size (), verifierHex, sizeof (verifierHex),
316
- Encoding::HexFlags::kNullTerminate );
317
- ChipLogProgress (NotSpecified, " PAKEPasscodeVerifier: %s" , verifierHex);
318
-
319
- char saltHex[Crypto::kSpake2p_Max_PBKDF_Salt_Length * 2 + 1 ];
320
- Encoding::BytesToHex (value.salt .data (), value.salt .size (), saltHex, sizeof (saltHex), Encoding::HexFlags::kNullTerminate );
321
- ChipLogProgress (NotSpecified, " salt: %s" , saltHex);
322
-
323
- OpenDeviceCommissioningWindow (mLocalBridgeNodeId , value.commissioningTimeout , value.iterations , value.discriminator , saltHex,
324
- verifierHex);
325
- }
326
-
327
- void DeviceManager::HandleAttributeData (const app::ConcreteDataAttributePath & path, TLV::TLVReader * data)
328
- {
329
- if (path.mClusterId == CommissionerControl::Id &&
330
- path.mAttributeId == CommissionerControl::Attributes::SupportedDeviceCategories::Id)
331
- {
332
- ChipLogProgress (NotSpecified, " Attribute SupportedDeviceCategories detected." );
333
-
334
- BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> value;
335
- CHIP_ERROR error = app::DataModel::Decode (*data, value);
336
- if (error != CHIP_NO_ERROR)
337
- {
338
- ChipLogError (NotSpecified, " Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
339
- return ;
340
- }
341
-
342
- if (value.Has (CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization ))
343
- {
344
- ChipLogProgress (NotSpecified, " Remote Fabric-Bridge supports Fabric Synchronization, start reverse commissioning." );
345
- RequestCommissioningApproval ();
346
- }
347
-
348
- return ;
349
- }
350
-
351
- if (path.mClusterId != Descriptor::Id || path.mAttributeId != Descriptor::Attributes::PartsList::Id)
352
- {
353
- return ;
354
- }
355
-
356
- ChipLogProgress (NotSpecified, " Attribute change detected:" );
357
- ChipLogProgress (
358
- NotSpecified, " Endpoint: %u, Cluster: " ChipLogFormatMEI " , Attribute: " ChipLogFormatMEI " , DataVersion: %" PRIu32,
359
- path.mEndpointId , ChipLogValueMEI (path.mClusterId ), ChipLogValueMEI (path.mAttributeId ), path.mDataVersion .ValueOr (0 ));
307
+ ChipLogProgress (NotSpecified, " Attribute PartsList change detected:" );
360
308
361
309
app::DataModel::DecodableList<EndpointId> value;
362
- CHIP_ERROR error = app::DataModel::Decode (* data, value);
310
+ CHIP_ERROR error = app::DataModel::Decode (data, value);
363
311
if (error != CHIP_NO_ERROR)
364
312
{
365
313
ChipLogError (NotSpecified, " Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
@@ -413,7 +361,7 @@ void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & p
413
361
for (const auto & endpoint : addedEndpoints)
414
362
{
415
363
// print to console
416
- fprintf (stderr, " A new devie is added on Endpoint: %u\n " , endpoint);
364
+ fprintf (stderr, " A new device is added on Endpoint: %u\n " , endpoint);
417
365
418
366
if (mAutoSyncEnabled )
419
367
{
@@ -457,7 +405,63 @@ void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & p
457
405
}
458
406
}
459
407
460
- void DeviceManager::HandleEventData (const app::EventHeader & header, TLV::TLVReader * data)
408
+ void DeviceManager::SendCommissionNodeRequest (uint64_t requestId, uint16_t responseTimeoutSeconds)
409
+ {
410
+ ChipLogProgress (NotSpecified, " Request the Commissioner Control Server to begin commissioning a previously approved request." );
411
+
412
+ StringBuilder<kMaxCommandSize > commandBuilder;
413
+ commandBuilder.Add (" commissionercontrol commission-node " );
414
+ commandBuilder.AddFormat (" %lu %u %lu %d" , requestId, responseTimeoutSeconds, mRemoteBridgeNodeId , kRootEndpointId );
415
+
416
+ PushCommand (commandBuilder.c_str ());
417
+ }
418
+
419
+ void DeviceManager::HandleReverseOpenCommissioningWindow (TLV::TLVReader & data)
420
+ {
421
+ CommissionerControl::Commands::ReverseOpenCommissioningWindow::DecodableType value;
422
+ CHIP_ERROR error = app::DataModel::Decode (data, value);
423
+ if (error != CHIP_NO_ERROR)
424
+ {
425
+ ChipLogError (NotSpecified, " Failed to decode command response value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
426
+ return ;
427
+ }
428
+
429
+ // Log all fields
430
+ ChipLogProgress (NotSpecified, " DecodableType fields:" );
431
+ ChipLogProgress (NotSpecified, " commissioningTimeout: %u" , value.commissioningTimeout );
432
+ ChipLogProgress (NotSpecified, " discriminator: %u" , value.discriminator );
433
+ ChipLogProgress (NotSpecified, " iterations: %u" , value.iterations );
434
+
435
+ char verifierHex[Crypto::kSpake2p_VerifierSerialized_Length * 2 + 1 ];
436
+ Encoding::BytesToHex (value.PAKEPasscodeVerifier .data (), value.PAKEPasscodeVerifier .size (), verifierHex, sizeof (verifierHex),
437
+ Encoding::HexFlags::kNullTerminate );
438
+ ChipLogProgress (NotSpecified, " PAKEPasscodeVerifier: %s" , verifierHex);
439
+
440
+ char saltHex[Crypto::kSpake2p_Max_PBKDF_Salt_Length * 2 + 1 ];
441
+ Encoding::BytesToHex (value.salt .data (), value.salt .size (), saltHex, sizeof (saltHex), Encoding::HexFlags::kNullTerminate );
442
+ ChipLogProgress (NotSpecified, " salt: %s" , saltHex);
443
+
444
+ OpenDeviceCommissioningWindow (mLocalBridgeNodeId , value.commissioningTimeout , value.iterations , value.discriminator , saltHex,
445
+ verifierHex);
446
+ }
447
+
448
+ void DeviceManager::HandleAttributeData (const app::ConcreteDataAttributePath & path, TLV::TLVReader & data)
449
+ {
450
+ if (path.mClusterId == CommissionerControl::Id &&
451
+ path.mAttributeId == CommissionerControl::Attributes::SupportedDeviceCategories::Id)
452
+ {
453
+ HandleReadSupportedDeviceCategories (data);
454
+ return ;
455
+ }
456
+
457
+ if (path.mClusterId == Descriptor::Id && path.mAttributeId == Descriptor::Attributes::PartsList::Id)
458
+ {
459
+ HandleAttributePartsListUpdate (data);
460
+ return ;
461
+ }
462
+ }
463
+
464
+ void DeviceManager::HandleEventData (const app::EventHeader & header, TLV::TLVReader & data)
461
465
{
462
466
if (header.mPath .mClusterId == CommissionerControl::Id &&
463
467
header.mPath .mEventId == CommissionerControl::Events::CommissioningRequestResult::Id)
@@ -466,7 +470,7 @@ void DeviceManager::HandleEventData(const app::EventHeader & header, TLV::TLVRea
466
470
}
467
471
}
468
472
469
- void DeviceManager::HandleCommandResponse (const app::ConcreteCommandPath & path, TLV::TLVReader * data)
473
+ void DeviceManager::HandleCommandResponse (const app::ConcreteCommandPath & path, TLV::TLVReader & data)
470
474
{
471
475
ChipLogProgress (NotSpecified, " Command Response received." );
472
476
0 commit comments