Skip to content

Commit 53824f6

Browse files
committed
Update comments for RemoveSynchronizedDevice
1 parent 8f887a3 commit 53824f6

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

examples/fabric-admin/rpc/RpcClient.cpp

+29-22
Original file line numberDiff line numberDiff line change
@@ -90,37 +90,44 @@ CHIP_ERROR AddSynchronizedDevice(chip::NodeId nodeId)
9090
chip_rpc_SynchronizedDevice device;
9191
device.node_id = nodeId;
9292

93-
// The RPC will remain active as long as `addSynchronizedDeviceCall` is alive.
93+
// By assigning the returned call to the global 'addSynchronizedDeviceCall', the RPC
94+
// call is kept alive until it completes. When a response is received, it
95+
// will be logged by the handler function and the call will complete.
9496
addSynchronizedDeviceCall = fabricBridgeClient.AddSynchronizedDevice(device, OnAddDeviceResponseCompleted);
9597

9698
if (!addSynchronizedDeviceCall.active())
9799
{
98-
return CHIP_ERROR_INTERNAL;
100+
{
101+
// The RPC call was not sent. This could occur due to, for example, an invalid channel ID. Handle if necessary.
102+
return CHIP_ERROR_INTERNAL;
103+
}
104+
105+
return CHIP_NO_ERROR;
99106
}
100107

101-
return CHIP_NO_ERROR;
102-
}
108+
CHIP_ERROR RemoveSynchronizedDevice(chip::NodeId nodeId)
109+
{
110+
ChipLogProgress(NotSpecified, "RemoveSynchronizedDevice");
103111

104-
CHIP_ERROR RemoveSynchronizedDevice(chip::NodeId nodeId)
105-
{
106-
ChipLogProgress(NotSpecified, "RemoveSynchronizedDevice");
112+
if (removeSynchronizedDeviceCall.active())
113+
{
114+
ChipLogError(NotSpecified, "Remove Synchronized Device operation is in progress\n");
115+
return CHIP_ERROR_BUSY;
116+
}
107117

108-
if (removeSynchronizedDeviceCall.active())
109-
{
110-
ChipLogError(NotSpecified, "Remove Synchronized Device operation is in progress\n");
111-
return CHIP_ERROR_BUSY;
112-
}
118+
chip_rpc_SynchronizedDevice device;
119+
device.node_id = nodeId;
113120

114-
chip_rpc_SynchronizedDevice device;
115-
device.node_id = nodeId;
121+
// By assigning the returned call to the global 'removeSynchronizedDeviceCall', the RPC
122+
// call is kept alive until it completes. When a response is received, it
123+
// will be logged by the handler function and the call will complete.
124+
removeSynchronizedDeviceCall = fabricBridgeClient.RemoveSynchronizedDevice(device, OnRemoveDeviceResponseCompleted);
116125

117-
// The RPC will remain active as long as `removeSynchronizedDeviceCall` is alive.
118-
removeSynchronizedDeviceCall = fabricBridgeClient.RemoveSynchronizedDevice(device, OnRemoveDeviceResponseCompleted);
126+
if (!removeSynchronizedDeviceCall.active())
127+
{
128+
// The RPC call was not sent. This could occur due to, for example, an invalid channel ID. Handle if necessary.
129+
return CHIP_ERROR_INTERNAL;
130+
}
119131

120-
if (!removeSynchronizedDeviceCall.active())
121-
{
122-
return CHIP_ERROR_INTERNAL;
132+
return CHIP_NO_ERROR;
123133
}
124-
125-
return CHIP_NO_ERROR;
126-
}

0 commit comments

Comments
 (0)