Skip to content

Commit

Permalink
Add pw_trace functionality to esp32 all cluster app (#11203)
Browse files Browse the repository at this point in the history
Add pw_trace rpc service to Rpc.cpp.
  • Loading branch information
yyzhong-g authored and pull[bot] committed Jun 10, 2022
1 parent 6af0c92 commit 3055685
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ include(third_party/connectedhomeip/third_party/pigweed/repo/pw_build/pigweed.cm
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.esp32)
pw_set_backend(pw_trace pw_trace_tokenized)

add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo)
add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo)
Expand Down
4 changes: 4 additions & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
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
)

set_property(TARGET ${chip_lib} APPEND PROPERTY LINK_LIBRARIES ${COMPONENT_LIB})
Expand Down
16 changes: 16 additions & 0 deletions examples/all-clusters-app/esp32/main/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,27 @@
#include "pw_containers/flat_map.h"
#include "pw_status/status.h"
#include "pw_status/try.h"
#include "pw_trace_tokenized/trace_rpc_service_nanopb.h"
#include "wifi_service/wifi_service.rpc.pb.h"
#include <pw_trace/trace.h>

#include "WiFiProvisioning.h"

#include "ESP32Utils.h"

static const char * TAG = "RPC";

// 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;
}

namespace chip {
namespace rpc {
namespace {
Expand Down Expand Up @@ -291,13 +304,16 @@ Esp32Button button_service;
Esp32Device device_service;
Lighting lighting_service;
Wifi wifi_service;
pw::trace::TraceService trace_service;

void RegisterServices(pw::rpc::Server & server)
{
server.RegisterService(button_service);
server.RegisterService(device_service);
server.RegisterService(lighting_service);
server.RegisterService(wifi_service);
server.RegisterService(trace_service);
PW_TRACE_SET_ENABLED(true);
}

void RunRpcService(void *)
Expand Down

0 comments on commit 3055685

Please sign in to comment.