diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 95cb6d03a915bd..b5de67cf049a05 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -106,6 +106,7 @@ include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) pw_set_backend(pw_log pw_log_basic) pw_set_backend(pw_assert pw_assert_log) pw_set_backend(pw_sys_io pw_sys_io.nrfconnect) +pw_set_backend(pw_trace pw_trace_tokenized) set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE) add_subdirectory(third_party/connectedhomeip/examples/platform/nrfconnect/pw_sys_io) @@ -180,7 +181,8 @@ target_compile_options(app PRIVATE "-DPW_RPC_ATTRIBUTE_SERVICE=1" "-DPW_RPC_BUTTON_SERVICE=1" "-DPW_RPC_DEVICE_SERVICE=1" - "-DPW_RPC_LIGHTING_SERVICE=1") + "-DPW_RPC_LIGHTING_SERVICE=1" + "-DPW_RPC_TRACING_SERVICE=1") target_link_libraries(app PRIVATE attributes_service.nanopb_rpc @@ -191,6 +193,15 @@ target_link_libraries(app PRIVATE pw_hdlc pw_log pw_rpc.server + pw_trace_tokenized + pw_trace_tokenized.trace_buffer + pw_trace_tokenized.rpc_service + pw_trace_tokenized.protos.nanopb_rpc +) + +target_link_options(app + PUBLIC + "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" ) target_link_libraries(pw_build INTERFACE zephyr_interface) diff --git a/examples/platform/nrfconnect/Rpc.cpp b/examples/platform/nrfconnect/Rpc.cpp index 89af172327e4fc..580c925d883465 100644 --- a/examples/platform/nrfconnect/Rpc.cpp +++ b/examples/platform/nrfconnect/Rpc.cpp @@ -45,6 +45,23 @@ LOG_MODULE_DECLARE(app); #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 { @@ -110,6 +127,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 @@ -131,6 +152,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