@@ -90,37 +90,44 @@ CHIP_ERROR AddSynchronizedDevice(chip::NodeId nodeId)
90
90
chip_rpc_SynchronizedDevice device;
91
91
device.node_id = nodeId;
92
92
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.
94
96
addSynchronizedDeviceCall = fabricBridgeClient.AddSynchronizedDevice (device, OnAddDeviceResponseCompleted);
95
97
96
98
if (!addSynchronizedDeviceCall.active ())
97
99
{
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;
99
106
}
100
107
101
- return CHIP_NO_ERROR;
102
- }
108
+ CHIP_ERROR RemoveSynchronizedDevice (chip::NodeId nodeId)
109
+ {
110
+ ChipLogProgress (NotSpecified, " RemoveSynchronizedDevice" );
103
111
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
+ }
107
117
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;
113
120
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);
116
125
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
+ }
119
131
120
- if (!removeSynchronizedDeviceCall.active ())
121
- {
122
- return CHIP_ERROR_INTERNAL;
132
+ return CHIP_NO_ERROR;
123
133
}
124
-
125
- return CHIP_NO_ERROR;
126
- }
0 commit comments