@@ -41,6 +41,7 @@ constexpr uint32_t kDefaultChannelId = 1;
41
41
// Fabric Bridge Client
42
42
rpc::pw_rpc::nanopb::FabricBridge::Client fabricBridgeClient (rpc::client::GetDefaultRpcClient(), kDefaultChannelId);
43
43
pw::rpc::NanopbUnaryReceiver<::pw_protobuf_Empty> addSynchronizedDeviceCall;
44
+ pw::rpc::NanopbUnaryReceiver<::pw_protobuf_Empty> removeSynchronizedDeviceCall;
44
45
45
46
// Callback function to be called when the RPC response is received
46
47
void OnAddDeviceResponseCompleted (const pw_protobuf_Empty & response, pw::Status status)
@@ -55,6 +56,19 @@ void OnAddDeviceResponseCompleted(const pw_protobuf_Empty & response, pw::Status
55
56
}
56
57
}
57
58
59
+ // Callback function to be called when the RPC response is received
60
+ void OnRemoveDeviceResponseCompleted (const pw_protobuf_Empty & response, pw::Status status)
61
+ {
62
+ if (status.ok ())
63
+ {
64
+ ChipLogProgress (NotSpecified, " RemoveSynchronizedDevice RPC call succeeded!" );
65
+ }
66
+ else
67
+ {
68
+ ChipLogProgress (NotSpecified, " RemoveSynchronizedDevice RPC call failed with status: %d\n " , status.code ());
69
+ }
70
+ }
71
+
58
72
} // namespace
59
73
60
74
CHIP_ERROR InitRpcClient (uint16_t rpcServerPort)
@@ -86,3 +100,27 @@ CHIP_ERROR AddSynchronizedDevice(chip::NodeId nodeId)
86
100
87
101
return CHIP_NO_ERROR;
88
102
}
103
+
104
+ CHIP_ERROR RemoveSynchronizedDevice (chip::NodeId nodeId)
105
+ {
106
+ ChipLogProgress (NotSpecified, " RemoveSynchronizedDevice" );
107
+
108
+ if (removeSynchronizedDeviceCall.active ())
109
+ {
110
+ ChipLogError (NotSpecified, " Remove Synchronized Device operation is in progress\n " );
111
+ return CHIP_ERROR_BUSY;
112
+ }
113
+
114
+ chip_rpc_SynchronizedDevice device;
115
+ device.node_id = nodeId;
116
+
117
+ // The RPC will remain active as long as `removeSynchronizedDeviceCall` is alive.
118
+ removeSynchronizedDeviceCall = fabricBridgeClient.RemoveSynchronizedDevice (device, OnRemoveDeviceResponseCompleted);
119
+
120
+ if (!removeSynchronizedDeviceCall.active ())
121
+ {
122
+ return CHIP_ERROR_INTERNAL;
123
+ }
124
+
125
+ return CHIP_NO_ERROR;
126
+ }
0 commit comments