Skip to content

Commit 2501d42

Browse files
committed
Add device sync in progress tracking
1 parent dc75ac5 commit 2501d42

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

examples/fabric-admin/commands/pairing/DeviceSynchronization.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ void DeviceSynchronizer::OnReportEnd()
124124
#else
125125
ChipLogError(NotSpecified, "Cannot synchronize device with fabric bridge: RPC not enabled");
126126
#endif
127+
mDeviceSyncInProcess = false;
127128
}
128129

129130
void DeviceSynchronizer::OnDone(chip::app::ReadClient * apReadClient)
@@ -134,6 +135,7 @@ void DeviceSynchronizer::OnDone(chip::app::ReadClient * apReadClient)
134135
void DeviceSynchronizer::OnError(CHIP_ERROR error)
135136
{
136137
ChipLogProgress(NotSpecified, "Error fetching device data: %" CHIP_ERROR_FORMAT, error.Format());
138+
mDeviceSyncInProcess = false;
137139
}
138140

139141
void DeviceSynchronizer::OnDeviceConnected(chip::Messaging::ExchangeManager & exchangeMgr,
@@ -167,10 +169,18 @@ void DeviceSynchronizer::OnDeviceConnectionFailure(const chip::ScopedNodeId & pe
167169
void DeviceSynchronizer::StartDeviceSynchronization(chip::Controller::DeviceController & controller, chip::NodeId nodeId,
168170
bool deviceIsIcd)
169171
{
172+
if (mDeviceSyncInProcess)
173+
{
174+
ChipLogError(NotSpecified, "Device Sync NOT POSSIBLE: another sync is in progress");
175+
return;
176+
}
177+
170178
mCurrentDeviceData = chip_rpc_SynchronizedDevice_init_default;
171179
mCurrentDeviceData.node_id = nodeId;
172180
mCurrentDeviceData.has_is_icd = true;
173181
mCurrentDeviceData.is_icd = deviceIsIcd;
174182

183+
mDeviceSyncInProcess = true;
184+
175185
controller.GetConnectedDevice(nodeId, &mOnDeviceConnectedCallback, &mOnDeviceConnectionFailureCallback);
176186
}

examples/fabric-admin/commands/pairing/DeviceSynchronization.h

+1
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ class DeviceSynchronizer : public chip::app::ReadClient::Callback
6565
chip::Callback::Callback<chip::OnDeviceConnected> mOnDeviceConnectedCallback;
6666
chip::Callback::Callback<chip::OnDeviceConnectionFailure> mOnDeviceConnectionFailureCallback;
6767

68+
bool mDeviceSyncInProcess = false;
6869
chip_rpc_SynchronizedDevice mCurrentDeviceData = chip_rpc_SynchronizedDevice_init_default;
6970
};

third_party/nxp/nxp_matter_support

Submodule nxp_matter_support updated 30 files

0 commit comments

Comments
 (0)