Skip to content

Commit

Permalink
Fix and clean up examples/lighting-app/efr32 RPC build
Browse files Browse the repository at this point in the history
- Remove all of the duplicate include_dirs that were needed due
  to missing dependencies & improper use of private deps.
- Add back an retargetserial.c file which is needed for this build. It
  was removed in fc59bd2 ("[3rd-party] update openthread and
  ot-br-posix (project-chip#5062)")
- Define the pigweed_lighting debug API in a common place. This
  means we need to move the enable_pw_rpc to that place, too.
- Add missing bits to CHIPProjectConfig.h needed after c99bef7
  ("[EFR32] BLE Advertissement fixes and change default pin code
  (project-chip#5503)")

Tested via
  gn gen out/with_pw_rpc --args='import("//with_pw_rpc.gni")'
  ninja -C out/with_pw_rpc

Note it is still broken due to OpenThread serial conflict.

Clean up and add comments for the uart api
remap OT uart functions to use our uart api.
  • Loading branch information
mspang authored and jmartinez-silabs committed Mar 26, 2021
1 parent abb5a72 commit cd7a4ef
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 79 deletions.
37 changes: 6 additions & 31 deletions examples/lighting-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")

import("$dir_pw_protobuf_compiler/proto.gni")
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/lighting-app/lighting-common/lighting.gni")

assert(current_os == "freertos")

efr32_project_dir = "${chip_root}/examples/lighting-app/efr32"
Expand All @@ -30,7 +31,6 @@ examples_plat_dir = "${chip_root}/examples/platform/efr32"
declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
enable_pw_rpc = false
setupPinCode = 73141520
}

Expand Down Expand Up @@ -67,13 +67,6 @@ efr32_sdk("sdk") {
}
}

if (enable_pw_rpc) {
pw_proto_library("pw_light_service_proto") {
sources = [ "${chip_root}/examples/lighting-app/lighting-common/pigweed_lighting.proto" ]
inputs = [ "${chip_root}/examples/lighting-app/lighting-common/pigweed_lighting.options" ]
}
}

efr32_executable("lighting_app") {
include_dirs = []
defines = []
Expand Down Expand Up @@ -103,6 +96,7 @@ efr32_executable("lighting_app") {
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/Service.cpp",
"${examples_plat_dir}/init_efrPlatform.cpp",
"${examples_plat_dir}/uart.c",
"src/AppTask.cpp",
"src/ButtonHandler.cpp",
"src/LightingManager.cpp",
Expand All @@ -118,43 +112,24 @@ efr32_executable("lighting_app") {

if (enable_pw_rpc) {
public_deps += [
":pw_light_service_proto.nanopb_rpc",
"$dir_pw_assert",
"$dir_pw_checksum",
"$dir_pw_stream",
"$dir_pw_sys_io",
"${chip_root}/config/efr32/lib/pw_rpc:pw_rpc",
"${chip_root}/examples/lighting-app/lighting-common:lighting_service.nanopb_rpc",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32",
]

include_dirs += [
"${examples_plat_dir}/pw_sys_io/public",
"${dir_pigweed}/pw_sys_io/public",
"${dir_pigweed}/pw_span/public_overrides",
"${dir_pigweed}/pw_span/public",
"${dir_pigweed}/pw_polyfill/public",
"${dir_pigweed}/pw_polyfill/standard_library_public",
"${dir_pigweed}/pw_polyfill/public_overrides",
"${dir_pigweed}/pw_status/public",
"${dir_pigweed}/pw_stream/public",
"${dir_pigweed}/pw_preprocessor/public",
"${dir_pigweed}/pw_rpc/public",
"${dir_pigweed}/pw_rpc/nanopb/public",
"${dir_pigweed}/pw_rpc/raw/public",
"${dir_pigweed}/pw_rpc/system_server/public",
"${dir_pigweed}/pw_protobuf/public",
"${dir_pigweed}/pw_result/public",
"${dir_pigweed}/pw_varint/public",
"${chip_root}/third_party/nanopb/repo",
"${chip_root}/src/lib/support",
"${chip_root}/examples/common",
"${chip_root}/examples/common/pigweed/efr32",
"out/debug/gen/pw_light_service_proto/third_party/connectedhomeip/examples/lighting-app/lighting-common",
]

sources += [
"${chip_root}/examples/common/pigweed/RpcService.cpp",
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp",
"${examples_plat_dir}/PigweedLogger.cpp",
"${examples_plat_dir}/uart.c",
"src/Rpc.cpp",
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ combination with JLinkRTTClient as follows:
the example by UART using the RPC LightingService. Call the following
command in your terminal
`python -m pw_hdlc.rpc_console --device /dev/tty.<SERIALDEVICE> -b 115200 /<CHIP_ROOT>/examples/lighting-app/lighting-common/pigweed_lighting.proto -o /<YourFolder>/pw_log.out`
`python -m pw_hdlc.rpc_console --device /dev/tty.<SERIALDEVICE> -b 115200 /<CHIP_ROOT>/examples/lighting-app/lighting-common//lighting_service/pigweed_lighting.proto -o /<YourFolder>/pw_log.out`
- Then you can simulate a button press or realease using the following command
where : idx = 0 or 1 for Button PB0 or PB1 action = 0 for PRESSED, 1 for
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/src/Rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "PigweedLoggerMutex.h"
#include "pigweed/RpcService.h"

#include "pigweed_lighting.rpc.pb.h"
#include "lighting_service/pigweed_lighting.rpc.pb.h"
#include "pw_hdlc/rpc_channel.h"
#include "pw_hdlc/rpc_packets.h"
#include "pw_rpc/server.h"
Expand Down
13 changes: 13 additions & 0 deletions examples/lighting-app/lighting-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,29 @@
# limitations under the License.

import("//build_overrides/chip.gni")
import("${chip_root}/examples/lighting-app/lighting-common/lighting.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/src/lib/core/core.gni")

if (enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_protobuf_compiler/proto.gni")
}

config("includes") {
include_dirs = [
".",
"include",
]
}

if (enable_pw_rpc) {
pw_proto_library("lighting_service") {
sources = [ "lighting_service/pigweed_lighting.proto" ]
inputs = [ "lighting_service/pigweed_lighting.options" ]
}
}

source_set("lighting-common") {
sources = [
"${chip_root}/src/app/clusters/bindings/bindings.cpp",
Expand Down
18 changes: 18 additions & 0 deletions examples/lighting-app/lighting-common/lighting.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

declare_args() {
# Enable Pigweed RPC integration.
enable_pw_rpc = false
}
1 change: 1 addition & 0 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ efr32_executable("lock_app") {
"${examples_plat_dir}/LEDWidget.cpp",
"${examples_plat_dir}/Service.cpp",
"${examples_plat_dir}/init_efrPlatform.cpp",
"${examples_plat_dir}/uart.c",
"src/AppTask.cpp",
"src/BoltLockManager.cpp",
"src/ButtonHandler.cpp",
Expand Down
1 change: 1 addition & 0 deletions examples/persistent-storage/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ efr32_executable("persistent_storage") {
sources = [
"${efr32_project_dir}/../KeyValueStorageTest.cpp",
"${examples_plat_dir}/init_efrPlatform.cpp",
"${examples_plat_dir}/uart.c",
"main.cpp",
]

Expand Down
1 change: 0 additions & 1 deletion examples/pigweed-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ efr32_sdk("sdk") {
sources = [
"${efr32_project_dir}/include/CHIPProjectConfig.h",
"${efr32_project_dir}/include/FreeRTOSConfig.h",
"${efr32_sdk_root}/hardware/kit/common/drivers/retargetserial.c",
]

defines = [
Expand Down
40 changes: 40 additions & 0 deletions examples/pigweed-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,43 @@
* A size, in bytes, of the individual debug event logging buffer.
*/
#define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)

/**
* CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL
*
* The interval (in units of 0.625ms) at which the device will send BLE advertisements while
* in fast advertising mode.
*
* 40 (25ms).
*/
#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL 40

/**
* CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL
*
* The interval (in units of 0.625ms) at which the device will send BLE advertisements while
* in slow advertisement mode.
*
* 800 (500ms).
*/
#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL 800

/**
* CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
*
* The amount of time in miliseconds after which BLE should change his advertisements
* from fast interval to slow interval.
*
* 30000 (30 secondes).
*/
#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT (30 * 1000)

/**
* CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT
*
* The amount of time in miliseconds after which BLE advertisement should be disabled, counting
* from the moment of slow advertisement commencement.
*
* Defaults to 9000000 (15 minutes).
*/
#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)
Loading

0 comments on commit cd7a4ef

Please sign in to comment.