Skip to content

Commit

Permalink
Enable RPC trace service in nrfconnect lighting app (#13045)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyzhong-g authored and pull[bot] committed Aug 21, 2023
1 parent 22df336 commit 1050944
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
13 changes: 12 additions & 1 deletion examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions examples/platform/nrfconnect/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1050944

Please sign in to comment.