Skip to content

Commit

Permalink
RPC: Add RPCs to EFR lock app
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Oliver committed Nov 23, 2021
1 parent 9d95d08 commit 6cc4912
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
45 changes: 45 additions & 0 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
}

assert(current_os == "freertos")

efr32_project_dir = "${chip_root}/examples/lock-app/efr32"
Expand Down Expand Up @@ -59,6 +65,10 @@ efr32_sdk("sdk") {
"BOARD_ID=${efr32_board}",
"CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
]

if (chip_enable_pw_rpc) {
defines += [ "HAL_VCOM_ENABLE=1" ]
}
}

efr32_executable("lock_app") {
Expand Down Expand Up @@ -97,6 +107,41 @@ efr32_executable("lock_app") {
defines += [ "DISPLAY_ENABLED" ]
}

if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ENABLED",
"PW_RPC_ATTRIBUTE_SERVICE=1",
"PW_RPC_BUTTON_SERVICE=1",
"PW_RPC_DEVICE_SERVICE=1",
"PW_RPC_LOCKING_SERVICE=1",
]

sources += [
"${chip_root}/examples/common/pigweed/RpcService.cpp",
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp",
"${examples_plat_dir}/PigweedLogger.cpp",
"${examples_plat_dir}/Rpc.cpp",
]

deps += [
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_stream:sys_io_stream",
"${chip_root}/config/efr32/lib/pw_rpc:pw_rpc",
"${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:locking_service.nanopb_rpc",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32",
]

deps += pw_build_LINK_DEPS

include_dirs += [
"${chip_root}/examples/common",
"${chip_root}/examples/common/pigweed/efr32",
]
}

if (enable_heap_monitoring) {
defines += [ "HEAP_MONITORING" ]
sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
Expand Down
8 changes: 8 additions & 0 deletions examples/lock-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#include "lcd.h"
#endif

#if PW_RPC_ENABLED
#include "Rpc.h"
#endif

#if CHIP_ENABLE_OPENTHREAD
#include <mbedtls/platform.h>
#include <openthread/cli.h>
Expand Down Expand Up @@ -104,6 +108,10 @@ int main(void)
init_efrPlatform();
mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);

#if PW_RPC_ENABLED
chip::rpc::Init();
#endif

EFR32_LOG("==================================================");
EFR32_LOG("chip-efr32-lock-example starting");
EFR32_LOG("==================================================");
Expand Down
5 changes: 4 additions & 1 deletion examples/lock-app/efr32/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

import("//build_overrides/chip.gni")
import("${chip_root}/config/efr32/lib/pw_rpc/pw_rpc.gni")
import("${chip_root}/src/platform/EFR32/args.gni")
import("${chip_root}/examples/platform/efr32/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_pw_rpc = true
chip_enable_openthread = true

cpp_standard = "gnu++17"
2 changes: 1 addition & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def Efr32Targets():
board=Efr32Board.BRD4161A)

yield efr_target.Extend('window-covering', app=Efr32App.WINDOW_COVERING)
yield efr_target.Extend('lock', app=Efr32App.LOCK)
yield efr_target.Extend('unit-test', app=Efr32App.UNIT_TEST)

rpc_aware_targets = [
efr_target.Extend('light', app=Efr32App.LIGHT),
efr_target.Extend('lock', app=Efr32App.LOCK)
]

for target in rpc_aware_targets:
Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/all_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android-x86-chip-tool
efr32-brd4161a-light
efr32-brd4161a-light-rpc
efr32-brd4161a-lock
efr32-brd4161a-lock-rpc
efr32-brd4161a-unit-test
efr32-brd4161a-window-covering
esp32-c3devkit-all-clusters
Expand Down
6 changes: 6 additions & 0 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 '
# Generating efr32-brd4161a-lock
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock

# Generating efr32-brd4161a-lock-rpc
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A" import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-lock-rpc

# Generating efr32-brd4161a-unit-test
gn gen --check --fail-on-unused-args --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-unit-test

Expand Down Expand Up @@ -587,6 +590,9 @@ ninja -C {out}/efr32-brd4161a-light-rpc
# Building efr32-brd4161a-lock
ninja -C {out}/efr32-brd4161a-lock

# Building efr32-brd4161a-lock-rpc
ninja -C {out}/efr32-brd4161a-lock-rpc

# Building efr32-brd4161a-unit-test
ninja -C {out}/efr32-brd4161a-unit-test

Expand Down
1 change: 1 addition & 0 deletions scripts/build/testdata/glob_star_targets_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android-x86-chip-tool
efr32-brd4161a-light
efr32-brd4161a-light-rpc
efr32-brd4161a-lock
efr32-brd4161a-lock-rpc
efr32-brd4161a-unit-test
efr32-brd4161a-window-covering
esp32-c3devkit-all-clusters
Expand Down

0 comments on commit 6cc4912

Please sign in to comment.