Skip to content

Commit 64f859b

Browse files
authoredSep 17, 2024
[Fabric-Admin] Update the last used nodeId to avoid conflict (#35612)
* Update the last used nodeId to avoid conflict * Fix lint error
1 parent 89c8d33 commit 64f859b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

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

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ void FabricSyncAddBridgeCommand::OnCommissioningComplete(NodeId deviceId, CHIP_E
6262
ChipLogProgress(NotSpecified, "Successfully paired bridge device: NodeId: " ChipLogFormatX64,
6363
ChipLogValueX64(mBridgeNodeId));
6464

65+
DeviceMgr().UpdateLastUsedNodeId(mBridgeNodeId);
6566
DeviceMgr().SubscribeRemoteFabricBridge();
6667

6768
if (DeviceMgr().IsLocalBridgeReady())
@@ -180,6 +181,7 @@ void FabricSyncAddLocalBridgeCommand::OnCommissioningComplete(NodeId deviceId, C
180181
if (err == CHIP_NO_ERROR)
181182
{
182183
DeviceMgr().SetLocalBridgeNodeId(mLocalBridgeNodeId);
184+
DeviceMgr().UpdateLastUsedNodeId(mLocalBridgeNodeId);
183185
ChipLogProgress(NotSpecified, "Successfully paired local bridge device: NodeId: " ChipLogFormatX64,
184186
ChipLogValueX64(mLocalBridgeNodeId));
185187
}

‎examples/fabric-admin/device_manager/DeviceManager.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ void DeviceManager::Init()
4747
{
4848
// TODO: (#34113) Init mLastUsedNodeId from chip config file
4949
mLastUsedNodeId = 1;
50+
mInitialized = true;
51+
52+
ChipLogProgress(NotSpecified, "DeviceManager initialized: last used nodeId " ChipLogFormatX64,
53+
ChipLogValueX64(mLastUsedNodeId));
5054
}
5155

5256
NodeId DeviceManager::GetNextAvailableNodeId()
@@ -61,8 +65,8 @@ void DeviceManager::UpdateLastUsedNodeId(NodeId nodeId)
6165
{
6266
if (nodeId > mLastUsedNodeId)
6367
{
64-
ChipLogProgress(NotSpecified, "Updating last used NodeId to " ChipLogFormatX64, ChipLogValueX64(nodeId));
6568
mLastUsedNodeId = nodeId;
69+
ChipLogProgress(NotSpecified, "Updating last used NodeId to " ChipLogFormatX64, ChipLogValueX64(mLastUsedNodeId));
6670
}
6771
}
6872

0 commit comments

Comments
 (0)