Skip to content

Commit

Permalink
Chef - Extended Pigweed RPC support (project-chip#17781)
Browse files Browse the repository at this point in the history
* Build flash_script package for ESP32

Change-Id: I4e0375c9b9837b3b9f8a3d2570635536e7e34e42
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1419520
Reviewed-by: Doug Ferraz <[email protected]>

* new: Wifi and Descriptor clusters on ESP32

Change-Id: I37b61425a55d8210c2286becce47917fddf54a3f
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1418359
Reviewed-by: Rob Oliver <[email protected]>
Reviewed-by: Kevin Cheung <[email protected]>
Reviewed-by: Jerry Lee <[email protected]>

* new: added stub file. Included callbacks for successful operation of lock/unlock commands

Change-Id: I9f4d601feb3b043d3c6689775bcaf40a8c5564d2
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1420959
Reviewed-by: Michael Spang <[email protected]>
Reviewed-by: Jerry Lee <[email protected]>

* Enable PW RPC server on chef-built virtual device app

Change-Id: I878955e9df26e893c136650654019a8fa14e2a8b
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1417979
Reviewed-by: Doug Ferraz <[email protected]>

* cosmetic change

Change-Id: Ia2063a395a8d3f16965356d4a76b0d9df0834e57

* changes to linux pigweed dependencies. Still has issues building Pigweed

Change-Id: I2be4e81f6c2e14112e31a0803813ef56d012b206

* Fix nrfconnect compilation errors (project-chip#17713)

* Fix nrfconnect compilation errors

* Chef: fix arguments for clean build

* Build flash_script package for ESP32

Change-Id: I4e0375c9b9837b3b9f8a3d2570635536e7e34e42
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1419520
Reviewed-by: Doug Ferraz <[email protected]>

* new: Wifi and Descriptor clusters on ESP32

Change-Id: I37b61425a55d8210c2286becce47917fddf54a3f
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1418359
Reviewed-by: Rob Oliver <[email protected]>
Reviewed-by: Kevin Cheung <[email protected]>
Reviewed-by: Jerry Lee <[email protected]>

* new: added stub file. Included callbacks for successful operation of lock/unlock commands

Change-Id: I9f4d601feb3b043d3c6689775bcaf40a8c5564d2
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1420959
Reviewed-by: Michael Spang <[email protected]>
Reviewed-by: Jerry Lee <[email protected]>

* Enable PW RPC server on chef-built virtual device app

Change-Id: I878955e9df26e893c136650654019a8fa14e2a8b
Reviewed-on: https://team-review.git.corp.google.com/c/npe-tse-chip-sdk/third_party/connectedhomeip/+/1417979
Reviewed-by: Doug Ferraz <[email protected]>

* cosmetic change

Change-Id: Ia2063a395a8d3f16965356d4a76b0d9df0834e57

* changes to linux pigweed dependencies. Still has issues building Pigweed

Change-Id: I2be4e81f6c2e14112e31a0803813ef56d012b206

* Restyled by gn

* Restyled by autopep8

* Restyled by gn

Co-authored-by: Sebastian Mauer <[email protected]>
Co-authored-by: MT Tsai <[email protected]>
Co-authored-by: vinitg1 <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Change-Id: I827aa39ea41b8084d6fdca202e5a87e0f29cb4f3
  • Loading branch information
5 people authored and cpagravel committed May 10, 2022
1 parent 395375d commit 4aa3c1d
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 23 deletions.
13 changes: 12 additions & 1 deletion examples/chef/chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ def main(argv: Sequence[str]) -> None:
shell.run_cmd(f"rm -rf {_CHEF_SCRIPT_PATH}/esp32/build")
shell.run_cmd("idf.py fullclean")
shell.run_cmd("idf.py build")
shell.run_cmd("idf.py build flashing_script")
shell.run_cmd(
f"(cd build/ && tar cJvf $(git rev-parse HEAD)-{options.sample_device_type_name}.tar.xz --files-from=chip-shell.flashbundle.txt)")
shell.run_cmd(
f"cp build/$(git rev-parse HEAD)-{options.sample_device_type_name}.tar.xz {_CHEF_SCRIPT_PATH}")
elif options.build_target == "nrfconnect":
shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/nrfconnect")
if options.do_clean:
Expand All @@ -307,6 +312,8 @@ def main(argv: Sequence[str]) -> None:
import("//build_overrides/chip.gni")
import("\\${{chip_root}}/config/standalone/args.gni")
chip_shell_cmd_server = false
chip_build_libshell = true
chip_config_network_layer_ble = false
target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={'1' if options.doRPC else '0'}"]
"""))
with open(f"{_CHEF_SCRIPT_PATH}/linux/sample.gni", "w") as f:
Expand All @@ -316,7 +323,11 @@ def main(argv: Sequence[str]) -> None:
"""))
if options.do_clean:
shell.run_cmd(f"rm -rf out")
shell.run_cmd("gn gen out")
if options.do_rpc:
shell.run_cmd(
"gn gen out --args='import(\"//with_pw_rpc.gni\")'")
else:
shell.run_cmd("gn gen out --args=''")
shell.run_cmd("ninja -C out")

#
Expand Down
16 changes: 16 additions & 0 deletions examples/chef/common/stubs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app-common/zap-generated/command-id.h>

bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, chip::Optional<chip::ByteSpan> pinCode)
{
return true;
}

bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, chip::Optional<chip::ByteSpan> pinCode)
{
return true;
}
29 changes: 29 additions & 0 deletions examples/chef/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/../common"
)

if (CONFIG_ENABLE_CHIP_SHELL)
Expand Down Expand Up @@ -145,6 +146,17 @@ pw_proto_library(button_service
pw_protobuf.common_protos
)

pw_proto_library(descriptor_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto
PREFIX
descriptor_service
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
DEPS
pw_protobuf.common_protos
)

pw_proto_library(device_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/device_service.proto
Expand All @@ -158,9 +170,23 @@ pw_proto_library(device_service
pw_protobuf.common_protos
)

pw_proto_library(wifi_service
SOURCES
${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.proto
INPUTS
${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.options
PREFIX
wifi_service
DEPS
pw_protobuf.common_protos
STRIP_PREFIX
${CHIP_ROOT}/examples/common/pigweed/protos
)

target_link_libraries(${COMPONENT_LIB} PUBLIC
attributes_service.nanopb_rpc
button_service.nanopb_rpc
descriptor_service.nanopb_rpc
device_service.nanopb_rpc
pw_checksum
pw_hdlc
Expand All @@ -170,6 +196,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC
pw_trace_tokenized.trace_buffer
pw_trace_tokenized.rpc_service
pw_trace_tokenized.protos.nanopb_rpc
wifi_service.nanopb_rpc
)

target_link_options(${COMPONENT_LIB}
Expand All @@ -181,6 +208,8 @@ target_compile_options(${COMPONENT_LIB} PRIVATE
"-DPW_RPC_ATTRIBUTE_SERVICE=1"
"-DPW_RPC_BUTTON_SERVICE=1"
"-DPW_RPC_DEVICE_SERVICE=1"
"-DPW_RPC_DESCRIPTOR_SERVICE=1"
"-DPW_RPC_WIFI_SERVICE=1"
"-DPW_RPC_TRACING_SERVICE=1")

endif (CONFIG_ENABLE_PW_RPC)
68 changes: 62 additions & 6 deletions examples/chef/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,92 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/openthread.gni")
import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/app/chip_data_model.gni")
import("sample.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/src/app/common_flags.gni")

assert(chip_build_tools)

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")
}

import("sample.gni")

project_dir = "./.."

chip_data_model("chef-data-model") {
zap_file = "${project_dir}/devices/${sample_zap_file}"

zap_pregenerated_dir =
"${chip_root}/examples/chef/out/${sample_name}/zap-generated/"
is_server = true
}

executable("${sample_name}") {
sources = [ "${project_dir}/linux/main.cpp" ]
sources = [
"${project_dir}/common/stubs.cpp",
"${project_dir}/linux/main.cpp",
]

deps = [
":chef-data-model",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/src/controller",
"${chip_root}/src/credentials",
"${chip_root}/src/lib",
"${chip_root}/src/lib",
"${chip_root}/src/lib/shell",
"${chip_root}/src/platform",
"${project_dir}/shell_common:shell_common",
]

cflags = [ "-Wconversion" ]
include_dirs = [ "include" ]

if (chip_enable_pw_rpc) {
defines = [
"PW_RPC_ATTRIBUTE_SERVICE=1",
"PW_RPC_BUTTON_SERVICE=1",
"PW_RPC_DESCRIPTOR_SERVICE=1",
"PW_RPC_DEVICE_SERVICE=1",
"PW_RPC_LIGHTING_SERVICE=1",
]

sources += [
"${chip_root}/examples/platform/linux/Rpc.cpp",
"${dir_pigweed}/targets/host/system_rpc_server.cc",
]

deps += [
"$dir_pw_hdlc:pw_rpc",
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_log",
"$dir_pw_rpc:server",
"$dir_pw_rpc/system_server:facade",
"$dir_pw_stream:socket_stream",
"$dir_pw_stream:sys_io_stream",
"$dir_pw_sync:mutex",
"${chip_root}/config/linux/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:descriptor_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:rpc_services",
]

deps += pw_build_LINK_DEPS
} else {
# The system_rpc_server.cc file is in pigweed and doesn't compile with
# -Wconversion, remove check for RPC build only.
cflags = [ "-Wconversion" ]
}

output_dir = root_out_dir
}
Expand All @@ -52,4 +106,6 @@ group("chef") {
deps = [ ":${sample_name}" ]
}

import("//build_overrides/chip.gni")
group("default") {
deps = [ ":chef" ]
}
31 changes: 15 additions & 16 deletions examples/chef/linux/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,32 +16,29 @@
* limitations under the License.
*/

#include <lib/shell/Engine.h>
#include <AppMain.h>

#include <lib/core/CHIPCore.h>
#include <lib/support/Base64.h>
#include <lib/support/CHIPArgParser.hpp>
#include <lib/support/CodeUtils.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

#include <lib/shell/Engine.h>

#include <ChipShellCollection.h>
#include <lib/support/CHIPMem.h>
#include <platform/CHIPDeviceLayer.h>

using namespace chip;
using namespace chip::Shell;

int main()
void ApplicationInit() {}

int main(int argc, char * argv[])
{
chip::Platform::MemoryInit();
chip::DeviceLayer::PlatformMgr().InitChipStack();
chip::DeviceLayer::PlatformMgr().StartEventLoopTask();
#if CHIP_DEVICE_CONFIG_ENABLE_WPA
chip::DeviceLayer::ConnectivityManagerImpl().StartWiFiManagement();
#endif
if (ChipLinuxAppInit(argc, argv) != 0)
{
return -1;
}

const int rc = Engine::Root().Init();

if (rc != 0)
{
ChipLogError(Shell, "Streamer initialization failed: %d", rc);
Expand All @@ -55,6 +53,7 @@ int main()
cmd_app_server_init();
#endif

Engine::Root().RunMainLoop();
ChipLinuxAppMainLoop();

return 0;
}
40 changes: 40 additions & 0 deletions examples/chef/linux/with_pw_rpc.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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.

# add this gni as import in your build args to use pigweed in the example
# 'import("//with_pw_rpc.gni")'

import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")

import("//build_overrides/pigweed.gni")

cpp_standard = "gnu++17"

pw_log_BACKEND = "$dir_pw_log_basic"
pw_assert_BACKEND = "$dir_pw_assert_log"
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
pw_unit_test_MAIN = "$dir_pw_unit_test:logging_main"
pw_rpc_system_server_BACKEND = "${chip_root}/config/linux/lib/pw_rpc:pw_rpc"
dir_pw_third_party_nanopb = "${chip_root}/third_party/nanopb/repo"
pw_chrono_SYSTEM_CLOCK_BACKEND = "$dir_pw_chrono_stl:system_clock"
pw_sync_MUTEX_BACKEND = "$dir_pw_sync_stl:mutex_backend"

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
"$dir_pw_log:impl",
]

chip_enable_pw_rpc = true
1 change: 1 addition & 0 deletions examples/chef/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ target_sources(app PRIVATE
${APP_ROOT}/shell_common/cmd_ping.cpp
${APP_ROOT}/shell_common/cmd_send.cpp
${APP_ROOT}/nrfconnect/main.cpp
${APP_ROOT}/common/stubs.cpp
${GEN_DIR}/callback-stub.cpp
${GEN_DIR}/IMClusterCommandHandler.cpp
${NRFCONNECT_COMMON}/util/ThreadUtil.cpp
Expand Down

0 comments on commit 4aa3c1d

Please sign in to comment.