From 721e63124e979d43f2774c9ca929989c62e6f3a8 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 30 Jul 2024 15:58:09 +0000 Subject: [PATCH 01/10] Add CommandHandler to fabric-bridge --- .../src/DeviceManager.cpp | 8 ++++- examples/fabric-bridge-app/linux/main.cpp | 36 +++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp index bc70c0cb0fe609..ed798dca2b4f0a 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp @@ -98,6 +98,11 @@ DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::WindowStatus:: DECLARE_DYNAMIC_ATTRIBUTE(AdministratorCommissioning::Attributes::AdminVendorId::Id, VENDOR_ID, 2, 0), /* Reachable */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); +constexpr CommandId bridgedDeviceBasicInformationCommands[] = { + app::Clusters::BridgedDeviceBasicInformation::Commands::KeepActive::Id, + kInvalidCommandId, +}; + constexpr CommandId administratorCommissioningCommands[] = { app::Clusters::AdministratorCommissioning::Commands::OpenCommissioningWindow::Id, app::Clusters::AdministratorCommissioning::Commands::OpenBasicCommissioningWindow::Id, @@ -108,7 +113,8 @@ constexpr CommandId administratorCommissioningCommands[] = { // Declare Cluster List for Bridged Node endpoint DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedNodeClusters) DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), + bridgedDeviceBasicInformationCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER), administratorCommissioningCommands, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index d8fb45dea08a02..5b79742519beff 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -39,6 +39,7 @@ using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::AdministratorCommissioning; +using namespace chip::app::Clusters::BridgedDeviceBasicInformation; namespace { @@ -122,7 +123,7 @@ void AdministratorCommissioningCommandHandler::InvokeCommand(HandlerContext & ha EndpointId endpointId = handlerContext.mRequestPath.mEndpointId; ChipLogProgress(NotSpecified, "Received command to open commissioning window on Endpoint: %d", endpointId); - if (handlerContext.mRequestPath.mCommandId != Commands::OpenCommissioningWindow::Id || endpointId == kRootEndpointId) + if (handlerContext.mRequestPath.mCommandId != AdministratorCommissioning::Commands::OpenCommissioningWindow::Id || endpointId == kRootEndpointId) { // Proceed with default handling in Administrator Commissioning Server return; @@ -130,7 +131,7 @@ void AdministratorCommissioningCommandHandler::InvokeCommand(HandlerContext & ha handlerContext.SetCommandHandled(); - Commands::OpenCommissioningWindow::DecodableType commandData; + AdministratorCommissioning::Commands::OpenCommissioningWindow::DecodableType commandData; if (DataModel::Decode(handlerContext.mPayload, commandData) != CHIP_NO_ERROR) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::InvalidCommand); @@ -166,7 +167,37 @@ void AdministratorCommissioningCommandHandler::InvokeCommand(HandlerContext & ha handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, status); } +class BridgedDeviceInformationCommandHandler : public CommandHandlerInterface +{ +public: + // Register for the BridgedDeviceBasicInformation cluster on all endpoints. + BridgedDeviceInformationCommandHandler() : + CommandHandlerInterface(Optional::Missing(), BridgedDeviceBasicInformation::Id) + {} + + void InvokeCommand(HandlerContext & handlerContext) override; +}; + +void BridgedDeviceInformationCommandHandler::InvokeCommand(HandlerContext & handlerContext) +{ + using Protocols::InteractionModel::Status; + + EndpointId endpointId = handlerContext.mRequestPath.mEndpointId; + + if (handlerContext.mRequestPath.mCommandId != BridgedDeviceBasicInformation::Commands::KeepActive::Id) + { + // Proceed with default handling in BridgedDeviceBasicInformation Server + return; + } + + ChipLogProgress(NotSpecified, "Received command to KeepActive on Endpoint: %d", endpointId); + + handlerContext.SetCommandHandled(); + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::Success); +} + AdministratorCommissioningCommandHandler gAdministratorCommissioningCommandHandler; +BridgedDeviceInformationCommandHandler gBridgedDeviceInformationCommandHandler; } // namespace @@ -175,6 +206,7 @@ void ApplicationInit() ChipLogDetail(NotSpecified, "Fabric-Bridge: ApplicationInit()"); CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gAdministratorCommissioningCommandHandler); + CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gBridgedDeviceInformationCommandHandler); #if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE InitRpcServer(kFabricBridgeServerPort); From 61548e1160d1459b20680ad23afbee2a79f65a38 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 7 Aug 2024 13:05:23 +0000 Subject: [PATCH 02/10] Plumbing for KeepActive --- .../pigweed/protos/fabric_admin_service.proto | 6 +++ .../protos/fabric_bridge_service.proto | 7 +++- .../common/pigweed/rpc_services/FabricAdmin.h | 5 +++ .../pigweed/rpc_services/FabricBridge.h | 5 +++ examples/fabric-admin/rpc/RpcClient.cpp | 38 +++++++++++++++++++ examples/fabric-admin/rpc/RpcClient.h | 12 ++++++ examples/fabric-admin/rpc/RpcServer.cpp | 12 ++++++ .../include/BridgedDevice.h | 2 + .../src/BridgedDevice.cpp | 5 +++ .../fabric-bridge-app/linux/RpcClient.cpp | 37 ++++++++++++++++++ .../fabric-bridge-app/linux/RpcServer.cpp | 18 +++++++++ .../linux/include/RpcClient.h | 2 + examples/fabric-bridge-app/linux/main.cpp | 34 ++++++++++++++--- 13 files changed, 177 insertions(+), 6 deletions(-) diff --git a/examples/common/pigweed/protos/fabric_admin_service.proto b/examples/common/pigweed/protos/fabric_admin_service.proto index 7f6ec4f4995b12..382da4b71393e3 100644 --- a/examples/common/pigweed/protos/fabric_admin_service.proto +++ b/examples/common/pigweed/protos/fabric_admin_service.proto @@ -14,6 +14,11 @@ message DeviceCommissioningWindowInfo { bytes verifier = 6; } +message KeepActiveParameters { + uint64 node_id = 1; + uint32 stay_active_duration = 2; +} + // Define the response message to convey the status of the operation message OperationStatus { bool success = 1; @@ -21,4 +26,5 @@ message OperationStatus { service FabricAdmin { rpc OpenCommissioningWindow(DeviceCommissioningWindowInfo) returns (OperationStatus){} + rpc KeepActive(KeepActiveParameters) returns (pw.protobuf.Empty){} } diff --git a/examples/common/pigweed/protos/fabric_bridge_service.proto b/examples/common/pigweed/protos/fabric_bridge_service.proto index 10e5ccf888583d..bb81442ce36799 100644 --- a/examples/common/pigweed/protos/fabric_bridge_service.proto +++ b/examples/common/pigweed/protos/fabric_bridge_service.proto @@ -9,8 +9,13 @@ message SynchronizedDevice { uint64 node_id = 1; } +message KeepActiveChanged { + uint64 node_id = 1; + uint32 promised_active_duration = 2; +} + service FabricBridge { rpc AddSynchronizedDevice(SynchronizedDevice) returns (pw.protobuf.Empty){} rpc RemoveSynchronizedDevice(SynchronizedDevice) returns (pw.protobuf.Empty){} + rpc ActiveChanged(KeepActiveChanged) returns (pw.protobuf.Empty){} } - diff --git a/examples/common/pigweed/rpc_services/FabricAdmin.h b/examples/common/pigweed/rpc_services/FabricAdmin.h index 14de9d50f60673..1c8398215a6b7c 100644 --- a/examples/common/pigweed/rpc_services/FabricAdmin.h +++ b/examples/common/pigweed/rpc_services/FabricAdmin.h @@ -39,6 +39,11 @@ class FabricAdmin : public pw_rpc::nanopb::FabricAdmin::Service { return pw::Status::Unimplemented(); } + + virtual pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, chip_rpc_OperationStatus & response) + { + return pw::Status::Unimplemented(); + } }; } // namespace rpc diff --git a/examples/common/pigweed/rpc_services/FabricBridge.h b/examples/common/pigweed/rpc_services/FabricBridge.h index 4b9c4d93f1eb51..aab714223968df 100644 --- a/examples/common/pigweed/rpc_services/FabricBridge.h +++ b/examples/common/pigweed/rpc_services/FabricBridge.h @@ -43,6 +43,11 @@ class FabricBridge : public pw_rpc::nanopb::FabricBridge::Service { return pw::Status::Unimplemented(); } + + virtual pw::Status ActiveChanged(const chip_rpc_KeepActiveChanged & request, pw_protobuf_Empty & response) + { + return pw::Status::Unimplemented(); + } }; } // namespace rpc diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index 00ca1204cc1f19..35afb9303417db 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -105,6 +105,23 @@ void OnRemoveDeviceResponseCompleted(const pw_protobuf_Empty & response, pw::Sta } } +void GenericResponseCompletedWithNoParameters(const pw_protobuf_Empty & response, pw::Status status) +{ + std::lock_guard lock(responseMutex); + responseReceived = true; + responseError = status.ok() ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + responseCv.notify_one(); + + if (status.ok()) + { + ChipLogProgress(NotSpecified, "RPC call succeeded!"); + } + else + { + ChipLogProgress(NotSpecified, "RPC call failed with status: %d", status.code()); + } +} + } // namespace CHIP_ERROR InitRpcClient(uint16_t rpcServerPort) @@ -152,3 +169,24 @@ CHIP_ERROR RemoveSynchronizedDevice(chip::NodeId nodeId) return WaitForResponse(call); } + +CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration) +{ + ChipLogProgress(NotSpecified, "ActiveChanged"); + + chip_rpc_KeepActiveChanged parameters; + parameters.node_id = nodeId; + parameters.promised_active_duration = promisedActiveDuration; + + // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler + // function and the call will complete. + auto call = fabricBridgeClient.ActiveChanged(parameters, GenericResponseCompletedWithNoParameters); + + if (!call.active()) + { + // The RPC call was not sent. This could occur due to, for example, an invalid channel ID. Handle if necessary. + return CHIP_ERROR_INTERNAL; + } + + return WaitForResponse(call); +} \ No newline at end of file diff --git a/examples/fabric-admin/rpc/RpcClient.h b/examples/fabric-admin/rpc/RpcClient.h index a1754b3846d508..aab17511a3f2fe 100644 --- a/examples/fabric-admin/rpc/RpcClient.h +++ b/examples/fabric-admin/rpc/RpcClient.h @@ -61,3 +61,15 @@ CHIP_ERROR AddSynchronizedDevice(chip::NodeId nodeId); * - CHIP_ERROR_INTERNAL: An internal error occurred while activating the RPC call. */ CHIP_ERROR RemoveSynchronizedDevice(chip::NodeId nodeId); + +/** + * @brief Received StayActiveResponse on behalf of client that previously called KeepActive + * + * @param nodeId The Node ID of the device we recieved a StayActiveResponse. + * @param promisedActiveDuration the computed duration (in milliseconds) that the ICD intends to stay active for. + * @return CHIP_ERROR An error code indicating the success or failure of the operation. + * - CHIP_NO_ERROR: The RPC command was successfully processed. + * - CHIP_ERROR_BUSY: Another operation is currently in progress. + * - CHIP_ERROR_INTERNAL: An internal error occurred while activating the RPC call. + */ +CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration); diff --git a/examples/fabric-admin/rpc/RpcServer.cpp b/examples/fabric-admin/rpc/RpcServer.cpp index d4979e5a27c427..34b4e3c714af93 100644 --- a/examples/fabric-admin/rpc/RpcServer.cpp +++ b/examples/fabric-admin/rpc/RpcServer.cpp @@ -65,6 +65,18 @@ class FabricAdmin final : public rpc::FabricAdmin return pw::OkStatus(); } + + pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, chip_rpc_OperationStatus & response) override + { + // TODO(#33221): When we get this command hopefully we are already registers with an ICD device to be + // notified when it wakes up. We will need to add in hooks there to make sure we send the StayActiveRequest + // Important thing to note: + // * If we get this call multiple times before we get a wakeup from ICD, we only send out one StayActiveRequest command + // * After 60 mins from last exipry we no longer will send out a StayActiveRequest. + + response.success = true; + return pw::OkStatus(); + } }; FabricAdmin fabric_admin_service; diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h index a237d93d133eb7..4f02c948faddcf 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h @@ -36,6 +36,7 @@ class BridgedDevice virtual ~BridgedDevice() {} bool IsReachable(); + bool IsIcd(); void SetReachable(bool reachable); void SetName(const char * name); void SetLocation(std::string location) { mLocation = location; }; @@ -51,6 +52,7 @@ class BridgedDevice protected: bool mReachable; + bool mIsIcd = false; char mName[kDeviceNameSize]; std::string mLocation; chip::NodeId mNodeId; diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp index d641f3743d43f0..de2dd1a405f75b 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp @@ -37,6 +37,11 @@ bool BridgedDevice::IsReachable() return mReachable; } +bool BridgedDevice::IsIcd() +{ + return mIsIcd; +} + void BridgedDevice::SetReachable(bool reachable) { mReachable = reachable; diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index d2aef5d1d82e5e..3f5dcbe9fdb0af 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -87,6 +87,24 @@ void OnOpenCommissioningWindowCompleted(const chip_rpc_OperationStatus & respons } } +// Callback function to be called when the RPC response is received for generic empty response. +void GenericRpcCompletedWithPwStatus(const pw_protobuf_Empty & response, pw::Status status) +{ + std::lock_guard lock(responseMutex); + responseReceived = true; + responseError = status.ok() ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + responseCv.notify_one(); + + if (status.ok()) + { + ChipLogProgress(NotSpecified, "RPC call succeeded!"); + } + else + { + ChipLogProgress(NotSpecified, "RPC call failed with status: %d", status.code()); + } +} + } // namespace CHIP_ERROR InitRpcClient(uint16_t rpcServerPort) @@ -143,3 +161,22 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams para return OpenCommissioningWindow(device); } + +CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration) +{ + chip_rpc_KeepActiveParameters params; + params.node_id = nodeId; + params.stay_active_duration = stayActiveDuration; + + // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler + // function and the call will complete. + auto call = fabricAdminClient.KeepActive(params, GenericRpcCompletedWithPwStatus); + + if (!call.active()) + { + // The RPC call was not sent. This could occur due to, for example, an invalid channel ID. Handle if necessary. + return CHIP_ERROR_INTERNAL; + } + + return WaitForResponse(call); +} \ No newline at end of file diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index 76fe8f84653d39..12f560e5ed14c0 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -44,6 +44,7 @@ class FabricBridge final : public chip::rpc::FabricBridge public: pw::Status AddSynchronizedDevice(const chip_rpc_SynchronizedDevice & request, pw_protobuf_Empty & response) override; pw::Status RemoveSynchronizedDevice(const chip_rpc_SynchronizedDevice & request, pw_protobuf_Empty & response) override; + pw::Status ActiveChanged(const chip_rpc_KeepActiveChanged & request, pw_protobuf_Empty & response) override; }; pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice & request, pw_protobuf_Empty & response) @@ -80,6 +81,23 @@ pw::Status FabricBridge::RemoveSynchronizedDevice(const chip_rpc_SynchronizedDev return pw::OkStatus(); } +pw::Status FabricBridge::ActiveChanged(const chip_rpc_KeepActiveChanged & request, pw_protobuf_Empty & response) +{ + NodeId nodeId = request.node_id; + ChipLogProgress(NotSpecified, "Received ActiveChanged: " ChipLogFormatX64, ChipLogValueX64(nodeId)); + + auto* device = BridgeDeviceMgr().GetDeviceByNodeId(nodeId); + if (device == nullptr) + { + ChipLogError(NotSpecified, "Could not find bridged device associated with nodeId=0x" ChipLogFormatX64, ChipLogValueX64(nodeId)); + return pw::Status::NotFound(); + } + + // TODO: DNS without making this change, we need to send the event for the coresponding bridged device endpoint. + // device->TriggerActiveChangeEventOnDevice(request.promised_active_duration) + return pw::OkStatus(); +} + FabricBridge fabric_bridge_service; #endif // defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE diff --git a/examples/fabric-bridge-app/linux/include/RpcClient.h b/examples/fabric-bridge-app/linux/include/RpcClient.h index e7e2cc5b48505c..73f7d58bab3ddc 100644 --- a/examples/fabric-bridge-app/linux/include/RpcClient.h +++ b/examples/fabric-bridge-app/linux/include/RpcClient.h @@ -56,3 +56,5 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowPasscodeParams para */ CHIP_ERROR OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams params); + +CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration); \ No newline at end of file diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index 09f01c62e692d3..5bdb74aa872727 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -181,19 +181,43 @@ class BridgedDeviceInformationCommandHandler : public CommandHandlerInterface void BridgedDeviceInformationCommandHandler::InvokeCommand(HandlerContext & handlerContext) { using Protocols::InteractionModel::Status; + VerifyOrReturn(handlerContext.mRequestPath.mCommandId != BridgedDeviceBasicInformation::Commands::KeepActive::Id); EndpointId endpointId = handlerContext.mRequestPath.mEndpointId; + ChipLogProgress(NotSpecified, "Received command to KeepActive on Endpoint: %d", endpointId); + + BridgedDevice * device = BridgeDeviceMgr().GetDevice(endpointId); - if (handlerContext.mRequestPath.mCommandId != BridgedDeviceBasicInformation::Commands::KeepActive::Id) + if (device == nullptr || !device->IsIcd()) { - // Proceed with default handling in BridgedDeviceBasicInformation Server + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::Failure); return; } - ChipLogProgress(NotSpecified, "Received command to KeepActive on Endpoint: %d", endpointId); + BridgedDeviceBasicInformation::Commands::KeepActive::DecodableType commandData; + if (DataModel::Decode(handlerContext.mPayload, commandData) != CHIP_NO_ERROR) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::InvalidCommand); + return; + } - handlerContext.SetCommandHandled(); - handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::Success); + Status status = Status::Failure; + +#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE + if (KeepActive(device->GetNodeId(), commandData.stayActiveDuration) == CHIP_NO_ERROR) + { + ChipLogProgress(NotSpecified, "KeepActive successfully processed"); + status = Status::Success; + } + else + { + ChipLogProgress(NotSpecified, "KeepActive failed to process"); + } +#else + ChipLogProgress(NotSpecified, "Unable to properly call KeepActive: PW_RPC_FABRIC_BRIDGE_SERVICE not defined"); +#endif // defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE + + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, status); } AdministratorCommissioningCommandHandler gAdministratorCommissioningCommandHandler; From ea9e94619d1b3baec6fc1a90a04d1c89d6b2ab35 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 7 Aug 2024 17:36:08 +0000 Subject: [PATCH 03/10] More plumbing --- .../common/pigweed/rpc_services/FabricAdmin.h | 2 +- examples/fabric-admin/rpc/RpcServer.cpp | 4 +- .../include/BridgedDevice.h | 2 + .../src/BridgedDevice.cpp | 38 ++++++++++++++++++- .../fabric-bridge-app/linux/RpcServer.cpp | 3 +- examples/fabric-bridge-app/linux/main.cpp | 4 +- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/examples/common/pigweed/rpc_services/FabricAdmin.h b/examples/common/pigweed/rpc_services/FabricAdmin.h index 1c8398215a6b7c..125d322e3ab8bf 100644 --- a/examples/common/pigweed/rpc_services/FabricAdmin.h +++ b/examples/common/pigweed/rpc_services/FabricAdmin.h @@ -40,7 +40,7 @@ class FabricAdmin : public pw_rpc::nanopb::FabricAdmin::Service return pw::Status::Unimplemented(); } - virtual pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, chip_rpc_OperationStatus & response) + virtual pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, pw_protobuf_Empty & response) { return pw::Status::Unimplemented(); } diff --git a/examples/fabric-admin/rpc/RpcServer.cpp b/examples/fabric-admin/rpc/RpcServer.cpp index 34b4e3c714af93..24c0c5908a25a4 100644 --- a/examples/fabric-admin/rpc/RpcServer.cpp +++ b/examples/fabric-admin/rpc/RpcServer.cpp @@ -66,15 +66,15 @@ class FabricAdmin final : public rpc::FabricAdmin return pw::OkStatus(); } - pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, chip_rpc_OperationStatus & response) override + pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, pw_protobuf_Empty & response) override { + ChipLogProgress(NotSpecified, "Received KeepActive request: 0x%lx, %u", request.node_id, request.stay_active_duration); // TODO(#33221): When we get this command hopefully we are already registers with an ICD device to be // notified when it wakes up. We will need to add in hooks there to make sure we send the StayActiveRequest // Important thing to note: // * If we get this call multiple times before we get a wakeup from ICD, we only send out one StayActiveRequest command // * After 60 mins from last exipry we no longer will send out a StayActiveRequest. - response.success = true; return pw::OkStatus(); } }; diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h index 4f02c948faddcf..9f4dff5e580763 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h @@ -35,6 +35,8 @@ class BridgedDevice BridgedDevice(chip::NodeId nodeId); virtual ~BridgedDevice() {} + void LogActiveChangeEvent(uint32_t promisedActiveDuration); + bool IsReachable(); bool IsIcd(); void SetReachable(bool reachable); diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp index de2dd1a405f75b..3b246442041e4f 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp @@ -19,9 +19,36 @@ #include "BridgedDevice.h" #include +#include + +#include #include -#include +namespace { + +struct ActiveChangeEventWorkData { + chip::EndpointId mEndpointId; + uint32_t mPromisedActiveDuration; +}; + +static void ActiveChangeEventWork(intptr_t arg) +{ + ActiveChangeEventWorkData* data = reinterpret_cast(arg); + + chip::app::Clusters::BridgedDeviceBasicInformation::Events::ActiveChanged::Type event{}; + event.promisedActiveDuration = data->mPromisedActiveDuration; + chip::EventNumber eventNumber = 0; + + // TODO DNS this is not called from Matter event loop so it will crash + CHIP_ERROR err = chip::app::LogEvent(event, data->mEndpointId, eventNumber); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(NotSpecified, "LogEvent for ActiveChanged failed %s", err.AsString()); + } + chip::Platform::Delete(data); +} + +} // namespace using namespace chip::app::Clusters::Actions; @@ -32,6 +59,15 @@ BridgedDevice::BridgedDevice(chip::NodeId nodeId) mEndpointId = chip::kInvalidEndpointId; } +void BridgedDevice::LogActiveChangeEvent(uint32_t promisedActiveDuration) +{ + ActiveChangeEventWorkData* workdata = chip::Platform::New(); + workdata->mEndpointId = mEndpointId; + workdata->mPromisedActiveDuration = promisedActiveDuration; + + chip::DeviceLayer::PlatformMgr().ScheduleWork(ActiveChangeEventWork, reinterpret_cast(workdata)); +} + bool BridgedDevice::IsReachable() { return mReachable; diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index 12f560e5ed14c0..30aecd0fb9fd10 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -93,8 +93,7 @@ pw::Status FabricBridge::ActiveChanged(const chip_rpc_KeepActiveChanged & reques return pw::Status::NotFound(); } - // TODO: DNS without making this change, we need to send the event for the coresponding bridged device endpoint. - // device->TriggerActiveChangeEventOnDevice(request.promised_active_duration) + device->LogActiveChangeEvent(request.promised_active_duration); return pw::OkStatus(); } diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index e2f91dfc43d54d..d670eea627ae54 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -184,13 +184,15 @@ class BridgedDeviceInformationCommandHandler : public CommandHandlerInterface void BridgedDeviceInformationCommandHandler::InvokeCommand(HandlerContext & handlerContext) { using Protocols::InteractionModel::Status; - VerifyOrReturn(handlerContext.mRequestPath.mCommandId != BridgedDeviceBasicInformation::Commands::KeepActive::Id); + VerifyOrReturn(handlerContext.mRequestPath.mCommandId == BridgedDeviceBasicInformation::Commands::KeepActive::Id); EndpointId endpointId = handlerContext.mRequestPath.mEndpointId; ChipLogProgress(NotSpecified, "Received command to KeepActive on Endpoint: %d", endpointId); BridgedDevice * device = BridgeDeviceMgr().GetDevice(endpointId); + handlerContext.SetCommandHandled(); + if (device == nullptr || !device->IsIcd()) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::Failure); From 1f62a3afd944648967000538c5c3f73b6e4c41fa Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 7 Aug 2024 20:24:50 +0000 Subject: [PATCH 04/10] Quick fix --- examples/fabric-admin/rpc/RpcClient.cpp | 2 +- examples/fabric-bridge-app/linux/RpcClient.cpp | 2 +- examples/fabric-bridge-app/linux/include/RpcClient.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index 35afb9303417db..3dcea2d7e1dc03 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -189,4 +189,4 @@ CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration) } return WaitForResponse(call); -} \ No newline at end of file +} diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index 3f5dcbe9fdb0af..adfa29dbaac504 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -179,4 +179,4 @@ CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration) } return WaitForResponse(call); -} \ No newline at end of file +} diff --git a/examples/fabric-bridge-app/linux/include/RpcClient.h b/examples/fabric-bridge-app/linux/include/RpcClient.h index 73f7d58bab3ddc..292e31b3b6ee3e 100644 --- a/examples/fabric-bridge-app/linux/include/RpcClient.h +++ b/examples/fabric-bridge-app/linux/include/RpcClient.h @@ -57,4 +57,4 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowPasscodeParams para CHIP_ERROR OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams params); -CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration); \ No newline at end of file +CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration); From 8f9d6be360a53c5c2f4f2cfbc6d82fa4d1c8840b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 7 Aug 2024 20:25:37 +0000 Subject: [PATCH 05/10] Restyled by clang-format --- examples/fabric-admin/rpc/RpcClient.cpp | 2 +- .../fabric-bridge-common/src/BridgedDevice.cpp | 11 ++++++----- examples/fabric-bridge-app/linux/RpcClient.cpp | 2 +- examples/fabric-bridge-app/linux/RpcServer.cpp | 5 +++-- examples/fabric-bridge-app/linux/main.cpp | 3 ++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index 3dcea2d7e1dc03..cc1284b2cf2b68 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -175,7 +175,7 @@ CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration) ChipLogProgress(NotSpecified, "ActiveChanged"); chip_rpc_KeepActiveChanged parameters; - parameters.node_id = nodeId; + parameters.node_id = nodeId; parameters.promised_active_duration = promisedActiveDuration; // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp index 3b246442041e4f..63787ed15725df 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp @@ -26,14 +26,15 @@ namespace { -struct ActiveChangeEventWorkData { +struct ActiveChangeEventWorkData +{ chip::EndpointId mEndpointId; uint32_t mPromisedActiveDuration; }; static void ActiveChangeEventWork(intptr_t arg) { - ActiveChangeEventWorkData* data = reinterpret_cast(arg); + ActiveChangeEventWorkData * data = reinterpret_cast(arg); chip::app::Clusters::BridgedDeviceBasicInformation::Events::ActiveChanged::Type event{}; event.promisedActiveDuration = data->mPromisedActiveDuration; @@ -61,9 +62,9 @@ BridgedDevice::BridgedDevice(chip::NodeId nodeId) void BridgedDevice::LogActiveChangeEvent(uint32_t promisedActiveDuration) { - ActiveChangeEventWorkData* workdata = chip::Platform::New(); - workdata->mEndpointId = mEndpointId; - workdata->mPromisedActiveDuration = promisedActiveDuration; + ActiveChangeEventWorkData * workdata = chip::Platform::New(); + workdata->mEndpointId = mEndpointId; + workdata->mPromisedActiveDuration = promisedActiveDuration; chip::DeviceLayer::PlatformMgr().ScheduleWork(ActiveChangeEventWork, reinterpret_cast(workdata)); } diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index adfa29dbaac504..a5aff108e198e9 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -165,7 +165,7 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams para CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration) { chip_rpc_KeepActiveParameters params; - params.node_id = nodeId; + params.node_id = nodeId; params.stay_active_duration = stayActiveDuration; // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index 30aecd0fb9fd10..58a8e886a493e0 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -86,10 +86,11 @@ pw::Status FabricBridge::ActiveChanged(const chip_rpc_KeepActiveChanged & reques NodeId nodeId = request.node_id; ChipLogProgress(NotSpecified, "Received ActiveChanged: " ChipLogFormatX64, ChipLogValueX64(nodeId)); - auto* device = BridgeDeviceMgr().GetDeviceByNodeId(nodeId); + auto * device = BridgeDeviceMgr().GetDeviceByNodeId(nodeId); if (device == nullptr) { - ChipLogError(NotSpecified, "Could not find bridged device associated with nodeId=0x" ChipLogFormatX64, ChipLogValueX64(nodeId)); + ChipLogError(NotSpecified, "Could not find bridged device associated with nodeId=0x" ChipLogFormatX64, + ChipLogValueX64(nodeId)); return pw::Status::NotFound(); } diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index d670eea627ae54..9b4667b8deaf75 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -126,7 +126,8 @@ void AdministratorCommissioningCommandHandler::InvokeCommand(HandlerContext & ha EndpointId endpointId = handlerContext.mRequestPath.mEndpointId; ChipLogProgress(NotSpecified, "Received command to open commissioning window on Endpoint: %d", endpointId); - if (handlerContext.mRequestPath.mCommandId != AdministratorCommissioning::Commands::OpenCommissioningWindow::Id || endpointId == kRootEndpointId) + if (handlerContext.mRequestPath.mCommandId != AdministratorCommissioning::Commands::OpenCommissioningWindow::Id || + endpointId == kRootEndpointId) { // Proceed with default handling in Administrator Commissioning Server return; From dd94a5ec16911cb0399f62698553e1a32f44c177 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 7 Aug 2024 20:33:50 +0000 Subject: [PATCH 06/10] Remove spaces at the end of the line:wq --- examples/common/pigweed/protos/fabric_bridge_service.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/common/pigweed/protos/fabric_bridge_service.proto b/examples/common/pigweed/protos/fabric_bridge_service.proto index bb81442ce36799..1b573deb4c7b70 100644 --- a/examples/common/pigweed/protos/fabric_bridge_service.proto +++ b/examples/common/pigweed/protos/fabric_bridge_service.proto @@ -16,6 +16,6 @@ message KeepActiveChanged { service FabricBridge { rpc AddSynchronizedDevice(SynchronizedDevice) returns (pw.protobuf.Empty){} - rpc RemoveSynchronizedDevice(SynchronizedDevice) returns (pw.protobuf.Empty){} - rpc ActiveChanged(KeepActiveChanged) returns (pw.protobuf.Empty){} + rpc RemoveSynchronizedDevice(SynchronizedDevice) returns (pw.protobuf.Empty){} + rpc ActiveChanged(KeepActiveChanged) returns (pw.protobuf.Empty){} } From 2d88a17365cce6abcd573f7b8fd0cb6cbfedf00f Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 7 Aug 2024 21:25:23 +0000 Subject: [PATCH 07/10] Self-review fixes --- examples/fabric-admin/rpc/RpcClient.cpp | 4 ++-- .../fabric-bridge-common/src/BridgedDevice.cpp | 1 - examples/fabric-bridge-app/linux/RpcClient.cpp | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index cc1284b2cf2b68..a61a79cffffa28 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -105,7 +105,7 @@ void OnRemoveDeviceResponseCompleted(const pw_protobuf_Empty & response, pw::Sta } } -void GenericResponseCompletedWithNoParameters(const pw_protobuf_Empty & response, pw::Status status) +void RpcCompletedWithEmptyResponse(const pw_protobuf_Empty & response, pw::Status status) { std::lock_guard lock(responseMutex); responseReceived = true; @@ -180,7 +180,7 @@ CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration) // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler // function and the call will complete. - auto call = fabricBridgeClient.ActiveChanged(parameters, GenericResponseCompletedWithNoParameters); + auto call = fabricBridgeClient.ActiveChanged(parameters, RpcCompletedWithEmptyResponse); if (!call.active()) { diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp index 63787ed15725df..9d6a1b3c77eb13 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp @@ -40,7 +40,6 @@ static void ActiveChangeEventWork(intptr_t arg) event.promisedActiveDuration = data->mPromisedActiveDuration; chip::EventNumber eventNumber = 0; - // TODO DNS this is not called from Matter event loop so it will crash CHIP_ERROR err = chip::app::LogEvent(event, data->mEndpointId, eventNumber); if (err != CHIP_NO_ERROR) { diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index a5aff108e198e9..970400ae0a80e1 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -88,7 +88,7 @@ void OnOpenCommissioningWindowCompleted(const chip_rpc_OperationStatus & respons } // Callback function to be called when the RPC response is received for generic empty response. -void GenericRpcCompletedWithPwStatus(const pw_protobuf_Empty & response, pw::Status status) +void RpcCompletedWithEmptyResponse(const pw_protobuf_Empty & response, pw::Status status) { std::lock_guard lock(responseMutex); responseReceived = true; @@ -170,7 +170,7 @@ CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration) // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler // function and the call will complete. - auto call = fabricAdminClient.KeepActive(params, GenericRpcCompletedWithPwStatus); + auto call = fabricAdminClient.KeepActive(params, RpcCompletedWithEmptyResponse); if (!call.active()) { From bd12b004c67302a8c90217fd40e9c92ff2e32471 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 8 Aug 2024 02:25:03 +0000 Subject: [PATCH 08/10] Fix merge conflict compiler issues --- examples/fabric-bridge-app/linux/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index b34fda4c2b79e3..1678ec59a81a1d 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -244,7 +244,7 @@ void ApplicationInit() MatterEcosystemInformationPluginServerInitCallback(); CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&gAdministratorCommissioningCommandHandler); - CommandHandlerInterfaceRegistry::RegisterCommandHandler(&gBridgedDeviceInformationCommandHandler); + CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&gBridgedDeviceInformationCommandHandler); AttributeAccessInterfaceRegistry::Instance().Register(&gBridgedDeviceBasicInformationAttributes); #if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE From ef8ac0ce3fe0d39f67214608a339b31509fce0bb Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 8 Aug 2024 13:37:23 +0000 Subject: [PATCH 09/10] Address PR comments --- examples/common/pigweed/protos/fabric_admin_service.proto | 2 +- examples/common/pigweed/protos/fabric_bridge_service.proto | 2 +- examples/fabric-admin/rpc/RpcClient.cpp | 4 ++-- examples/fabric-admin/rpc/RpcClient.h | 4 ++-- examples/fabric-admin/rpc/RpcServer.cpp | 4 ++-- .../fabric-bridge-common/include/BridgedDevice.h | 2 +- .../fabric-bridge-common/src/BridgedDevice.cpp | 4 ++-- examples/fabric-bridge-app/linux/RpcClient.cpp | 4 ++-- examples/fabric-bridge-app/linux/RpcServer.cpp | 2 +- examples/fabric-bridge-app/linux/include/RpcClient.h | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/common/pigweed/protos/fabric_admin_service.proto b/examples/common/pigweed/protos/fabric_admin_service.proto index 382da4b71393e3..b2c81d5ee0eaae 100644 --- a/examples/common/pigweed/protos/fabric_admin_service.proto +++ b/examples/common/pigweed/protos/fabric_admin_service.proto @@ -16,7 +16,7 @@ message DeviceCommissioningWindowInfo { message KeepActiveParameters { uint64 node_id = 1; - uint32 stay_active_duration = 2; + uint32 stay_active_duration_ms = 2; } // Define the response message to convey the status of the operation diff --git a/examples/common/pigweed/protos/fabric_bridge_service.proto b/examples/common/pigweed/protos/fabric_bridge_service.proto index 9933b495dc0702..82837e0b684ee7 100644 --- a/examples/common/pigweed/protos/fabric_bridge_service.proto +++ b/examples/common/pigweed/protos/fabric_bridge_service.proto @@ -22,7 +22,7 @@ message SynchronizedDevice { message KeepActiveChanged { uint64 node_id = 1; - uint32 promised_active_duration = 2; + uint32 promised_active_duration_ms = 2; } service FabricBridge { diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index 3f112764afaf1b..1fbd274891abea 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -198,13 +198,13 @@ CHIP_ERROR RemoveSynchronizedDevice(chip::NodeId nodeId) return WaitForResponse(call); } -CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration) +CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDurationMs) { ChipLogProgress(NotSpecified, "ActiveChanged"); chip_rpc_KeepActiveChanged parameters; parameters.node_id = nodeId; - parameters.promised_active_duration = promisedActiveDuration; + parameters.promised_active_duration_ms = promisedActiveDurationMs; // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler // function and the call will complete. diff --git a/examples/fabric-admin/rpc/RpcClient.h b/examples/fabric-admin/rpc/RpcClient.h index aab17511a3f2fe..2e54a9fc383abb 100644 --- a/examples/fabric-admin/rpc/RpcClient.h +++ b/examples/fabric-admin/rpc/RpcClient.h @@ -66,10 +66,10 @@ CHIP_ERROR RemoveSynchronizedDevice(chip::NodeId nodeId); * @brief Received StayActiveResponse on behalf of client that previously called KeepActive * * @param nodeId The Node ID of the device we recieved a StayActiveResponse. - * @param promisedActiveDuration the computed duration (in milliseconds) that the ICD intends to stay active for. + * @param promisedActiveDurationMs the computed duration (in milliseconds) that the ICD intends to stay active for. * @return CHIP_ERROR An error code indicating the success or failure of the operation. * - CHIP_NO_ERROR: The RPC command was successfully processed. * - CHIP_ERROR_BUSY: Another operation is currently in progress. * - CHIP_ERROR_INTERNAL: An internal error occurred while activating the RPC call. */ -CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDuration); +CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDurationMs); diff --git a/examples/fabric-admin/rpc/RpcServer.cpp b/examples/fabric-admin/rpc/RpcServer.cpp index 24c0c5908a25a4..cb06b359d68a71 100644 --- a/examples/fabric-admin/rpc/RpcServer.cpp +++ b/examples/fabric-admin/rpc/RpcServer.cpp @@ -68,8 +68,8 @@ class FabricAdmin final : public rpc::FabricAdmin pw::Status KeepActive(const chip_rpc_KeepActiveParameters & request, pw_protobuf_Empty & response) override { - ChipLogProgress(NotSpecified, "Received KeepActive request: 0x%lx, %u", request.node_id, request.stay_active_duration); - // TODO(#33221): When we get this command hopefully we are already registers with an ICD device to be + ChipLogProgress(NotSpecified, "Received KeepActive request: 0x%lx, %u", request.node_id, request.stay_active_duration_ms); + // TODO(#33221): When we get this command hopefully we are already registered with an ICD device to be // notified when it wakes up. We will need to add in hooks there to make sure we send the StayActiveRequest // Important thing to note: // * If we get this call multiple times before we get a wakeup from ICD, we only send out one StayActiveRequest command diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h index 15735a04a4f521..a65ddb15a736f5 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h @@ -43,7 +43,7 @@ class BridgedDevice BridgedDevice(chip::NodeId nodeId); virtual ~BridgedDevice() = default; - void LogActiveChangeEvent(uint32_t promisedActiveDuration); + void LogActiveChangeEvent(uint32_t promisedActiveDurationMs); bool IsReachable(); bool IsIcd(); diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp index ead4f01e0c5228..a5e041b487d962 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp @@ -59,11 +59,11 @@ BridgedDevice::BridgedDevice(chip::NodeId nodeId) mEndpointId = chip::kInvalidEndpointId; } -void BridgedDevice::LogActiveChangeEvent(uint32_t promisedActiveDuration) +void BridgedDevice::LogActiveChangeEvent(uint32_t promisedActiveDurationMs) { ActiveChangeEventWorkData * workdata = chip::Platform::New(); workdata->mEndpointId = mEndpointId; - workdata->mPromisedActiveDuration = promisedActiveDuration; + workdata->mPromisedActiveDuration = promisedActiveDurationMs; chip::DeviceLayer::PlatformMgr().ScheduleWork(ActiveChangeEventWork, reinterpret_cast(workdata)); } diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index 970400ae0a80e1..aeac3276fba5c5 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -162,11 +162,11 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams para return OpenCommissioningWindow(device); } -CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration) +CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDurationMs) { chip_rpc_KeepActiveParameters params; params.node_id = nodeId; - params.stay_active_duration = stayActiveDuration; + params.stay_active_duration_ms = stayActiveDurationMs; // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler // function and the call will complete. diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index b1502302b51546..8838360ee7b1e7 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -152,7 +152,7 @@ pw::Status FabricBridge::ActiveChanged(const chip_rpc_KeepActiveChanged & reques return pw::Status::NotFound(); } - device->LogActiveChangeEvent(request.promised_active_duration); + device->LogActiveChangeEvent(request.promised_active_duration_ms); return pw::OkStatus(); } diff --git a/examples/fabric-bridge-app/linux/include/RpcClient.h b/examples/fabric-bridge-app/linux/include/RpcClient.h index 292e31b3b6ee3e..6913a66d8c24a1 100644 --- a/examples/fabric-bridge-app/linux/include/RpcClient.h +++ b/examples/fabric-bridge-app/linux/include/RpcClient.h @@ -57,4 +57,4 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowPasscodeParams para CHIP_ERROR OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams params); -CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDuration); +CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDurationMs); From 19b7ba2c0a4ff4f0aa9dff9f73c09ee58011f2b6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 8 Aug 2024 13:37:46 +0000 Subject: [PATCH 10/10] Restyled by clang-format --- examples/fabric-admin/rpc/RpcClient.cpp | 2 +- examples/fabric-bridge-app/linux/RpcClient.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index 1fbd274891abea..3c01b7268df8f8 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -203,7 +203,7 @@ CHIP_ERROR ActiveChanged(chip::NodeId nodeId, uint32_t promisedActiveDurationMs) ChipLogProgress(NotSpecified, "ActiveChanged"); chip_rpc_KeepActiveChanged parameters; - parameters.node_id = nodeId; + parameters.node_id = nodeId; parameters.promised_active_duration_ms = promisedActiveDurationMs; // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp index aeac3276fba5c5..1260c8744b67f2 100644 --- a/examples/fabric-bridge-app/linux/RpcClient.cpp +++ b/examples/fabric-bridge-app/linux/RpcClient.cpp @@ -165,7 +165,7 @@ OpenCommissioningWindow(chip::Controller::CommissioningWindowVerifierParams para CHIP_ERROR KeepActive(chip::NodeId nodeId, uint32_t stayActiveDurationMs) { chip_rpc_KeepActiveParameters params; - params.node_id = nodeId; + params.node_id = nodeId; params.stay_active_duration_ms = stayActiveDurationMs; // The RPC call is kept alive until it completes. When a response is received, it will be logged by the handler