diff --git a/examples/common/pigweed/rpc_services/Device.h b/examples/common/pigweed/rpc_services/Device.h index 499ebe9ca006f7..6898e55594798f 100644 --- a/examples/common/pigweed/rpc_services/Device.h +++ b/examples/common/pigweed/rpc_services/Device.h @@ -21,6 +21,7 @@ #include #include +#include "app/clusters/ota-requestor/OTARequestorInterface.h" #include "app/server/OnboardingCodesUtil.h" #include "app/server/Server.h" #include "credentials/FabricTable.h" @@ -220,8 +221,20 @@ class Device : public pw_rpc::nanopb::Device::Service virtual pw::Status TriggerOta(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) { - // TODO: auto err = DeviceLayer::SoftwareUpdateMgr().CheckNow(); - return pw::Status::Unimplemented(); + chip::DeviceLayer::PlatformMgr().ScheduleWork( + [](intptr_t) { + chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); + if (requestor == nullptr) + { + ChipLogError(SoftwareUpdate, "Can't get the CASESessionManager"); + } + else + { + requestor->TriggerImmediateQuery(); + } + }, + reinterpret_cast(nullptr)); + return pw::OkStatus(); } virtual pw::Status SetPairingState(const chip_rpc_PairingState & request, pw_protobuf_Empty & response) diff --git a/examples/ota-requestor-app/esp32/CMakeLists.txt b/examples/ota-requestor-app/esp32/CMakeLists.txt index 2d1b7398791956..4eb5c5e209c2e0 100644 --- a/examples/ota-requestor-app/esp32/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/CMakeLists.txt @@ -1,18 +1,18 @@ # -# Copyright (c) 2021 Project CHIP Authors -# All rights reserved. +# Copyright (c) 2021 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. -# You may obtain a copy of the License at +# 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 +# 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. +# 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. # The following lines of boilerplate have to be in your project's # CMakeLists in this exact order for cmake to work correctly @@ -27,8 +27,11 @@ set(EXTRA_COMPONENT_DIRS ) project(chip-ota-requestor-app) -idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND) + +# C++17 is required for RPC build. +idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND) idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND) + # For the C3, project_include.cmake sets -Wno-format, but does not clear various # flags that depend on -Wformat idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND) @@ -39,25 +42,24 @@ idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-secur # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 idf_build_set_property(COMPILE_OPTIONS "-Wno-error=maybe-uninitialized" APPEND) -if (CONFIG_ENABLE_PW_RPC) -get_filename_component(CHIP_ROOT ./third_party/connectedhomeip REALPATH) -include(third_party/connectedhomeip/third_party/pigweed/repo/pw_build/pigweed.cmake) +if(CONFIG_ENABLE_PW_RPC) + get_filename_component(CHIP_ROOT ./third_party/connectedhomeip REALPATH) + include(third_party/connectedhomeip/third_party/pigweed/repo/pw_build/pigweed.cmake) -pw_set_module_config(pw_rpc_CONFIG pw_rpc.disable_global_mutex_config) -pw_set_backend(pw_log pw_log_basic) -pw_set_backend(pw_assert.check pw_assert_log.check_backend) -pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend) -pw_set_backend(pw_sys_io pw_sys_io.esp32) + pw_set_module_config(pw_rpc_CONFIG pw_rpc.disable_global_mutex_config) + pw_set_backend(pw_log pw_log_basic) + pw_set_backend(pw_assert.check pw_assert_log.check_backend) + pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend) + pw_set_backend(pw_sys_io pw_sys_io.esp32) -add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo) -add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo) -add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io) + add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo) + add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo) + add_subdirectory(third_party/connectedhomeip/examples/platform/esp32/pw_sys_io) -get_target_property(_target_cxx_flags pw_build.cpp17 INTERFACE_COMPILE_OPTIONS) -list(REMOVE_ITEM _target_cxx_flags $<$:-std=c++17>) -list(APPEND _target_cxx_flags $<$:-std=gnu++17>) -set_target_properties(pw_build.cpp17 PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}") + get_target_property(_target_cxx_flags pw_build.cpp17 INTERFACE_COMPILE_OPTIONS) + list(REMOVE_ITEM _target_cxx_flags $<$:-std=c++17>) + list(APPEND _target_cxx_flags $<$:-std=gnu++17>) + set_target_properties(pw_build.cpp17 PROPERTIES INTERFACE_COMPILE_OPTIONS "${_target_cxx_flags}") endif(CONFIG_ENABLE_PW_RPC) - flashing_script() diff --git a/examples/ota-requestor-app/esp32/README.md b/examples/ota-requestor-app/esp32/README.md index 513c070578a088..7c093cb6967a4e 100644 --- a/examples/ota-requestor-app/esp32/README.md +++ b/examples/ota-requestor-app/esp32/README.md @@ -78,3 +78,30 @@ config options for setting software version. Matter OTA image can also be generated using [ota_image_tool.py](https://github.com/project-chip/connectedhomeip/blob/master/src/app/ota_image_tool.py) script. + +## Using the RPC console + +Enable RPCs in the build using menuconfig: + + $ idf.py menuconfig + +Enable the RPC library: + + Component config → CHIP Core → General Options → Enable Pigweed PRC library + +After flashing a build with RPCs enabled you can use the rpc console to send +commands to the device. + +Build or install the [rpc console](../../common/pigweed/rpc_console/README.md) + +- Start the console + +``` + chip-console --device /dev/ttyUSB0 +``` + +- From within the console you can then invoke rpcs: + +``` + rpcs.chip.rpc.Device.TriggerOta() +``` diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index a465e628863136..310acadf9a81e5 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -1,162 +1,185 @@ # -# Copyright (c) 2021 Project CHIP Authors -# All rights reserved. +# Copyright (c) 2021 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. -# You may obtain a copy of the License at +# 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 +# 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. +# 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. # # # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) -idf_component_register(PRIV_INCLUDE_DIRS - "${CMAKE_CURRENT_LIST_DIR}/include" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" - SRC_DIRS - "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" - PRIV_REQUIRES chip QRCode bt console app_update) +set(PRIV_INCLUDE_DIRS_LIST + "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" +) + +set(SRC_DIRS_LIST + "${CMAKE_CURRENT_LIST_DIR}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/zap-generated" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" +) + +set(PRIV_REQUIRES_LIST chip QRCode bt console app_update) -set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14) +if(CONFIG_ENABLE_PW_RPC) + # Append additional directories for RPC build + set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/pw_sys_io/public" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" + "${IDF_PATH}/components/freertos/include/freertos" + ) + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" + ) +endif(CONFIG_ENABLE_PW_RPC) + +idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} + SRC_DIRS ${SRC_DIRS_LIST} + PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) + +set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H") target_compile_options(${COMPONENT_LIB} PUBLIC - "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" + "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" ) -if (CONFIG_ENABLE_PW_RPC) +if(CONFIG_ENABLE_PW_RPC) + get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) -get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) + set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") + include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) + include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) + set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE) -set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") -include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) -include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) -set(dir_pw_third_party_nanopb "${CHIP_ROOT}/third_party/nanopb/repo" CACHE STRING "" FORCE) - -pw_proto_library(attributes_service - SOURCES + pw_proto_library(attributes_service + SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.proto - INPUTS + INPUTS ${CHIP_ROOT}/examples/common/pigweed/protos/attributes_service.options - PREFIX + PREFIX attributes_service - STRIP_PREFIX + STRIP_PREFIX ${CHIP_ROOT}/examples/common/pigweed/protos - DEPS + DEPS pw_protobuf.common_proto -) + ) -pw_proto_library(button_service - SOURCES + pw_proto_library(button_service + SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/button_service.proto - PREFIX + PREFIX button_service - STRIP_PREFIX + STRIP_PREFIX ${CHIP_ROOT}/examples/common/pigweed/protos - DEPS + DEPS pw_protobuf.common_proto -) + ) -pw_proto_library(descriptor_service - SOURCES + pw_proto_library(descriptor_service + SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/descriptor_service.proto - PREFIX + PREFIX descriptor_service - STRIP_PREFIX + STRIP_PREFIX ${CHIP_ROOT}/examples/common/pigweed/protos - DEPS + DEPS pw_protobuf.common_proto -) + ) -pw_proto_library(device_service - SOURCES + pw_proto_library(device_service + SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.proto - INPUTS + INPUTS ${CHIP_ROOT}/examples/common/pigweed/protos/device_service.options - PREFIX + PREFIX device_service - STRIP_PREFIX + STRIP_PREFIX ${CHIP_ROOT}/examples/common/pigweed/protos - DEPS + DEPS pw_protobuf.common_proto -) + ) -pw_proto_library(wifi_service - SOURCES + pw_proto_library(wifi_service + SOURCES ${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.proto - INPUTS + INPUTS ${CHIP_ROOT}/examples/common/pigweed/protos/wifi_service.options - PREFIX + PREFIX wifi_service - DEPS + DEPS pw_protobuf.common_proto - STRIP_PREFIX + 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 - wifi_service.nanopb_rpc - pw_checksum - 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_libraries(${COMPONENT_LIB} PUBLIC + attributes_service.nanopb_rpc + button_service.nanopb_rpc + descriptor_service.nanopb_rpc + device_service.nanopb_rpc + wifi_service.nanopb_rpc + pw_checksum + 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(${COMPONENT_LIB} - PUBLIC + target_link_options(${COMPONENT_LIB} + PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" -) - -target_compile_options(${COMPONENT_LIB} PRIVATE - "-DPW_RPC_ATTRIBUTE_SERVICE=1" - "-DPW_RPC_BUTTON_SERVICE=1" - "-DPW_RPC_DESCRIPTOR_SERVICE=1" - "-DPW_RPC_DEVICE_SERVICE=1" - "-DPW_RPC_TRACING_SERVICE=1" - "-DPW_RPC_WIFI_SERVICE=1" - "-DPW_TRACE_BACKEND_SET=1") + ) -endif (CONFIG_ENABLE_PW_RPC) + target_compile_options(${COMPONENT_LIB} PRIVATE + "-DPW_RPC_ATTRIBUTE_SERVICE=1" + "-DPW_RPC_BUTTON_SERVICE=1" + "-DPW_RPC_DESCRIPTOR_SERVICE=1" + "-DPW_RPC_DEVICE_SERVICE=1" + "-DPW_RPC_TRACING_SERVICE=1" + "-DPW_RPC_WIFI_SERVICE=1" + "-DPW_TRACE_BACKEND_SET=1") +endif(CONFIG_ENABLE_PW_RPC) diff --git a/examples/ota-requestor-app/esp32/main/Kconfig.projbuild b/examples/ota-requestor-app/esp32/main/Kconfig.projbuild index a563d7b2ae46ce..bd6973f4996cd2 100644 --- a/examples/ota-requestor-app/esp32/main/Kconfig.projbuild +++ b/examples/ota-requestor-app/esp32/main/Kconfig.projbuild @@ -45,3 +45,41 @@ menu "Demo" default 8 if RENDEZVOUS_MODE_ETHERNET endmenu + +menu "PW RPC Debug channel" +depends on ENABLE_PW_RPC + config EXAMPLE_UART_PORT_NUM + int "UART port number" + range 0 2 if IDF_TARGET_ESP32 + range 0 1 if IDF_TARGET_ESP32C3 + default 0 + help + UART communication port number for the example. + See UART documentation for available port numbers. + + config EXAMPLE_UART_BAUD_RATE + int "UART communication speed" + range 1200 115200 + default 115200 + help + UART communication speed for Modbus example. + + config EXAMPLE_UART_RXD + int "UART RXD pin number" + range 0 34 if IDF_TARGET_ESP32 + range 0 19 if IDF_TARGET_ESP32C3 + default 5 + help + GPIO number for UART RX pin. See UART documentation for more information + about available pin numbers for UART. + + config EXAMPLE_UART_TXD + int "UART TXD pin number" + range 0 34 if IDF_TARGET_ESP32 + range 0 19 if IDF_TARGET_ESP32C3 + default 4 + help + GPIO number for UART TX pin. See UART documentation for more information + about available pin numbers for UART. + +endmenu \ No newline at end of file diff --git a/examples/ota-requestor-app/esp32/main/main.cpp b/examples/ota-requestor-app/esp32/main/main.cpp index 02adf0680655ae..ac5540b32b4974 100644 --- a/examples/ota-requestor-app/esp32/main/main.cpp +++ b/examples/ota-requestor-app/esp32/main/main.cpp @@ -37,6 +37,12 @@ #include +#include "OTAImageProcessorImpl.h" + +#if CONFIG_ENABLE_PW_RPC +#include "Rpc.h" +#endif + using namespace ::chip; using namespace ::chip::System; using namespace ::chip::Credentials; @@ -66,6 +72,10 @@ static void InitServer(intptr_t context) extern "C" void app_main() { +#if CONFIG_ENABLE_PW_RPC + chip::rpc::Init(); +#endif + ESP_LOGI(TAG, "OTA Requester!"); /* Print chip information */ diff --git a/examples/ota-requestor-app/esp32/sdkconfig_rpc.defaults b/examples/ota-requestor-app/esp32/sdkconfig_rpc.defaults new file mode 100644 index 00000000000000..350613d6118874 --- /dev/null +++ b/examples/ota-requestor-app/esp32/sdkconfig_rpc.defaults @@ -0,0 +1,65 @@ +# +# Copyright (c) 2020 Project CHIP Authors +# Copyright (c) 2018 Nest Labs, Inc. +# 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. +# 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. +# +# Description: +# Some useful defaults for the demo app configuration. +# + + +# Default to 921600 baud when flashing and monitoring device +CONFIG_ESPTOOLPY_BAUD_921600B=y +CONFIG_ESPTOOLPY_BAUD=921600 +CONFIG_ESPTOOLPY_COMPRESSED=y +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 + +#enable BT +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y + +#enable lwip ipv6 autoconfig +CONFIG_LWIP_IPV6_AUTOCONFIG=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" + +# Add RTC memory to system heap +CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y + +# Product id +CONFIG_DEVICE_VENDOR_ID=0xFFF1 +CONFIG_DEVICE_PRODUCT_ID=0x8008 + +# Main task needs a bit more stack than the default +# default is 3584, bump this up to 4k. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" + +# Enable OTA Requestor +CONFIG_ENABLE_OTA_REQUESTOR=y +CONFIG_DEVICE_SOFTWARE_VERSION_NUMBER=2 + +# PW RPC Debug channel +CONFIG_EXAMPLE_UART_PORT_NUM=0 +CONFIG_EXAMPLE_UART_BAUD_RATE=115200 +CONFIG_EXAMPLE_UART_RXD=3 +CONFIG_EXAMPLE_UART_TXD=1 +CONFIG_ENABLE_PW_RPC=y \ No newline at end of file diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 375921edee45c7..beee2899808b62 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -324,6 +324,8 @@ def Esp32Targets(): yield devkitc.Extend('bridge', app=Esp32App.BRIDGE) yield devkitc.Extend('temperature-measurement', app=Esp32App.TEMPERATURE_MEASUREMENT) yield devkitc.Extend('temperature-measurement-rpc', app=Esp32App.TEMPERATURE_MEASUREMENT, enable_rpcs=True) + yield devkitc.Extend('ota-requestor', app=Esp32App.OTA_REQUESTOR) + yield devkitc.Extend('ota-requestor-rpc', app=Esp32App.OTA_REQUESTOR, enable_rpcs=True) yield esp32_target.Extend('qemu-tests', board=Esp32Board.QEMU, app=Esp32App.TESTS) diff --git a/scripts/build/builders/esp32.py b/scripts/build/builders/esp32.py index 8f3f43393d0f2e..1b70f563415e76 100644 --- a/scripts/build/builders/esp32.py +++ b/scripts/build/builders/esp32.py @@ -35,6 +35,7 @@ class Esp32App(Enum): BRIDGE = auto() TEMPERATURE_MEASUREMENT = auto() TESTS = auto() + OTA_REQUESTOR = auto() @property def ExamplePath(self): @@ -50,6 +51,8 @@ def ExamplePath(self): return 'examples/bridge-app' elif self == Esp32App.TEMPERATURE_MEASUREMENT: return 'examples/temperature-measurement-app' + elif self == Esp32App.OTA_REQUESTOR: + return 'examples/ota-requestor-app' elif self == Esp32App.TESTS: return 'src/test_driver' else: @@ -69,6 +72,8 @@ def AppNamePrefix(self): return 'chip-bridge-app' elif self == Esp32App.TEMPERATURE_MEASUREMENT: return 'chip-temperature-measurement-app' + elif self == Esp32App.OTA_REQUESTOR: + return 'chip-ota-requestor-app' elif self == Esp32App.TESTS: return None else: @@ -93,9 +98,12 @@ def IsCompatible(self, board: Esp32Board): def DefaultsFileName(board: Esp32Board, app: Esp32App, enable_rpcs: bool): + rpc_enabled_apps = [Esp32App.ALL_CLUSTERS, + Esp32App.OTA_REQUESTOR, + Esp32App.TEMPERATURE_MEASUREMENT] if app == Esp32App.TESTS: return 'sdkconfig_qemu.defaults' - elif app != Esp32App.ALL_CLUSTERS and app != Esp32App.TEMPERATURE_MEASUREMENT: + elif app not in rpc_enabled_apps: return 'sdkconfig.defaults' rpc = "_rpc" if enable_rpcs else "" diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index a97608af99fef6..e93c34356657c6 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -144,6 +144,8 @@ esp32-devkitc-all-clusters-ipv6only esp32-devkitc-bridge esp32-devkitc-light esp32-devkitc-lock +esp32-devkitc-ota-requestor +esp32-devkitc-ota-requestor-rpc esp32-devkitc-shell esp32-devkitc-temperature-measurement esp32-devkitc-temperature-measurement-rpc diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 4d5876197e8b76..359c47ddcd95a2 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -579,6 +579,28 @@ bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-lock/sdkconfig.defaults idf.py -C examples/lock-app/esp32 -B {out}/esp32-devkitc-lock reconfigure' +# Generating esp32-devkitc-ota-requestor +mkdir -p {out}/esp32-devkitc-ota-requestor + +cp examples/ota-requestor-app/esp32/sdkconfig.defaults {out}/esp32-devkitc-ota-requestor/sdkconfig.defaults + +rm -f examples/ota-requestor-app/esp32/sdkconfig + +bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; +export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-ota-requestor/sdkconfig.defaults +idf.py -C examples/ota-requestor-app/esp32 -B {out}/esp32-devkitc-ota-requestor reconfigure' + +# Generating esp32-devkitc-ota-requestor-rpc +mkdir -p {out}/esp32-devkitc-ota-requestor-rpc + +cp examples/ota-requestor-app/esp32/sdkconfig_rpc.defaults {out}/esp32-devkitc-ota-requestor-rpc/sdkconfig.defaults + +rm -f examples/ota-requestor-app/esp32/sdkconfig + +bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; +export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-ota-requestor-rpc/sdkconfig.defaults +idf.py -C examples/ota-requestor-app/esp32 -B {out}/esp32-devkitc-ota-requestor-rpc reconfigure' + # Generating esp32-devkitc-shell mkdir -p {out}/esp32-devkitc-shell @@ -1657,6 +1679,20 @@ bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-lock/sdkconfig.defaults idf.py -C examples/lock-app/esp32 -B {out}/esp32-devkitc-lock build' +rm -f examples/ota-requestor-app/esp32/sdkconfig + +# Building esp32-devkitc-ota-requestor +bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; +export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-ota-requestor/sdkconfig.defaults +idf.py -C examples/ota-requestor-app/esp32 -B {out}/esp32-devkitc-ota-requestor build' + +rm -f examples/ota-requestor-app/esp32/sdkconfig + +# Building esp32-devkitc-ota-requestor-rpc +bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh; +export SDKCONFIG_DEFAULTS={out}/esp32-devkitc-ota-requestor-rpc/sdkconfig.defaults +idf.py -C examples/ota-requestor-app/esp32 -B {out}/esp32-devkitc-ota-requestor-rpc build' + rm -f examples/shell/esp32/sdkconfig # Building esp32-devkitc-shell diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 8783e163a04bf8..41f486181bebb9 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -38,6 +38,8 @@ esp32-devkitc-all-clusters-ipv6only esp32-devkitc-bridge esp32-devkitc-light esp32-devkitc-lock +esp32-devkitc-ota-requestor +esp32-devkitc-ota-requestor-rpc esp32-devkitc-shell esp32-devkitc-temperature-measurement esp32-devkitc-temperature-measurement-rpc