Skip to content

Commit 8480b14

Browse files
committed
Support write events as string through RPC
1 parent 3252a78 commit 8480b14

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

examples/common/pigweed/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pw_proto_library("button_service") {
7474

7575
pw_proto_library("event_service") {
7676
sources = [ "protos/event_service.proto" ]
77+
inputs = [ "protos/event_service.options" ]
7778
deps = [ "$dir_pw_protobuf:common_protos" ]
7879
strip_prefix = "protos"
7980
prefix = "event_service"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chip.rpc.EventSetRequest.event_payload max_size:2048 // max event size

examples/common/pigweed/protos/event_service.proto

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
syntax = "proto3";
22

3-
import 'pw_protobuf_protos/common.proto';
4-
53
package chip.rpc;
64

5+
import 'pw_protobuf_protos/common.proto';
6+
77
message EventSetRequest {
88
uint32 endpoint_id = 1;
99
uint32 cluster_id = 2;
10-
uint32 event_id = 3;
11-
std::string event_payload = 4;
10+
string event_payload = 3; //
1211
}
1312

1413
message EventSetResponse {

examples/common/pigweed/rpc_services/Event.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ namespace rpc {
3131
class Event final : public pw_rpc::nanopb::Event::Service<Event>
3232
{
3333
public:
34-
virtual ~Event() = default;
35-
36-
virtual pw::Status Set(const chip_rpc_EventSetRequest & request, chip_rpc_EventSetResponse & response)
34+
::pw::Status Set( const ::chip_rpc_EventSetRequest& request, ::chip_rpc_EventSetResponse& response)
3735
{
3836
EndpointId endpointId = request.endpoint_id;
3937
uint8_t newPosition = 1 ; // to be parsed from request.event_payload
4038

39+
printf("\033[41m %s, %d, request.event_playload=%s \033[0m \n", __func__, __LINE__, request.event_payload);
4140
EventNumber eventNumber;
4241
{
4342
DeviceLayer::StackLock lock;
@@ -53,18 +52,18 @@ class Event final : public pw_rpc::nanopb::Event::Service<Event>
5352
return pw::OkStatus();
5453
}
5554

56-
virtual pw::Status Get(const chip_rpc_EventGetRequest & request, chip_rpc_EventGetResponse & response)
55+
::pw::Status Get( const ::chip_rpc_EventGetRequest& request, ::chip_rpc_EventGetResponse& response)
5756
{
5857
EndpointId endpointId = request.endpoint_id;
59-
uint32 event_id = 1; // TBD
58+
// uint32_t event_id = 1; // TBD
6059

6160
{
6261
DeviceLayer::StackLock lock;
6362
// TBD: Get latest event number
6463
// RETURN_STATUS_IF_NOT_OK(app::Clusters::Switch::Attributes::StateValue::Get(endpointId, &state_value));
6564
}
6665

67-
response.state.event_id = event_id;
66+
response.event_id = endpointId;
6867
return pw::OkStatus();
6968
}
7069
};

examples/platform/linux/Rpc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Device device_service;
8989
#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE
9090

9191
#if defined(PW_RPC_EVENT_SERVICE) && PW_RPC_EVENT_SERVICE
92-
BooleanState event_service;
92+
Event event_service;
9393
#endif // defined(PW_RPC_EVENT_SERVICE) && PW_RPC_EVENT_SERVICE
9494

9595
#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE

0 commit comments

Comments
 (0)