Skip to content

Commit 1825508

Browse files
yyzhong-grestyled-commits
authored andcommitted
Add tracing service to example/platform/esp rpc (#12386)
* Add tracing service to example/platform/esp rpc * Restyled by clang-format Co-authored-by: Restyled.io <[email protected]>
1 parent b304f7c commit 1825508

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

examples/all-clusters-app/esp32/main/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ target_compile_options(${COMPONENT_LIB} PRIVATE
225225
"-DPW_RPC_BUTTON_SERVICE=1"
226226
"-DPW_RPC_DEVICE_SERVICE=1"
227227
"-DPW_RPC_LIGHTING_SERVICE=1"
228-
"-DPW_RPC_LOCKING_SERVICE=1")
228+
"-DPW_RPC_LOCKING_SERVICE=1"
229+
"-DPW_RPC_TRACING_SERVICE=1")
229230

230231
endif (CONFIG_ENABLE_PW_RPC)

examples/platform/esp32/Rpc.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@
5252
#include "pigweed/rpc_services/Locking.h"
5353
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE
5454

55+
#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
56+
#include "pw_trace/trace.h"
57+
#include "pw_trace_tokenized/trace_rpc_service_nanopb.h"
58+
59+
// Define trace time for pw_trace
60+
PW_TRACE_TIME_TYPE pw_trace_GetTraceTime()
61+
{
62+
return (PW_TRACE_TIME_TYPE) chip::System::SystemClock().GetMonotonicMicroseconds64().count();
63+
}
64+
// Microsecond time source
65+
size_t pw_trace_GetTraceTimeTicksPerSecond()
66+
{
67+
return 1000000;
68+
}
69+
70+
#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
71+
5572
namespace chip {
5673
namespace rpc {
5774

@@ -122,6 +139,10 @@ Lighting lighting_service;
122139
Locking locking;
123140
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE
124141

142+
#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
143+
pw::trace::TraceService trace_service;
144+
#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
145+
125146
void RegisterServices(pw::rpc::Server & server)
126147
{
127148
#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE
@@ -143,6 +164,10 @@ void RegisterServices(pw::rpc::Server & server)
143164
#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE
144165
server.RegisterService(locking);
145166
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE
167+
168+
#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
169+
server.RegisterService(trace_service);
170+
#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
146171
}
147172

148173
} // namespace

0 commit comments

Comments
 (0)