Skip to content

Commit ffaeda4

Browse files
authored
[Fabric-Admin] Merge CommissioningDelegate and PairingDelegate (project-chip#36388)
1 parent 775cb4d commit ffaeda4

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CHIP_ERROR FabricSyncAddBridgeCommand::RunCommand(NodeId remoteId)
8787
return CHIP_NO_ERROR;
8888
}
8989

90-
PairingManager::Instance().SetCommissioningDelegate(this);
90+
PairingManager::Instance().SetPairingDelegate(this);
9191

9292
mBridgeNodeId = remoteId;
9393

@@ -180,7 +180,7 @@ CHIP_ERROR FabricSyncAddLocalBridgeCommand::RunCommand(NodeId deviceId)
180180
return CHIP_NO_ERROR;
181181
}
182182

183-
PairingManager::Instance().SetCommissioningDelegate(this);
183+
PairingManager::Instance().SetPairingDelegate(this);
184184
mLocalBridgeNodeId = deviceId;
185185

186186
if (mSetupPINCode.HasValue())
@@ -252,7 +252,7 @@ void FabricSyncDeviceCommand::OnCommissioningWindowOpened(NodeId deviceId, CHIP_
252252
{
253253
NodeId nodeId = DeviceMgr().GetNextAvailableNodeId();
254254

255-
PairingManager::Instance().SetCommissioningDelegate(this);
255+
PairingManager::Instance().SetPairingDelegate(this);
256256
mAssignedNodeId = nodeId;
257257

258258
usleep(kCommissionPrepareTimeMs * 1000);

examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace admin {
2626
// Constants
2727
constexpr uint32_t kCommissionPrepareTimeMs = 500;
2828

29-
class FabricSyncAddBridgeCommand : public CHIPCommand, public CommissioningDelegate
29+
class FabricSyncAddBridgeCommand : public CHIPCommand, public PairingDelegate
3030
{
3131
public:
3232
FabricSyncAddBridgeCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("add-bridge", credIssuerCommands)
@@ -71,7 +71,7 @@ class FabricSyncRemoveBridgeCommand : public CHIPCommand, public PairingDelegate
7171
chip::NodeId mBridgeNodeId;
7272
};
7373

74-
class FabricSyncAddLocalBridgeCommand : public CHIPCommand, public CommissioningDelegate
74+
class FabricSyncAddLocalBridgeCommand : public CHIPCommand, public PairingDelegate
7575
{
7676
public:
7777
FabricSyncAddLocalBridgeCommand(CredentialIssuerCommands * credIssuerCommands) :
@@ -116,7 +116,7 @@ class FabricSyncRemoveLocalBridgeCommand : public CHIPCommand, public PairingDel
116116
chip::NodeId mLocalBridgeNodeId;
117117
};
118118

119-
class FabricSyncDeviceCommand : public CHIPCommand, public CommissioningWindowDelegate, public CommissioningDelegate
119+
class FabricSyncDeviceCommand : public CHIPCommand, public CommissioningWindowDelegate, public PairingDelegate
120120
{
121121
public:
122122
FabricSyncDeviceCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("sync-device", credIssuerCommands)

examples/fabric-admin/device_manager/PairingManager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ void PairingManager::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err)
312312
ChipLogProgress(NotSpecified, "Device commissioning Failure: %s", ErrorStr(err));
313313
}
314314

315-
if (mCommissioningDelegate)
315+
if (mPairingDelegate)
316316
{
317-
mCommissioningDelegate->OnCommissioningComplete(nodeId, err);
318-
SetCommissioningDelegate(nullptr);
317+
mPairingDelegate->OnCommissioningComplete(nodeId, err);
318+
SetPairingDelegate(nullptr);
319319
}
320320
}
321321

@@ -555,6 +555,7 @@ void PairingManager::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E
555555
if (self->mPairingDelegate)
556556
{
557557
self->mPairingDelegate->OnDeviceRemoved(nodeId, err);
558+
self->SetPairingDelegate(nullptr);
558559
}
559560

560561
#if defined(PW_RPC_ENABLED)

examples/fabric-admin/device_manager/PairingManager.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,12 @@ class CommissioningWindowDelegate
3737
virtual ~CommissioningWindowDelegate() = default;
3838
};
3939

40-
class CommissioningDelegate
41-
{
42-
public:
43-
virtual void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR err) = 0;
44-
virtual ~CommissioningDelegate() = default;
45-
};
46-
4740
class PairingDelegate
4841
{
4942
public:
50-
virtual void OnDeviceRemoved(chip::NodeId deviceId, CHIP_ERROR err) = 0;
51-
virtual ~PairingDelegate() = default;
43+
virtual void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR err) {}
44+
virtual void OnDeviceRemoved(chip::NodeId deviceId, CHIP_ERROR err) {}
45+
virtual ~PairingDelegate() = default;
5246
};
5347

5448
/**
@@ -85,7 +79,6 @@ class PairingManager : public chip::Controller::DevicePairingDelegate,
8579
CHIP_ERROR Init(chip::Controller::DeviceCommissioner * commissioner, CredentialIssuerCommands * credIssuerCmds);
8680

8781
void SetOpenCommissioningWindowDelegate(CommissioningWindowDelegate * delegate) { mCommissioningWindowDelegate = delegate; }
88-
void SetCommissioningDelegate(CommissioningDelegate * delegate) { mCommissioningDelegate = delegate; }
8982
void SetPairingDelegate(PairingDelegate * delegate) { mPairingDelegate = delegate; }
9083
PairingDelegate * GetPairingDelegate() { return mPairingDelegate; }
9184

@@ -181,7 +174,6 @@ class PairingManager : public chip::Controller::DevicePairingDelegate,
181174
CredentialIssuerCommands * mCredIssuerCmds = nullptr;
182175

183176
CommissioningWindowDelegate * mCommissioningWindowDelegate = nullptr;
184-
CommissioningDelegate * mCommissioningDelegate = nullptr;
185177
PairingDelegate * mPairingDelegate = nullptr;
186178

187179
chip::NodeId mNodeId = chip::kUndefinedNodeId;

0 commit comments

Comments
 (0)