Skip to content

Commit

Permalink
Add tracing service to example/platform/esp rpc (#12966)
Browse files Browse the repository at this point in the history
* Add tracing service to example/platform/esp rpc

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 6, 2023
1 parent 9a86e64 commit 3515152
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ target_compile_options(${COMPONENT_LIB} PRIVATE
"-DPW_RPC_BUTTON_SERVICE=1"
"-DPW_RPC_DEVICE_SERVICE=1"
"-DPW_RPC_LIGHTING_SERVICE=1"
"-DPW_RPC_LOCKING_SERVICE=1")
"-DPW_RPC_LOCKING_SERVICE=1"
"-DPW_RPC_TRACING_SERVICE=1")

endif (CONFIG_ENABLE_PW_RPC)
25 changes: 25 additions & 0 deletions examples/platform/esp32/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@
#include "pigweed/rpc_services/Locking.h"
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE

#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
#include "pw_trace/trace.h"
#include "pw_trace_tokenized/trace_rpc_service_nanopb.h"

// Define trace time for pw_trace
PW_TRACE_TIME_TYPE pw_trace_GetTraceTime()
{
return (PW_TRACE_TIME_TYPE) chip::System::SystemClock().GetMonotonicMicroseconds64().count();
}
// Microsecond time source
size_t pw_trace_GetTraceTimeTicksPerSecond()
{
return 1000000;
}

#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE

namespace chip {
namespace rpc {

Expand Down Expand Up @@ -122,6 +139,10 @@ Lighting lighting_service;
Locking locking;
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE

#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
pw::trace::TraceService trace_service;
#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE

void RegisterServices(pw::rpc::Server & server)
{
#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE
Expand All @@ -143,6 +164,10 @@ void RegisterServices(pw::rpc::Server & server)
#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE
server.RegisterService(locking);
#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE

#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
server.RegisterService(trace_service);
#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE
}

} // namespace
Expand Down

0 comments on commit 3515152

Please sign in to comment.