@@ -237,6 +237,25 @@ void DeviceManager::ReadSupportedDeviceCategories()
237
237
PushCommand (commandBuilder.c_str ());
238
238
}
239
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
+
240
259
void DeviceManager::RequestCommissioningApproval ()
241
260
{
242
261
ChipLogProgress (NotSpecified, " Starting reverse commissioning for bridge device: NodeId: " ChipLogFormatX64,
@@ -254,12 +273,12 @@ void DeviceManager::RequestCommissioningApproval()
254
273
PushCommand (commandBuilder.c_str ());
255
274
}
256
275
257
- void DeviceManager::HandleCommissioningRequestResult (TLV::TLVReader * data)
276
+ void DeviceManager::HandleCommissioningRequestResult (TLV::TLVReader & data)
258
277
{
259
278
ChipLogProgress (NotSpecified, " CommissioningRequestResult event received." );
260
279
261
280
CommissionerControl::Events::CommissioningRequestResult::DecodableType value;
262
- CHIP_ERROR error = app::DataModel::Decode (* data, value);
281
+ CHIP_ERROR error = app::DataModel::Decode (data, value);
263
282
if (error != CHIP_NO_ERROR)
264
283
{
265
284
ChipLogError (NotSpecified, " Failed to decode event value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
@@ -283,82 +302,12 @@ void DeviceManager::HandleCommissioningRequestResult(TLV::TLVReader * data)
283
302
SendCommissionNodeRequest (value.requestId , kResponseTimeoutSeconds );
284
303
}
285
304
286
- void DeviceManager::SendCommissionNodeRequest (uint64_t requestId, uint16_t responseTimeoutSeconds)
287
- {
288
- ChipLogProgress (NotSpecified, " Request the Commissioner Control Server to begin commissioning a previously approved request." );
289
-
290
- StringBuilder<kMaxCommandSize > commandBuilder;
291
- commandBuilder.Add (" commissionercontrol commission-node " );
292
- commandBuilder.AddFormat (" %lu %u %lu %d" , requestId, responseTimeoutSeconds, mRemoteBridgeNodeId , kRootEndpointId );
293
-
294
- PushCommand (commandBuilder.c_str ());
295
- }
296
-
297
- void DeviceManager::HandleReverseOpenCommissioningWindow (TLV::TLVReader * data)
305
+ void DeviceManager::HandleAttributePartsListUpdate (chip::TLV::TLVReader & data)
298
306
{
299
- CommissionerControl::Commands::ReverseOpenCommissioningWindow::DecodableType value;
300
- CHIP_ERROR error = app::DataModel::Decode (*data, value);
301
- if (error != CHIP_NO_ERROR)
302
- {
303
- ChipLogError (NotSpecified, " Failed to decode command response value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
304
- return ;
305
- }
306
-
307
- // Log all fields
308
- ChipLogProgress (NotSpecified, " DecodableType fields:" );
309
- ChipLogProgress (NotSpecified, " commissioningTimeout: %u" , value.commissioningTimeout );
310
- ChipLogProgress (NotSpecified, " discriminator: %u" , value.discriminator );
311
- ChipLogProgress (NotSpecified, " iterations: %u" , value.iterations );
312
-
313
- char verifierHex[Crypto::kSpake2p_VerifierSerialized_Length * 2 + 1 ];
314
- Encoding::BytesToHex (value.PAKEPasscodeVerifier .data (), value.PAKEPasscodeVerifier .size (), verifierHex, sizeof (verifierHex),
315
- Encoding::HexFlags::kNullTerminate );
316
- ChipLogProgress (NotSpecified, " PAKEPasscodeVerifier: %s" , verifierHex);
317
-
318
- char saltHex[Crypto::kSpake2p_Max_PBKDF_Salt_Length * 2 + 1 ];
319
- Encoding::BytesToHex (value.salt .data (), value.salt .size (), saltHex, sizeof (saltHex), Encoding::HexFlags::kNullTerminate );
320
- ChipLogProgress (NotSpecified, " salt: %s" , saltHex);
321
-
322
- OpenDeviceCommissioningWindow (mLocalBridgeNodeId , value.commissioningTimeout , value.iterations , value.discriminator , saltHex,
323
- verifierHex);
324
- }
325
-
326
- void DeviceManager::HandleAttributeData (const app::ConcreteDataAttributePath & path, TLV::TLVReader * data)
327
- {
328
- if (path.mClusterId == CommissionerControl::Id &&
329
- path.mAttributeId == CommissionerControl::Attributes::SupportedDeviceCategories::Id)
330
- {
331
- ChipLogProgress (NotSpecified, " Attribute SupportedDeviceCategories detected." );
332
-
333
- BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> value;
334
- CHIP_ERROR error = app::DataModel::Decode (*data, value);
335
- if (error != CHIP_NO_ERROR)
336
- {
337
- ChipLogError (NotSpecified, " Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
338
- return ;
339
- }
340
-
341
- if (value.Has (CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization ))
342
- {
343
- ChipLogProgress (NotSpecified, " Remote Fabric-Bridge supports Fabric Synchronization, start reverse commissioning." );
344
- RequestCommissioningApproval ();
345
- }
346
-
347
- return ;
348
- }
349
-
350
- if (path.mClusterId != Descriptor::Id || path.mAttributeId != Descriptor::Attributes::PartsList::Id)
351
- {
352
- return ;
353
- }
354
-
355
- ChipLogProgress (NotSpecified, " Attribute change detected:" );
356
- ChipLogProgress (
357
- NotSpecified, " Endpoint: %u, Cluster: " ChipLogFormatMEI " , Attribute: " ChipLogFormatMEI " , DataVersion: %" PRIu32,
358
- path.mEndpointId , ChipLogValueMEI (path.mClusterId ), ChipLogValueMEI (path.mAttributeId ), path.mDataVersion .ValueOr (0 ));
307
+ ChipLogProgress (NotSpecified, " Attribute PartsList change detected:" );
359
308
360
309
app::DataModel::DecodableList<EndpointId> value;
361
- CHIP_ERROR error = app::DataModel::Decode (* data, value);
310
+ CHIP_ERROR error = app::DataModel::Decode (data, value);
362
311
if (error != CHIP_NO_ERROR)
363
312
{
364
313
ChipLogError (NotSpecified, " Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format ());
@@ -456,7 +405,63 @@ void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & p
456
405
}
457
406
}
458
407
459
- 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)
460
465
{
461
466
if (header.mPath .mClusterId == CommissionerControl::Id &&
462
467
header.mPath .mEventId == CommissionerControl::Events::CommissioningRequestResult::Id)
@@ -465,7 +470,7 @@ void DeviceManager::HandleEventData(const app::EventHeader & header, TLV::TLVRea
465
470
}
466
471
}
467
472
468
- void DeviceManager::HandleCommandResponse (const app::ConcreteCommandPath & path, TLV::TLVReader * data)
473
+ void DeviceManager::HandleCommandResponse (const app::ConcreteCommandPath & path, TLV::TLVReader & data)
469
474
{
470
475
ChipLogProgress (NotSpecified, " Command Response received." );
471
476
0 commit comments