-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the RPC support between Fabric_Admin and Fabric_Bridge
- Loading branch information
1 parent
896f802
commit d046d91
Showing
25 changed files
with
1,067 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
|
||
import 'pw_protobuf_protos/common.proto'; | ||
|
||
package chip.rpc; | ||
|
||
// Define the message for a synchronized end device with necessary fields | ||
message DeviceInfo { | ||
uint64 node_id = 1; | ||
} | ||
|
||
// Define the response message to convey the status of the operation | ||
message OperationStatus { | ||
bool success = 1; | ||
} | ||
|
||
service FabricAdmin { | ||
rpc OpenCommissioningWindow(DeviceInfo) returns (OperationStatus){} | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
examples/common/pigweed/protos/fabric_bridge_service.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
|
||
import 'pw_protobuf_protos/common.proto'; | ||
|
||
package chip.rpc; | ||
|
||
// Define the message for a synchronized end device with necessary fields | ||
message SynchronizedDevice { | ||
uint64 node_id = 1; | ||
} | ||
|
||
service FabricBridge { | ||
rpc AddSynchronizedDevice(SynchronizedDevice) returns (pw.protobuf.Empty){} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "app/util/attribute-storage.h" | ||
#include "fabric_admin_service/fabric_admin_service.rpc.pb.h" | ||
#include "pigweed/rpc_services/internal/StatusUtils.h" | ||
#include <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <app-common/zap-generated/ids/Clusters.h> | ||
#include <platform/PlatformManager.h> | ||
|
||
namespace chip { | ||
namespace rpc { | ||
|
||
class FabricAdmin : public pw_rpc::nanopb::FabricAdmin::Service<FabricAdmin> | ||
{ | ||
public: | ||
virtual ~FabricAdmin() = default; | ||
|
||
virtual pw::Status OpenCommissioningWindow(const chip_rpc_DeviceInfo & request, chip_rpc_OperationStatus & response) | ||
{ | ||
return pw::Status::Unimplemented(); | ||
} | ||
}; | ||
|
||
} // namespace rpc | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "app/util/attribute-storage.h" | ||
#include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h" | ||
#include "pigweed/rpc_services/internal/StatusUtils.h" | ||
#include <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <app-common/zap-generated/ids/Clusters.h> | ||
#include <platform/PlatformManager.h> | ||
|
||
namespace chip { | ||
namespace rpc { | ||
|
||
class FabricBridge : public pw_rpc::nanopb::FabricBridge::Service<FabricBridge> | ||
{ | ||
public: | ||
virtual ~FabricBridge() = default; | ||
|
||
virtual pw::Status AddSynchronizedDevice(const chip_rpc_SynchronizedDevice & request, pw_protobuf_Empty & response) | ||
{ | ||
return pw::Status::Unimplemented(); | ||
} | ||
}; | ||
|
||
} // namespace rpc | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <commands/common/Commands.h> | ||
#include <commands/fabric-sync/FabricSyncCommand.h> | ||
|
||
void registerCommandsFabricSync(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) | ||
{ | ||
const char * clusterName = "FabricSync"; | ||
|
||
commands_list clusterCommands = { | ||
make_unique<FabricSyncAddDeviceCommand>(credsIssuerConfig), | ||
}; | ||
|
||
commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for fabric synchronization."); | ||
} |
45 changes: 45 additions & 0 deletions
45
examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include "FabricSyncCommand.h" | ||
#include <commands/common/RemoteDataModelLogger.h> | ||
#include <thread> | ||
#include <unistd.h> | ||
|
||
#if defined(PW_RPC_ENABLED) | ||
#include "pw_assert/check.h" | ||
#include "pw_hdlc/decoder.h" | ||
#include "pw_hdlc/default_addresses.h" | ||
#include "pw_hdlc/rpc_channel.h" | ||
#include "pw_rpc/client.h" | ||
#include "pw_stream/socket_stream.h" | ||
|
||
#include <rpc/RpcClient.h> | ||
#endif | ||
|
||
using namespace ::chip; | ||
|
||
CHIP_ERROR FabricSyncAddDeviceCommand::RunCommand(NodeId remoteId) | ||
{ | ||
#if defined(PW_RPC_ENABLED) | ||
AddSynchronizedDevice(remoteId); | ||
return CHIP_NO_ERROR; | ||
#else | ||
return CHIP_ERROR_NOT_IMPLEMENTED; | ||
#endif | ||
} |
40 changes: 40 additions & 0 deletions
40
examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <commands/common/CHIPCommand.h> | ||
|
||
class FabricSyncAddDeviceCommand : public CHIPCommand | ||
{ | ||
public: | ||
FabricSyncAddDeviceCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("add-device", credIssuerCommands) | ||
{ | ||
AddArgument("nodeid", 0, UINT64_MAX, &mNodeId); | ||
} | ||
|
||
/////////// CHIPCommand Interface ///////// | ||
CHIP_ERROR RunCommand() override { return RunCommand(mNodeId); } | ||
|
||
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(30); } | ||
|
||
private: | ||
chip::NodeId mNodeId; | ||
|
||
CHIP_ERROR RunCommand(NodeId remoteId); | ||
}; |
Oops, something went wrong.