diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ea8a6750d4dac0..b7f991686db932 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Project CHIP Authors +# Copyright (c) 2020-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. @@ -56,7 +56,7 @@ jobs: - name: Setup Build run: | case $BUILD_TYPE in - "main") GN_ARGS='';; + "main") GN_ARGS='chip_config_memory_debug_checks=true chip_config_memory_debug_dmalloc=true';; "clang") GN_ARGS='is_clang=true';; "mbedtls") GN_ARGS='chip_crypto="mbedtls"';; *) ;; diff --git a/.gitmodules b/.gitmodules index 55f495a9b753ff..6186ba6d3ecfab 100644 --- a/.gitmodules +++ b/.gitmodules @@ -70,3 +70,6 @@ path = third_party/freertos/repo url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git branch = V10.3.1-kernel-only +[submodule "third_party/efr32_sdk/repo"] + path = third_party/efr32_sdk/repo + url = https://github.com/SiliconLabs/sdk_support.git diff --git a/REVIEWERS.md b/REVIEWERS.md index acc599464cb578..ec478b03c4d08f 100644 --- a/REVIEWERS.md +++ b/REVIEWERS.md @@ -1,14 +1,14 @@ The following individuals can be chosen as, and act as required reviewers on any PR -| Name | Company | -| ----------------------------------------------------- | ------------------- | -| [anush-apple](https://github.com/anush-apple) | Apple, Inc. | -| [BroderickCarlin](https://github.com/BroderickCarlin) | Samsung SmartThings | -| [chrisdecenzo](https://github.com/chrisdecenzo) | Amazon, Inc. | -| [hawk248](https://github.com/hawk248) | Comcast, Inc. | -| [jelderton](https://github.com/jelderton) | Comcast, Inc. | -| [andy31415](https://github.com/andy31415) | Google, Inc. | -| [robszewczyk](https://github.com/robszewczyk) | Google, Inc. | -| [saurabhst](https://github.com/saurabhst) | Samsung SmartThings | -| [woody-apple](https://github.com/woody-apple) | Apple, Inc. | +| Name | Company | +| ----------------------------------------------- | ------------------- | +| [anush-apple](https://github.com/anush-apple) | Apple, Inc. | +| [msandstedt](https://github.com/msandstedt) | Samsung SmartThings | +| [chrisdecenzo](https://github.com/chrisdecenzo) | Amazon, Inc. | +| [hawk248](https://github.com/hawk248) | Comcast, Inc. | +| [jelderton](https://github.com/jelderton) | Comcast, Inc. | +| [andy31415](https://github.com/andy31415) | Google, Inc. | +| [robszewczyk](https://github.com/robszewczyk) | Google, Inc. | +| [saurabhst](https://github.com/saurabhst) | Samsung SmartThings | +| [woody-apple](https://github.com/woody-apple) | Apple, Inc. | diff --git a/config/android/CHIPProjectConfig.h b/config/android/CHIPProjectConfig.h index 1685b9c719b31f..d164cff3dcda26 100644 --- a/config/android/CHIPProjectConfig.h +++ b/config/android/CHIPProjectConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2016-2017 Nest Labs, Inc. * Copyright (c) 2019-2020 Google LLC. * All rights reserved. @@ -44,7 +44,7 @@ #define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0 -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300 +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 300 #define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1 diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 4542e11cada9fc..a95481cb59ef22 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -321,7 +321,7 @@ menu "CHIP Device Layer" config CHIP_TASK_STACK_SIZE int "CHIP Task Stack Size" range 0 65535 - default 8192 + default 5120 help The size (in bytes) of the CHIP task stack. diff --git a/config/ios/CHIPProjectConfig.h b/config/ios/CHIPProjectConfig.h index 2761263ce6ff07..a46586c759ecfb 100644 --- a/config/ios/CHIPProjectConfig.h +++ b/config/ios/CHIPProjectConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2016-2017 Nest Labs, Inc. * Copyright (c) 2019-2020 Google LLC. * All rights reserved. @@ -44,7 +44,7 @@ #define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0 -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300 +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 300 #define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1 diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index d92e2caca783fc..e7328f634aa95a 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -201,6 +201,8 @@ else() endif() endif() +find_package(Python3 REQUIRED) + # ============================================================================== # Generate configuration for CHIP GN build system # ============================================================================== @@ -244,7 +246,12 @@ ExternalProject_Add( PREFIX ${CMAKE_CURRENT_BINARY_DIR} SOURCE_DIR ${CHIP_ROOT} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} - CONFIGURE_COMMAND ${GN_EXECUTABLE} --root=${CHIP_ROOT} --root-target=${GN_ROOT_TARGET} --dotfile=${GN_ROOT_TARGET}/.gn gen --check --fail-on-unused-args ${CMAKE_CURRENT_BINARY_DIR} + CONFIGURE_COMMAND ${GN_EXECUTABLE} + --root=${CHIP_ROOT} + --root-target=${GN_ROOT_TARGET} + --dotfile=${GN_ROOT_TARGET}/.gn + --script-executable=${Python3_EXECUTABLE} + gen --check --fail-on-unused-args ${CMAKE_CURRENT_BINARY_DIR} BUILD_COMMAND ninja INSTALL_COMMAND "" BUILD_BYPRODUCTS ${CHIP_LIBRARIES} diff --git a/config/standalone/CHIPProjectConfig.h b/config/standalone/CHIPProjectConfig.h index feb00ce7cf7e6d..1d5b2625cd481d 100644 --- a/config/standalone/CHIPProjectConfig.h +++ b/config/standalone/CHIPProjectConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2016-2017 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -65,7 +65,7 @@ #define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0 -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_MAXALLOC 300 +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 #define CHIP_CONFIG_ENABLE_FUNCT_ERROR_LOGGING 1 diff --git a/examples/chip-tool/templates/templates.json b/examples/chip-tool/templates/templates.json index 92a2cc2b1eb60c..243b3e0427d142 100644 --- a/examples/chip-tool/templates/templates.json +++ b/examples/chip-tool/templates/templates.json @@ -4,6 +4,7 @@ "helpers": [ "../../../src/app/zap-templates/partials/helper.js", "../../../src/app/zap-templates/common/StringHelper.js", + "../../../src/app/zap-templates/templates/app/helper.js", "../../../src/app/zap-templates/templates/chip/helper.js", "helper.js" ], diff --git a/examples/common/pigweed/nrfconnect/PigweedLoggerMutex.cpp b/examples/common/pigweed/nrfconnect/PigweedLoggerMutex.cpp new file mode 100644 index 00000000000000..5061d53e768a6d --- /dev/null +++ b/examples/common/pigweed/nrfconnect/PigweedLoggerMutex.cpp @@ -0,0 +1,27 @@ +/* + * + * 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 + * + * 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. + */ + +#include "PigweedLoggerMutex.h" + +namespace chip { +namespace rpc { + +PigweedLoggerMutex logger_mutex; + +} // namespace rpc +} // namespace chip diff --git a/examples/common/pigweed/nrfconnect/PigweedLoggerMutex.h b/examples/common/pigweed/nrfconnect/PigweedLoggerMutex.h new file mode 100644 index 00000000000000..18a1327669bd37 --- /dev/null +++ b/examples/common/pigweed/nrfconnect/PigweedLoggerMutex.h @@ -0,0 +1,52 @@ +/* + * + * 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 + * + * 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. + */ + +#pragma once + +#include "PigweedLogger.h" +#include "pigweed/RpcService.h" +#include + +namespace chip { +namespace rpc { +class PigweedLoggerMutex : public ::chip::rpc::Mutex +{ +public: + PigweedLoggerMutex() {} + void Lock() override + { + k_sem * sem = PigweedLogger::GetSemaphore(); + if (sem) + { + k_sem_take(sem, K_FOREVER); + } + } + void Unlock() override + { + k_sem * sem = PigweedLogger::GetSemaphore(); + if (sem) + { + k_sem_give(sem); + } + } +}; + +extern PigweedLoggerMutex logger_mutex; + +} // namespace rpc +} // namespace chip diff --git a/examples/lighting-app/efr32/README.md b/examples/lighting-app/efr32/README.md index 9f4312cae923f8..35bd5ba66f9ea9 100644 --- a/examples/lighting-app/efr32/README.md +++ b/examples/lighting-app/efr32/README.md @@ -39,11 +39,6 @@ Silicon Labs platform. ## Building -- Download the [sdk_support](https://github.com/SiliconLabs/sdk_support) from - GitHub and export the path with : - - $ export EFR32_SDK_ROOT= - - Download the [Simplicity Commander](https://www.silabs.com/mcu/programming-options) command line tool, and ensure that `commander` is your shell search path. @@ -66,6 +61,7 @@ Silicon Labs platform. MG12 boards: - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm + - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, 915MHz@19dBm @@ -77,10 +73,19 @@ Silicon Labs platform. * Build the example application: + cd ~/connectedhomeip + ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app BRD4161A + +- To delete generated executable, libraries and object files use: + + $ cd ~/connectedhomeip + $ rm -rf ./out/ + +OR use GN/Ninja directly + $ cd ~/connectedhomeip/examples/lighting-app/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_SDK_ROOT= $ export EFR32_BOARD=BRD4161A $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\"" $ ninja -C out/debug @@ -90,17 +95,6 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/lighting-app/efr32 $ rm -rf out/ -OR use the script - - cd ~/connectedhomeip - $ export EFR32_SDK_ROOT= - $ export EFR32_BOARD=BRD4161A - ./scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/debug/efr32_lighting_app - -- To delete generated executable, libraries and object files use: - $ cd ~/connectedhomeip - $ rm -rf out/debug/efr32_lighting_app - ## Flashing the Application @@ -210,14 +204,12 @@ combination with JLinkRTTClient as follows: **Push Button 0** - Press and Release : If not commissioned, start thread with default configurations (DEBUG) - - Pressed and hold for 6 s: Initiates the factory reset of the device. Releasing the button within the 6-second window cancels the factory reset procedure. **LEDs** blink in unison when the factory reset procedure is initiated. - **Push Button 1** - Toggles the light state On/Off + **Push Button 1** Toggles the light state On/Off - Once the device is provisioned, it will join the Thread network is established, look for the RTT log diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 917571c498dc7d..8c1599ecf58cfb 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -62,7 +62,6 @@ static LEDWidget sLightLED; static bool sIsThreadProvisioned = false; static bool sIsThreadEnabled = false; -static bool sIsThreadAttached = false; static bool sHaveBLEConnections = false; static bool sHaveServiceConnectivity = false; @@ -187,7 +186,6 @@ void AppTask::AppTaskMain(void * pvParameter) { sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); PlatformMgr().UnlockChipStack(); @@ -213,7 +211,7 @@ void AppTask::AppTaskMain(void * pvParameter) { sStatusLED.Set(true); } - else if (sIsThreadProvisioned && sIsThreadEnabled && (!sIsThreadAttached || !sHaveServiceConnectivity)) + else if (sIsThreadProvisioned && sIsThreadEnabled) { sStatusLED.Blink(950, 50); } diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 32db094783018d..96af02dc45a5ef 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -88,6 +88,7 @@ pw_proto_library(pigweed_lighting_protolib target_sources(app PRIVATE main/Rpc.cpp ../../common/pigweed/RpcService.cpp + ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp ) @@ -96,7 +97,8 @@ target_include_directories(app PRIVATE ${PIGWEED_ROOT}/pw_sys_io/public ${CHIP_ROOT}/src/lib/support ${CHIP_ROOT}/src/system - ../../common) + ../../common + ../../common/pigweed/nrfconnect) target_link_libraries(app PRIVATE pigweed_lighting_protolib.nanopb_rpc diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 0b021d215b59ce..7c089bb5feef47 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -74,8 +74,6 @@ NFCWidget sNFC; bool sIsThreadProvisioned = false; bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sIsPairedToAccount = false; bool sHaveBLEConnections = false; bool sHaveServiceConnectivity = false; @@ -164,16 +162,11 @@ int AppTask::StartApp() { sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); PlatformMgr().UnlockChipStack(); } - // Consider the system to be "fully connected" if it has service - // connectivity and it is able to interact with the service on a regular basis. - bool isFullyConnected = sHaveServiceConnectivity; - // Update the status LED if factory reset has not been initiated. // // If system has "full connectivity", keep the LED On constantly. @@ -188,11 +181,11 @@ int AppTask::StartApp() // Otherwise, blink the LED ON for a very short time. if (sAppTask.mFunction != kFunction_FactoryReset) { - if (isFullyConnected) + if (sHaveServiceConnectivity) { sStatusLED.Set(true); } - else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && (!sIsThreadAttached || !isFullyConnected)) + else if (sIsThreadProvisioned && sIsThreadEnabled) { sStatusLED.Blink(950, 50); } diff --git a/examples/lighting-app/nrfconnect/main/Rpc.cpp b/examples/lighting-app/nrfconnect/main/Rpc.cpp index 1c954eb7a2c143..647eb406653c1f 100644 --- a/examples/lighting-app/nrfconnect/main/Rpc.cpp +++ b/examples/lighting-app/nrfconnect/main/Rpc.cpp @@ -19,6 +19,7 @@ #include "Rpc.h" #include "AppTask.h" #include "PigweedLogger.h" +#include "PigweedLoggerMutex.h" #include "pigweed/RpcService.h" #include "main/pigweed_lighting.rpc.pb.h" @@ -52,30 +53,6 @@ namespace { using std::byte; -class PigweedLoggerMutex : public ::chip::rpc::Mutex -{ -public: - PigweedLoggerMutex() {} - void Lock() override - { - k_sem * sem = PigweedLogger::GetSemaphore(); - if (sem) - { - k_sem_take(sem, K_FOREVER); - } - } - void Unlock() override - { - k_sem * sem = PigweedLogger::GetSemaphore(); - if (sem) - { - k_sem_give(sem); - } - } -}; - -PigweedLoggerMutex uart_mutex; - constexpr size_t kRpcTaskSize = 4096; constexpr int kRpcPriority = 5; @@ -101,7 +78,7 @@ k_tid_t Init() void RunRpcService(void *, void *, void *) { - Start(RegisterServices, &uart_mutex); + Start(RegisterServices, &logger_mutex); } } // namespace rpc diff --git a/examples/lighting-app/nrfconnect/main/include/CHIPProjectConfig.h b/examples/lighting-app/nrfconnect/main/include/CHIPProjectConfig.h index 4908f996d3a311..f37feae1422e5f 100644 --- a/examples/lighting-app/nrfconnect/main/include/CHIPProjectConfig.h +++ b/examples/lighting-app/nrfconnect/main/include/CHIPProjectConfig.h @@ -30,3 +30,4 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 12345678 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING 1 diff --git a/examples/lock-app/efr32/README.md b/examples/lock-app/efr32/README.md index 14bbe1a944edf1..83a3af8e59a55d 100644 --- a/examples/lock-app/efr32/README.md +++ b/examples/lock-app/efr32/README.md @@ -39,11 +39,6 @@ Silicon Labs platform. ## Building -- Download the [sdk_support](https://github.com/SiliconLabs/sdk_support) from - GitHub and export the path with : - - $ export EFR32_SDK_ROOT= - - Download the [Simplicity Commander](https://www.silabs.com/mcu/programming-options) command line tool, and ensure that `commander` is your shell search path. @@ -66,6 +61,7 @@ Silicon Labs platform. MG12 boards: - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm + - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, 915MHz@19dBm @@ -77,10 +73,19 @@ Silicon Labs platform. * Build the example application: + cd ~/connectedhomeip + ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/efr32/ ./out/lock_app BRD4161A + +- To delete generated executable, libraries and object files use: + + $ cd ~/connectedhomeip + $ rm -rf ./out/ + +OR use GN/Ninja directly + $ cd ~/connectedhomeip/examples/lock-app/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_SDK_ROOT= $ export EFR32_BOARD=BRD4161A $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\"" $ ninja -C out/debug @@ -90,17 +95,6 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/lock-app/efr32 $ rm -rf out/ -OR use the script - - cd ~/connectedhomeip - $ export EFR32_SDK_ROOT= - $ export EFR32_BOARD=BRD4161A - ./scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ out/debug/efr32_lock_app - -- To delete generated executable, libraries and object files use: - $ cd ~/connectedhomeip - $ rm -rf out/debug/efr32_lock_app - ## Flashing the Application @@ -211,14 +205,12 @@ combination with JLinkRTTClient as follows: **Push Button 0** - Press and Release : If not commissioned, start thread with default configurations (DEBUG) - - Pressed and hold for 6 s: Initiates the factory reset of the device. Releasing the button within the 6-second window cancels the factory reset procedure. **LEDs** blink in unison when the factory reset procedure is initiated. - **Push Button 1** - Toggles the bolt state On/Off + **Push Button 1** Toggles the bolt state On/Off - Once the device is provisioned, it will join the Thread network is established, look for the RTT log diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index 866770e100724b..6ca91522a3c1c5 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -61,8 +61,6 @@ static LEDWidget sLockLED; static bool sIsThreadProvisioned = false; static bool sIsThreadEnabled = false; -static bool sIsThreadAttached = false; -static bool sIsPairedToAccount = false; static bool sHaveBLEConnections = false; static bool sHaveServiceConnectivity = false; @@ -187,9 +185,7 @@ void AppTask::AppTaskMain(void * pvParameter) { sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); - sIsPairedToAccount = ConfigurationMgr().IsPairedToAccount(); sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); PlatformMgr().UnlockChipStack(); } @@ -214,7 +210,7 @@ void AppTask::AppTaskMain(void * pvParameter) { sStatusLED.Set(true); } - else if (sIsThreadProvisioned && sIsThreadEnabled && (!sIsThreadAttached || !sHaveServiceConnectivity)) + else if (sIsThreadProvisioned && sIsThreadEnabled) { sStatusLED.Blink(950, 50); } diff --git a/examples/lock-app/k32w/main/AppTask.cpp b/examples/lock-app/k32w/main/AppTask.cpp index d0ff7c45edc737..670dc3e6d1829c 100644 --- a/examples/lock-app/k32w/main/AppTask.cpp +++ b/examples/lock-app/k32w/main/AppTask.cpp @@ -52,8 +52,6 @@ static LEDWidget sLockLED; static bool sIsThreadProvisioned = false; static bool sIsThreadEnabled = false; -static bool sIsThreadAttached = false; -static bool sIsPairedToAccount = false; static bool sHaveBLEConnections = false; static bool sHaveServiceConnectivity = false; @@ -176,17 +174,11 @@ void AppTask::AppTaskMain(void * pvParameter) { sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); - sIsPairedToAccount = ConfigurationMgr().IsPairedToAccount(); sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); PlatformMgr().UnlockChipStack(); } - // Consider the system to be "fully connected" if it has service - // connectivity and it is able to interact with the service on a regular basis. - bool isFullyConnected = sHaveServiceConnectivity; - // Update the status LED if factory reset has not been initiated. // // If system has "full connectivity", keep the LED On constantly. @@ -201,11 +193,11 @@ void AppTask::AppTaskMain(void * pvParameter) // Otherwise, blink the LED ON for a very short time. if (sAppTask.mFunction != kFunction_FactoryReset) { - if (isFullyConnected) + if (sHaveServiceConnectivity) { sStatusLED.Set(true); } - else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && (!sIsThreadAttached || !isFullyConnected)) + else if (sIsThreadProvisioned && sIsThreadEnabled) { sStatusLED.Blink(950, 50); } diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 298595b7d867db..8590fe6c994cae 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -66,8 +66,6 @@ static NFCWidget sNFC; static bool sIsThreadProvisioned = false; static bool sIsThreadEnabled = false; -static bool sIsThreadAttached = false; -static bool sIsPairedToAccount = false; static bool sHaveBLEConnections = false; static bool sHaveServiceConnectivity = false; @@ -156,16 +154,11 @@ int AppTask::StartApp() { sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); PlatformMgr().UnlockChipStack(); } - // Consider the system to be "fully connected" if it has service - // connectivity and it is able to interact with the service on a regular basis. - bool isFullyConnected = sHaveServiceConnectivity; - // Update the status LED if factory reset has not been initiated. // // If system has "full connectivity", keep the LED On constantly. @@ -180,11 +173,11 @@ int AppTask::StartApp() // Otherwise, blink the LED ON for a very short time. if (sAppTask.mFunction != kFunction_FactoryReset) { - if (isFullyConnected) + if (sHaveServiceConnectivity) { sStatusLED.Set(true); } - else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && (!sIsThreadAttached || !isFullyConnected)) + else if (sIsThreadProvisioned && sIsThreadEnabled) { sStatusLED.Blink(950, 50); } diff --git a/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h b/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h index 4908f996d3a311..f37feae1422e5f 100644 --- a/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h +++ b/examples/lock-app/nrfconnect/main/include/CHIPProjectConfig.h @@ -30,3 +30,4 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 12345678 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING 1 diff --git a/examples/lock-app/qpg6100/src/AppTask.cpp b/examples/lock-app/qpg6100/src/AppTask.cpp index e951258208af91..454e43ae004b79 100644 --- a/examples/lock-app/qpg6100/src/AppTask.cpp +++ b/examples/lock-app/qpg6100/src/AppTask.cpp @@ -56,8 +56,6 @@ static QueueHandle_t sAppEventQueue; static bool sIsThreadProvisioned = false; static bool sIsThreadEnabled = false; -static bool sIsThreadAttached = false; -static bool sIsPairedToAccount = false; static bool sHaveBLEConnections = false; static bool sHaveServiceConnectivity = false; @@ -145,7 +143,6 @@ void AppTask::AppTaskMain(void * pvParameter) { sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); PlatformMgr().UnlockChipStack(); @@ -171,8 +168,7 @@ void AppTask::AppTaskMain(void * pvParameter) { qvCHIP_LedSet(SYSTEM_STATE_LED, true); } - else if (sIsThreadProvisioned && sIsThreadEnabled && sIsPairedToAccount && - (!sIsThreadAttached || !sHaveServiceConnectivity)) + else if (sIsThreadProvisioned && sIsThreadEnabled) { qvCHIP_LedBlink(SYSTEM_STATE_LED, 950, 50); } diff --git a/examples/persistent-storage/efr32/README.md b/examples/persistent-storage/efr32/README.md index 0480c9be1794a1..56b8e012558947 100644 --- a/examples/persistent-storage/efr32/README.md +++ b/examples/persistent-storage/efr32/README.md @@ -42,11 +42,6 @@ defines = [ ### Building -- Download the [sdk_support](https://github.com/SiliconLabs/sdk_support) from - GitHub and export the path with : - - $ export EFR32_SDK_ROOT= - - Download the [Simplicity Commander](https://www.silabs.com/mcu/programming-options) command line tool, and ensure that `commander` is your shell search path. @@ -80,10 +75,19 @@ defines = [ * Build the example application: + cd ~/connectedhomeip + ./scripts/examples/gn_efr32_example.sh ./examples/persistent-storage/efr32/ ./out/persistent-storage BRD4161A + +- To delete generated executable, libraries and object files use: + + $ cd ~/connectedhomeip + $ rm -rf ./out/persistent-storage + +OR use GN/Ninja directly + $ cd ~/connectedhomeip/examples/persistent-storage/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_SDK_ROOT= $ export EFR32_BOARD=BRD4161A $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\"" $ ninja -C out/debug diff --git a/examples/pigweed-app/esp32/Makefile b/examples/pigweed-app/esp32/Makefile index 17f9fb3c60ef5f..363bb153f6a778 100644 --- a/examples/pigweed-app/esp32/Makefile +++ b/examples/pigweed-app/esp32/Makefile @@ -44,13 +44,23 @@ $(FLASHING_SCRIPT): $(APP_BIN) $(BOOTLOADER_BIN) $(PARTITION_TABLE_BIN) $(PROJEC --use-parttool $(IDF_PATH)/components/partition_table/parttool.py \ --use-sdkconfig $(PROJECT_PATH)/sdkconfig -flashing_script: $(FLASHING_SCRIPT) $(BUILD_DIR_BASE)/esp32_firmware_utils.py $(BUILD_DIR_BASE)/firmware_utils.py +flashing_script: $(FLASHING_SCRIPT) $(BUILD_DIR_BASE)/esp32_firmware_utils.py $(BUILD_DIR_BASE)/firmware_utils.py $(BUILD_DIR_BASE)/echo_test.py $(BUILD_DIR_BASE)/echo_test_config.yml @echo To flash $(subst $(CURDIR)/,,$(APP_BIN)), run $(subst $(CURDIR)/,,$(FLASHING_SCRIPT)) $(BUILD_DIR_BASE)/esp32_firmware_utils.py: third_party/connectedhomeip/scripts/flashing/esp32_firmware_utils.py + echo "Copying esp32_firmware_utils.py" @cp $< $@ $(BUILD_DIR_BASE)/firmware_utils.py: third_party/connectedhomeip/scripts/flashing/firmware_utils.py + echo "Copying firmware_utils.py" + @cp $< $@ + +$(BUILD_DIR_BASE)/echo_test.py: ../mobly_tests/echo_test.py + echo "Copying echo_test.py" + @cp $< $@ + +$(BUILD_DIR_BASE)/echo_test_config.yml: ./echo_test_config.yml + echo "Copying echo_test_config.yml" @cp $< $@ .PHONY: flashing_script diff --git a/examples/pigweed-app/esp32/echo_test_config.yml b/examples/pigweed-app/esp32/echo_test_config.yml new file mode 100644 index 00000000000000..374d303f3d50d0 --- /dev/null +++ b/examples/pigweed-app/esp32/echo_test_config.yml @@ -0,0 +1,37 @@ +# 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. + +TestBeds: + # A test bed for esp32 where pw_rpc will find a CHIP device + - Name: ESP32TestBed + Controllers: + PigweedDevice: + - device_tty: /dev/ttyUSB1 + baud: 115200 + platform_module: esp32_firmware_utils + platform_args: + - "application": "chip-pigweed-app.bin" + "parttool": None + "port": "/dev/ttyUSB0" + "baud": "921600" + "before": "default_reset" + "after": "hard_reset" + "flash_mode": "dio" + "flash_freq": "40m" + "flash_size": "2MB" + "compress": "y" + "bootloader": "bootloader/bootloader.bin" + "partition": "partitions.bin" + "partition_offset": "0x8000" + "application_offset": "0x10000" diff --git a/examples/pigweed-app/mobly_tests/echo_test.py b/examples/pigweed-app/mobly_tests/echo_test.py new file mode 100644 index 00000000000000..9ef179622d0ea0 --- /dev/null +++ b/examples/pigweed-app/mobly_tests/echo_test.py @@ -0,0 +1,45 @@ +# 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. + +from chip_mobly import pigweed_device +from mobly import asserts +from mobly import base_test +from mobly import test_runner +import time + + +class PigweedEchoTest(base_test.BaseTestClass): + def setup_class(self): + ''' Registering pigweed_device controller module declares the test's + dependency on CHIP/Pigweed device hardware. By default, we expect at least one + object is created from this.''' + self.ads = self.register_controller(pigweed_device) + self.dut = self.ads[0] + self.dut.platform.flash() # Flashes the image passed in the configuration yml. + time.sleep(1) # give the device time to boot and register rpcs + + def test_hello(self): + ''' Tests EchoService.Echo ''' + expected = "hello!" + status, payload = self.dut.rpcs().EchoService.Echo(msg=expected) + asserts.assert_true(status.ok(), "Status is %s" % status) + asserts.assert_equal( + payload.msg, + expected, + 'Returned payload is "%s" expected "%s"' % (payload.msg, expected), + ) + + +if __name__ == "__main__": + test_runner.main() diff --git a/examples/pigweed-app/nrfconnect/.gitignore b/examples/pigweed-app/nrfconnect/.gitignore new file mode 100644 index 00000000000000..84c048a73cc2e5 --- /dev/null +++ b/examples/pigweed-app/nrfconnect/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/examples/pigweed-app/nrfconnect/CMakeLists.txt b/examples/pigweed-app/nrfconnect/CMakeLists.txt index 43e58937f6c435..7865068b2be3aa 100644 --- a/examples/pigweed-app/nrfconnect/CMakeLists.txt +++ b/examples/pigweed-app/nrfconnect/CMakeLists.txt @@ -19,6 +19,8 @@ get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connect get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH) set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") +set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) + if(${BOARD} STREQUAL "nrf52840dongle_nrf52840") list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-usb_support.conf) endif() @@ -29,17 +31,47 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) project(chip-nrf52840-pigweed-example) -target_include_directories(app PRIVATE main/include +zephyr_compile_options(-Werror) + +include(${PIGWEED_ROOT}/pw_build/pigweed.cmake) +include(${PIGWEED_ROOT}/pw_protobuf_compiler/proto.cmake) + +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.nrfconnect) +set(dir_pw_third_party_nanopb PRESENT CACHE STRING ${CHIP_ROOT}/third_party/nanopb/repo FORCE) + +add_subdirectory(third_party/connectedhomeip/examples/platform/nrfconnect/pw_sys_io) +add_subdirectory(third_party/connectedhomeip/third_party/nanopb/repo) +add_subdirectory(third_party/connectedhomeip/third_party/pigweed/repo) + +target_include_directories(app PRIVATE main/include + ${ZEPHYR_BASE}/subsys // required to get access to `log_output_std.h` ${NRFCONNECT_COMMON}/util/include + ${CHIP_ROOT}/src/lib/support ${PIGWEED_ROOT}/pw_sys_io/public ${PIGWEED_ROOT}/pw_span/public_overrides ${PIGWEED_ROOT}/pw_span/public ${PIGWEED_ROOT}/pw_polyfill/public ${PIGWEED_ROOT}/pw_polyfill/standard_library_public ${PIGWEED_ROOT}/pw_polyfill/public_overrides + ${PIGWEED_ROOT}/pw_rpc/public ${PIGWEED_ROOT}/pw_status/public ${PIGWEED_ROOT}/pw_preprocessor/public + ../../common + ../../common/pigweed/nrfconnect ${NRFCONNECT_COMMON}/pw_sys_io/public) -target_sources(app PRIVATE main/main.cpp - ${NRFCONNECT_COMMON}/util/LEDWidget.cpp) +target_sources(app PRIVATE main/main.cpp + ../../common/pigweed/RpcService.cpp + ../../common/pigweed/nrfconnect/PigweedLoggerMutex.cpp + ${NRFCONNECT_COMMON}/util/LEDWidget.cpp + ${NRFCONNECT_COMMON}/util/PigweedLogger.cpp +) + +target_link_libraries(app PUBLIC + pw_hdlc + pw_log + pw_rpc.nanopb.echo_service + pw_rpc.server +) diff --git a/examples/pigweed-app/nrfconnect/main/main.cpp b/examples/pigweed-app/nrfconnect/main/main.cpp index d2f34040c25d9b..ba8933ebfd0c44 100644 --- a/examples/pigweed-app/nrfconnect/main/main.cpp +++ b/examples/pigweed-app/nrfconnect/main/main.cpp @@ -17,7 +17,11 @@ #include "AppConfig.h" #include "LEDWidget.h" +#include "PigweedLoggerMutex.h" +#include "pigweed/RpcService.h" +#include +#include "pw_rpc/echo_service_nanopb.h" #include "pw_sys_io/sys_io.h" #include "pw_sys_io_nrfconnect/init.h" @@ -28,9 +32,26 @@ LOG_MODULE_REGISTER(app); static LEDWidget sStatusLED; -namespace hdlc_example { -extern void Start(); -} // namespace hdlc_example +namespace { +#define RPC_STACK_SIZE (8 * 1024) +#define RPC_PRIORITY 7 + +K_THREAD_STACK_DEFINE(rpc_stack_area, RPC_STACK_SIZE); +struct k_thread rpc_thread_data; + +pw::rpc::EchoService echo_service; + +void RegisterServices(pw::rpc::Server & server) +{ + server.RegisterService(echo_service); +} + +void RunRpcService(void *, void *, void *) +{ + Start(RegisterServices, &::chip::rpc::logger_mutex); +} + +} // namespace int main() { @@ -51,7 +72,8 @@ int main() sStatusLED.Init(SYSTEM_STATE_LED); sStatusLED.Set(true); - hdlc_example::Start(); - + k_thread_create(&rpc_thread_data, rpc_stack_area, K_THREAD_STACK_SIZEOF(rpc_stack_area), RunRpcService, NULL, NULL, NULL, + RPC_PRIORITY, 0, K_NO_WAIT); + k_thread_join(&rpc_thread_data, K_FOREVER); return 0; } diff --git a/examples/pigweed-app/nrfconnect/prj.conf b/examples/pigweed-app/nrfconnect/prj.conf index b59c4148650a33..8ef8c3f262201f 100644 --- a/examples/pigweed-app/nrfconnect/prj.conf +++ b/examples/pigweed-app/nrfconnect/prj.conf @@ -13,57 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -CONFIG_CHIP=y - -CONFIG_NEWLIB_LIBC=y - # Export POSIX names for functions implementing a subset of POSIX standard in Zephyr CONFIG_POSIX_API=y -CONFIG_PTHREAD_IPC=y -CONFIG_EVENTFD=y - -CONFIG_LOG=n -CONFIG_LOG_MINIMAL=n -CONFIG_ASSERT=y -CONFIG_HW_STACK_PROTECTION=y - -# Generic networking options -CONFIG_NETWORKING=y -CONFIG_NET_SOCKETS=y -CONFIG_NET_SOCKETS_POSIX_NAMES=n - -# Application stack size -CONFIG_MAIN_STACK_SIZE=8192 -CONFIG_INIT_STACKS=y - -# Disable certain parts of Zephyr IPv6 stack -CONFIG_NET_IPV6_NBR_CACHE=n -CONFIG_NET_IPV6_MLD=n - -# Use mbedTLS from nrf_security library -CONFIG_NORDIC_SECURITY_BACKEND=y -CONFIG_OPENTHREAD_MBEDTLS=n - -CONFIG_MBEDTLS_ENABLE_HEAP=y -CONFIG_MBEDTLS_HEAP_SIZE=15360 -CONFIG_MBEDTLS_TLS_LIBRARY=y -CONFIG_NRF_SECURITY_ADVANCED=y - -CONFIG_MBEDTLS_AES_C=y -CONFIG_MBEDTLS_RSA_C=y -CONFIG_MBEDTLS_ECP_C=y -CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y -CONFIG_MBEDTLS_CTR_DRBG_C=y -CONFIG_MBEDTLS_CIPHER_MODE_CTR=y -CONFIG_MBEDTLS_ECJPAKE_C=y - -# Disable unneeded crypto operations -CONFIG_MBEDTLS_SHA512_C=n -CONFIG_MBEDTLS_CIPHER_MODE_XTS=n -CONFIG_MBEDTLS_CHACHA20_C=n -CONFIG_MBEDTLS_POLY1305_C=n -CONFIG_MBEDTLS_CHACHAPOLY_C=n -CONFIG_MBEDTLS_GCM_C=n # Add support for LEDs and buttons on Nordic development kits CONFIG_DK_LIBRARY=y @@ -76,9 +27,23 @@ CONFIG_MPU_STACK_GUARD=y CONFIG_CHIP_PW_RPC=y # Add support for C++17 to build Pigweed components +CONFIG_STD_CPP14=n CONFIG_STD_CPP17=y # Add support for Zephyr console component to use it for Pigweed console purposes CONFIG_CONSOLE_SUBSYS=y CONFIG_CONSOLE_GETCHAR=y -CONFIG_CONSOLE_GETCHAR_BUFSIZE=256 +CONFIG_CONSOLE_PUTCHAR_BUFSIZE=256 + +# Disable features which may interfere with Pigweed HDLC transport +CONFIG_SHELL=n +CONFIG_OPENTHREAD_SHELL=n +CONFIG_BOOT_BANNER=n + +# Configure Zephyr logger with defaults backends disabled as the app provides its own, +# based on Pigweed HDLC. +CONFIG_LOG=y +CONFIG_LOG_MINIMAL=n +CONFIG_LOG_IMMEDIATE=y +CONFIG_LOG_BACKEND_UART=n +CONFIG_LOG_BACKEND_RTT=n diff --git a/examples/platform/efr32/LEDWidget.cpp b/examples/platform/efr32/LEDWidget.cpp index 0e0afe79f1914d..52e6c4fa82d5ba 100644 --- a/examples/platform/efr32/LEDWidget.cpp +++ b/examples/platform/efr32/LEDWidget.cpp @@ -46,8 +46,7 @@ void LEDWidget::Invert(void) void LEDWidget::Set(bool state) { - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; + mLastChangeTimeUS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; DoSet(state); } diff --git a/examples/platform/k32w/util/LEDWidget.cpp b/examples/platform/k32w/util/LEDWidget.cpp index 9d0ad5e12917fb..b89840a2615659 100644 --- a/examples/platform/k32w/util/LEDWidget.cpp +++ b/examples/platform/k32w/util/LEDWidget.cpp @@ -39,7 +39,7 @@ void LEDWidget::Invert(void) void LEDWidget::Set(bool state) { - mBlinkOnTimeMS = mBlinkOffTimeMS = mLastChangeTimeUS = 0; + mLastChangeTimeUS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; DoSet(state); } diff --git a/examples/platform/nrfconnect/util/LEDWidget.cpp b/examples/platform/nrfconnect/util/LEDWidget.cpp index 84557b6410edee..3851a45fe11809 100644 --- a/examples/platform/nrfconnect/util/LEDWidget.cpp +++ b/examples/platform/nrfconnect/util/LEDWidget.cpp @@ -44,7 +44,7 @@ void LEDWidget::Invert(void) void LEDWidget::Set(bool state) { - mBlinkOnTimeMS = mBlinkOffTimeMS = 0; + mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; DoSet(state); } diff --git a/examples/shell/nrfconnect/CHIPProjectConfig.h b/examples/shell/nrfconnect/CHIPProjectConfig.h index 31220b0ac0817c..c8c835b52d4a09 100644 --- a/examples/shell/nrfconnect/CHIPProjectConfig.h +++ b/examples/shell/nrfconnect/CHIPProjectConfig.h @@ -30,6 +30,7 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 12345678 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING 1 // Enable support functions for parsing command-line arguments #define CHIP_CONFIG_ENABLE_ARG_PARSER 1 diff --git a/gn_build.sh b/gn_build.sh index e456f895ce7d38..49601030174467 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -80,6 +80,9 @@ for arg; do enable_qpg6100_builds=true) qpg6100_enabled=1 ;; + enable_efr32_builds=true) + efr32_enabled=1 + ;; esac user_args+=" $arg" done @@ -98,15 +101,11 @@ fi echo # EFR32 SDK setup -efr32_sdk_args="" - -if [[ -d "$EFR32_SDK_ROOT/protocol/" ]]; then - efr32_sdk_args+="efr32_sdk_root=\"$EFR32_SDK_ROOT\" efr32_board=\"$EFR32_BOARD\"" - extra_args+=" $efr32_sdk_args enable_efr32_builds=true" - echo 'To build the EFR32 lock sample as a standalone project': - echo "(cd $CHIP_ROOT/examples/lock-app/efr32; gn gen out/debug --args='$efr32_sdk_args'; ninja -C out/debug)" +if [[ -z "$efr32_enabled" ]]; then + echo "Hint: Pass enable_efr32_builds=true to enable building for EFR32" else - echo "Hint: Set \$EFR32_SDK_ROOT to enable building for EFR32" + echo 'To build the EFR32 lock sample as a standalone project': + echo "(cd $CHIP_ROOT/examples/lock-app/efr32; gn gen out/debug; ninja -C out/debug)" fi # K32W SDK setup diff --git a/integrations/docker/images/chip-build-efr32/Dockerfile b/integrations/docker/images/chip-build-efr32/Dockerfile index 17ecffe41c788f..b744e687a73c1d 100644 --- a/integrations/docker/images/chip-build-efr32/Dockerfile +++ b/integrations/docker/images/chip-build-efr32/Dockerfile @@ -11,8 +11,3 @@ RUN set -x \ gcc-arm-none-eabi \ binutils-arm-none-eabi \ ccache - -#Clone Gecko SDK -RUN mkdir -p /opt/SiliconLabs && git clone https://github.com/SiliconLabs/sdk_support.git /opt/SiliconLabs/sdk_support - -ENV EFR32_SDK_ROOT=/opt/SiliconLabs/sdk_support diff --git a/integrations/docker/images/chip-build-vscode/Dockerfile b/integrations/docker/images/chip-build-vscode/Dockerfile index 19dfbbfe2d27f9..8937b5ee1fea8f 100644 --- a/integrations/docker/images/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/chip-build-vscode/Dockerfile @@ -22,7 +22,6 @@ ENV ZEPHYR_BASE=/opt/NordicSemiconductor/nrfconnect/zephyr ENV ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb ENV GNUARMEMB_TOOLCHAIN_PATH=/opt/ARM-software/gcc-arm-none-eabi-9-2019-q4-major ENV ARM_GCC_INSTALL_ROOT=/opt/ARM-software/gcc-arm-none-eabi-9-2019-q4-major/bin -ENV EFR32_SDK_ROOT=/opt/SiliconLabs/sdk_support ENV EFR32_BOARD=BRD4161A ENV ANDROID_HOME=/opt/android/sdk ENV ANDROID_NDK_HOME=/opt/android/android-ndk-r21b diff --git a/integrations/mobly/chip_mobly/pigweed_device.py b/integrations/mobly/chip_mobly/pigweed_device.py index a5aca0df258499..d736ccc345248b 100644 --- a/integrations/mobly/chip_mobly/pigweed_device.py +++ b/integrations/mobly/chip_mobly/pigweed_device.py @@ -17,7 +17,7 @@ import serial # type: ignore import importlib -from pw_hdlc.rpc import HdlcRpcClient +from pw_hdlc.rpc import HdlcRpcClient, default_channels # Point the script to the .proto file with our RPC services. PROTO = Path(os.environ["PW_ROOT"], "pw_rpc/pw_rpc_protos/echo.proto") @@ -31,7 +31,9 @@ class Error(Exception): class PigweedDevice: def __init__(self, device_tty, baud, platform_module=None, platform_args=None): - self.pw_rpc_client = HdlcRpcClient(serial.Serial(device_tty, baud), [PROTO]) + ser = serial.Serial(device_tty, baud, timeout=0.01) + self.pw_rpc_client = HdlcRpcClient(lambda: ser.read(4096), + [PROTO], default_channels(ser.write)) self._platform = None print("Platform args: %s" % platform_args) print("Platform module: %s" % platform_module) diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index 015ffd07fe70fd..ca7ab9203c6b24 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -26,9 +26,9 @@ set -x env if [ -z "$3" ]; then - gn gen --check --fail-on-unused-args --root="$1" --args="efr32_sdk_root=\"$EFR32_SDK_ROOT\"" "$2"/"$EFR32_BOARD"/ + gn gen --check --fail-on-unused-args --root="$1" "$2"/"$EFR32_BOARD"/ ninja -v -C "$2"/"$EFR32_BOARD"/ else - gn gen --check --fail-on-unused-args --root="$1" --args="efr32_sdk_root=\"$EFR32_SDK_ROOT\" efr32_board=\"$3\"" "$2/$3" + gn gen --check --fail-on-unused-args --root="$1" --args="efr32_board=\"$3\"" "$2/$3" ninja -v -C "$2/$3" fi diff --git a/scripts/flashing/esp32_firmware_utils.py b/scripts/flashing/esp32_firmware_utils.py index 4fa0a9a6150b32..6b53f1e863af66 100755 --- a/scripts/flashing/esp32_firmware_utils.py +++ b/scripts/flashing/esp32_firmware_utils.py @@ -445,6 +445,40 @@ def actions(self): return self +### Mobly integration +class ESP32Platform: + def __init__(self, flasher_args): + self.flasher = Flasher(**flasher_args) + + def flash(self): + self.flasher.flash_command([os.getcwd()]) + +def verify_platform_args(platform_args): + required_args = [ + 'application', + 'parttool', + 'port', + 'baud', + 'before', + 'after', + 'flash_mode', + 'flash_freq', + 'flash_size', + 'compress', + 'bootloader', + 'partition', + 'partition_offset', + 'application_offset', + ] + difference = set(required_args) - set(platform_args) + if difference: + raise ValueError("Required arguments missing: %s" % difference) + +def create_platform(platform_args): + verify_platform_args(platform_args[0]) + return ESP32Platform(platform_args[0]) + +### End of Mobly integration if __name__ == '__main__': sys.exit(Flasher().flash_command(sys.argv)) diff --git a/scripts/requirements.txt b/scripts/requirements.txt index 40422e9ac5953b..2b5b78a836d12a 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -4,53 +4,115 @@ # # pip-compile requirements.in # -backcall==0.2.0 # via ipython -certifi==2020.12.5 # via requests -cffi==1.14.4 # via cryptography -chardet==4.0.0 # via requests -click==7.1.2 # via -r requirements.in, pip-tools -colorama==0.4.4 # via west -coloredlogs==15.0 # via -r requirements.in -cryptography==3.3.1 # via -r requirements.in -decorator==4.4.2 # via ipython -docopt==0.6.2 # via pykwalify -future==0.18.2 # via -r requirements.in, mobly -humanfriendly==9.1 # via coloredlogs -idna==2.10 # via requests -ipython-genutils==0.2.0 # via traitlets -ipython==7.20.0 # via -r requirements.in -jedi==0.18.0 # via ipython -lockfile==0.12.2 # via -r requirements.in -mobly==1.10.1 # via -r requirements.in -packaging==20.9 # via west -parso==0.8.1 # via jedi -pexpect==4.8.0 # via ipython -pickleshare==0.7.5 # via ipython -pip-tools==5.5.0 # via -r requirements.in -portpicker==1.3.1 # via -r requirements.in, mobly -prompt-toolkit==3.0.14 # via ipython -protobuf==3.14.0 # via -r requirements.in -psutil==5.8.0 # via -r requirements.in, mobly -ptyprocess==0.7.0 # via pexpect -pycparser==2.20 # via cffi -pyelftools==0.27 # via -r requirements.in -pygments==2.7.4 # via ipython -pykwalify==1.8.0 # via west -pyparsing==2.3.1 # via -r requirements.in, packaging -pyserial==3.5 # via -r requirements.in, mobly -python-dateutil==2.8.1 # via pykwalify -pyyaml==5.4.1 # via mobly west -requests==2.25.1 # via -r requirements.in -ruamel.yaml.clib==0.2.2 # via ruamel.yaml -ruamel.yaml==0.16.12 # via pykwalify -six==1.15.0 # via cryptography, protobuf, python-dateutil -timeout-decorator==0.5.0 # via mobly -traitlets==5.0.5 # via ipython -urllib3==1.26.3 # via requests -watchdog==1.0.2 # via -r requirements.in -wcwidth==0.2.5 # via prompt-toolkit -west==0.9.0 # via -r requirements.in -wheel==0.34.2 # via -r requirements.in +backcall==0.2.0 + # via ipython +certifi==2020.12.5 + # via requests +cffi==1.14.4 + # via cryptography +chardet==4.0.0 + # via requests +click==7.1.2 + # via + # -r requirements.in + # pip-tools +colorama==0.4.4 + # via west +coloredlogs==15.0 + # via -r requirements.in +cryptography==3.3.2 + # via -r requirements.in +decorator==4.4.2 + # via ipython +docopt==0.6.2 + # via pykwalify +future==0.18.2 + # via + # -r requirements.in + # mobly +humanfriendly==9.1 + # via coloredlogs +idna==2.10 + # via requests +ipython-genutils==0.2.0 + # via traitlets +ipython==7.20.0 + # via -r requirements.in +jedi==0.18.0 + # via ipython +lockfile==0.12.2 + # via -r requirements.in +mobly==1.10.1 + # via -r requirements.in +packaging==20.9 + # via west +parso==0.8.1 + # via jedi +pexpect==4.8.0 + # via ipython +pickleshare==0.7.5 + # via ipython +pip-tools==5.5.0 + # via -r requirements.in +portpicker==1.3.1 + # via + # -r requirements.in + # mobly +prompt-toolkit==3.0.14 + # via ipython +protobuf==3.14.0 + # via -r requirements.in +psutil==5.8.0 + # via + # -r requirements.in + # mobly +ptyprocess==0.7.0 + # via pexpect +pycparser==2.20 + # via cffi +pyelftools==0.27 + # via -r requirements.in +pygments==2.7.4 + # via ipython +pykwalify==1.8.0 + # via west +pyparsing==2.3.1 + # via + # -r requirements.in + # packaging +pyserial==3.5 + # via + # -r requirements.in + # mobly +python-dateutil==2.8.1 + # via pykwalify +pyyaml==5.4.1 + # via + # mobly + # west +requests==2.25.1 + # via -r requirements.in +ruamel.yaml==0.16.12 + # via pykwalify +six==1.15.0 + # via + # cryptography + # protobuf + # python-dateutil +timeout-decorator==0.5.0 + # via mobly +traitlets==5.0.5 + # via ipython +urllib3==1.26.3 + # via requests +watchdog==1.0.2 + # via -r requirements.in +wcwidth==0.2.5 + # via prompt-toolkit +west==0.9.0 + # via -r requirements.in +wheel==0.34.2 + # via -r requirements.in # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/scripts/tests/gn_tests.sh b/scripts/tests/gn_tests.sh index 964a66cc922290..99b9a8913a0fd2 100755 --- a/scripts/tests/gn_tests.sh +++ b/scripts/tests/gn_tests.sh @@ -24,6 +24,13 @@ CHIP_ROOT="$(dirname "$0")/../.." source "$CHIP_ROOT/scripts/activate.sh" +dmalloc=$(gn --root="$CHIP_ROOT" args "$CHIP_ROOT/out/$BUILD_TYPE" --short --list=chip_config_memory_debug_dmalloc) +if [ "x$dmalloc" == "xchip_config_memory_debug_dmalloc = true" ]; then + eval "$(dmalloc -b -l DMALLOC_LOG -i 1 high)" + export G_SLICE + G_SLICE=always-malloc # required for dmalloc compatibility +fi + env set -x diff --git a/src/app/Command.cpp b/src/app/Command.cpp index 41e42518813431..ef9791e809c45b 100644 --- a/src/app/Command.cpp +++ b/src/app/Command.cpp @@ -58,7 +58,7 @@ CHIP_ERROR Command::Reset() if (mCommandMessageBuf.IsNull()) { // TODO: Calculate the packet buffer size - mCommandMessageBuf = System::PacketBufferHandle::New(System::kMaxPacketBufferSize); + mCommandMessageBuf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize); VerifyOrExit(!mCommandMessageBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY); } @@ -145,7 +145,7 @@ void Command::Shutdown() chip::TLV::TLVWriter & Command::CreateCommandDataElementTLVWriter() { - mCommandDataBuf = chip::System::PacketBufferHandle::New(System::kMaxPacketBufferSize); + mCommandDataBuf = chip::System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize); if (mCommandDataBuf.IsNull()) { ChipLogDetail(DataManagement, "Unable to allocate packet buffer"); @@ -275,7 +275,8 @@ CHIP_ERROR Command::FinalizeCommandsMessage() err = mCommandMessageWriter.Finalize(&mCommandMessageBuf); SuccessOrExit(err); - mCommandMessageBuf->EnsureReservedSize(CHIP_SYSTEM_CONFIG_HEADER_RESERVE_SIZE); + VerifyOrExit(mCommandMessageBuf->EnsureReservedSize(System::PacketBuffer::kDefaultHeaderReserve), + err = CHIP_ERROR_BUFFER_TOO_SMALL); exit: ChipLogFunctError(err); diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 8177be01f72311..02356f875e7938 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -48,19 +48,26 @@ using namespace ::chip::Messaging; namespace { -bool isRendezvousBypassed() +constexpr bool isRendezvousBypassed() { - RendezvousInformationFlags rendezvousMode = RendezvousInformationFlags::kBLE; - -#ifdef CONFIG_RENDEZVOUS_MODE - rendezvousMode = static_cast(CONFIG_RENDEZVOUS_MODE); +#if defined(CHIP_BYPASS_RENDEZVOUS) && CHIP_BYPASS_RENDEZVOUS + return true; +#elif defined(CONFIG_RENDEZVOUS_MODE) + return static_cast(CONFIG_RENDEZVOUS_MODE) == RendezvousInformationFlags::kNone; +#else + return false; #endif +} -#ifdef CHIP_BYPASS_RENDEZVOUS - rendezvousMode = RendezvousInformationFlags::kNone; +constexpr bool useTestPairing() +{ +#if defined(CHIP_DEVICE_CONFIG_USE_TEST_PAIRING) && CHIP_DEVICE_CONFIG_USE_TEST_PAIRING + return true; +#else + // Use the test pairing whenever rendezvous is bypassed. Otherwise, there wouldn't be + // any way to communicate with the device using CHIP protocol. + return isRendezvousBypassed(); #endif - - return rendezvousMode == RendezvousInformationFlags::kNone; } // TODO: The following class is setting the discriminator in Persistent Storage. This is @@ -179,7 +186,7 @@ class ServerCallback : public SecureSessionMgrDelegate VerifyOrExit(state->GetPeerNodeId() != kUndefinedNodeId, ChipLogProgress(AppServer, "Unknown source for received message")); - state->GetPeerAddress().ToString(src_addr, sizeof(src_addr)); + state->GetPeerAddress().ToString(src_addr); ChipLogProgress(AppServer, "Packet received from %s: %zu bytes", src_addr, static_cast(data_len)); @@ -395,17 +402,21 @@ void InitServer(AppDelegate * delegate) gSessions.SetDelegate(&gCallbacks); #endif - // This flag is used to bypass BLE in the cirque test - // Only in the cirque test this is enabled with --args='bypass_rendezvous=true' - if (isRendezvousBypassed()) + if (useTestPairing()) { AdminPairingInfo * adminInfo = gAdminPairings.AssignAdminId(gNextAvailableAdminId); VerifyOrExit(adminInfo != nullptr, err = CHIP_ERROR_NO_MEMORY); adminInfo->SetNodeId(chip::kTestDeviceNodeId); - ChipLogProgress(AppServer, "Rendezvous and Secure Pairing skipped. Using test secret."); err = gSessions.NewPairing(peer, chip::kTestControllerNodeId, &gTestPairing, gNextAvailableAdminId); SuccessOrExit(err); } + + // This flag is used to bypass BLE in the cirque test + // Only in the cirque test this is enabled with --args='bypass_rendezvous=true' + if (isRendezvousBypassed()) + { + ChipLogProgress(AppServer, "Rendezvous and secure pairing skipped"); + } else if (DeviceLayer::ConnectivityMgr().IsWiFiStationProvisioned() || DeviceLayer::ConnectivityMgr().IsThreadProvisioned()) { // If the network is already provisioned, proactively disable BLE advertisement. diff --git a/src/app/tests/TestMessageDef.cpp b/src/app/tests/TestMessageDef.cpp index 2425351174aa74..ff4a1350219c8a 100644 --- a/src/app/tests/TestMessageDef.cpp +++ b/src/app/tests/TestMessageDef.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -748,7 +749,7 @@ void AttributePathTest(nlTestSuite * apSuite, void * apContext) AttributePath::Builder attributePathBuilder; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); attributePathBuilder.Init(&writer); BuildAttributePath(apSuite, attributePathBuilder); chip::System::PacketBufferHandle buf; @@ -771,7 +772,7 @@ void AttributePathListTest(nlTestSuite * apSuite, void * apContext) chip::System::PacketBufferTLVReader reader; AttributePathList::Builder attributePathListBuilder; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); err = attributePathListBuilder.Init(&writer); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -796,7 +797,7 @@ void EventPathTest(nlTestSuite * apSuite, void * apContext) EventPath::Builder eventPathBuilder; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); eventPathBuilder.Init(&writer); BuildEventPath(apSuite, eventPathBuilder); chip::System::PacketBufferHandle buf; @@ -820,7 +821,7 @@ void EventPathListTest(nlTestSuite * apSuite, void * apContext) chip::System::PacketBufferTLVReader reader; EventPathList::Builder eventPathListBuilder; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); err = eventPathListBuilder.Init(&writer); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -844,7 +845,7 @@ void CommandPathTest(nlTestSuite * apSuite, void * apContext) chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; CommandPath::Builder commandPathBuilder; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); err = commandPathBuilder.Init(&writer); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -870,7 +871,7 @@ void EventDataElementTest(nlTestSuite * apSuite, void * apContext) EventDataElement::Parser eventDataElementParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); eventDataElementBuilder.Init(&writer); BuildEventDataElement(apSuite, eventDataElementBuilder); chip::System::PacketBufferHandle buf; @@ -893,7 +894,7 @@ void EventListTest(nlTestSuite * apSuite, void * apContext) chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; EventList::Builder eventListBuilder; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); eventListBuilder.Init(&writer); BuildEventList(apSuite, eventListBuilder); chip::System::PacketBufferHandle buf; @@ -915,7 +916,7 @@ void StatusElementTest(nlTestSuite * apSuite, void * apContext) StatusElement::Parser statusElementParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); statusElementBuilder.Init(&writer); BuildStatusElement(apSuite, statusElementBuilder); chip::System::PacketBufferHandle buf; @@ -939,7 +940,7 @@ void AttributeStatusElementTest(nlTestSuite * apSuite, void * apContext) AttributeStatusElement::Parser attributeStatusElementParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); attributeStatusElementBuilder.Init(&writer); BuildAttributeStatusElement(apSuite, attributeStatusElementBuilder); chip::System::PacketBufferHandle buf; @@ -961,7 +962,7 @@ void AttributeStatusListTest(nlTestSuite * apSuite, void * apContext) CHIP_ERROR err = CHIP_NO_ERROR; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); AttributeStatusList::Builder attributeStatusListBuilder; err = attributeStatusListBuilder.Init(&writer); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); @@ -985,7 +986,7 @@ void AttributeDataElementTest(nlTestSuite * apSuite, void * apContext) AttributeDataElement::Parser attributeDataElementParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); attributeDataElementBuilder.Init(&writer); BuildAttributeDataElement(apSuite, attributeDataElementBuilder); chip::System::PacketBufferHandle buf; @@ -1007,7 +1008,7 @@ void AttributeDataListTest(nlTestSuite * apSuite, void * apContext) CHIP_ERROR err = CHIP_NO_ERROR; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); AttributeDataList::Builder attributeDataListBuilder; attributeDataListBuilder.Init(&writer); BuildAttributeDataList(apSuite, attributeDataListBuilder); @@ -1028,7 +1029,7 @@ void AttributeDataVersionListTest(nlTestSuite * apSuite, void * apContext) CHIP_ERROR err = CHIP_NO_ERROR; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); AttributeDataVersionList::Builder attributeDataVersionListBuilder; attributeDataVersionListBuilder.Init(&writer); BuildAttributeDataVersionList(apSuite, attributeDataVersionListBuilder); @@ -1051,7 +1052,7 @@ void CommandDataElementTest(nlTestSuite * apSuite, void * apContext) CommandDataElement::Parser commandDataElementParser; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); commandDataElementBuilder.Init(&writer); BuildCommandDataElement(apSuite, commandDataElementBuilder); chip::System::PacketBufferHandle buf; @@ -1074,7 +1075,7 @@ void CommandListTest(nlTestSuite * apSuite, void * apContext) chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; CommandList::Builder commandListBuilder; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); commandListBuilder.Init(&writer); BuildCommandList(apSuite, commandListBuilder); chip::System::PacketBufferHandle buf; @@ -1094,7 +1095,7 @@ void ReportDataTest(nlTestSuite * apSuite, void * apContext) CHIP_ERROR err = CHIP_NO_ERROR; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); BuildReportData(apSuite, writer); chip::System::PacketBufferHandle buf; err = writer.Finalize(&buf); @@ -1113,7 +1114,7 @@ void InvokeCommandTest(nlTestSuite * apSuite, void * apContext) CHIP_ERROR err = CHIP_NO_ERROR; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); BuildInvokeCommand(apSuite, writer); chip::System::PacketBufferHandle buf; err = writer.Finalize(&buf); @@ -1132,7 +1133,7 @@ void ReadRequestTest(nlTestSuite * apSuite, void * apContext) CHIP_ERROR err = CHIP_NO_ERROR; chip::System::PacketBufferTLVWriter writer; chip::System::PacketBufferTLVReader reader; - writer.Init(chip::System::PacketBufferHandle::New(chip::System::kMaxPacketBufferSize)); + writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize)); BuildReadRequest(apSuite, writer); chip::System::PacketBufferHandle buf; err = writer.Finalize(&buf); @@ -1176,6 +1177,26 @@ const nlTest sTests[] = // clang-format on } // namespace +/** + * Set up the test suite. + */ +static int TestSetup(void * inContext) +{ + CHIP_ERROR error = chip::Platform::MemoryInit(); + if (error != CHIP_NO_ERROR) + return FAILURE; + return SUCCESS; +} + +/** + * Tear down the test suite. + */ +static int TestTeardown(void * inContext) +{ + chip::Platform::MemoryShutdown(); + return SUCCESS; +} + int TestMessageDef() { // clang-format off @@ -1183,8 +1204,8 @@ int TestMessageDef() { "MessageDef", &sTests[0], - nullptr, - nullptr + TestSetup, + TestTeardown, }; // clang-format on diff --git a/src/app/util/chip-message-send.cpp b/src/app/util/chip-message-send.cpp index 72d6263f7f0c40..43b885000e9152 100644 --- a/src/app/util/chip-message-send.cpp +++ b/src/app/util/chip-message-send.cpp @@ -25,7 +25,8 @@ #include #include #include -#include // For SecureSessionMgr +#include +#include using namespace chip; diff --git a/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt b/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt index 53e04c616190bb..bc3a6e178bb91e 100644 --- a/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt +++ b/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt @@ -4,7 +4,7 @@ import ctypes from .ChipStack import * -from .ChipExceptions import * +from .exceptions import * ''' TODO(#4511): This file only sends cluster commands, should add more functions. diff --git a/src/app/zap-templates/zcl/manufacturers.xml b/src/app/zap-templates/zcl/manufacturers.xml index 005614b4cf6c05..1d8f655f924f99 100644 --- a/src/app/zap-templates/zcl/manufacturers.xml +++ b/src/app/zap-templates/zcl/manufacturers.xml @@ -1,5 +1,6 @@