From 101539200d8086f7fae453666a071fd58e760f15 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 22 Sep 2023 00:50:00 +0300 Subject: [PATCH] [Telink] RAM/ROM optimization & Update Telink image to 12 (#29373) * [Telink] Disabled MBEDTLS_TEST and MBEDTLS_ERROR_C (saved 7Kb of flash) * [Telink] Disabled debug logs (saved 11.5Kb of flash) * [Telink] Disable all unused buttons * [Telink] Enable all buttons by default * [Telink] Disable Interaction model Event support in server * [Telink] Reduce number of message buffers in the buffer pool * [Telink] Set packet buffer pool size into 0 * [Telink] Decrease stack and buffer size * [Telink] Update Stack sizes * [Telink] Use B9X * [Telink] Use LAMBDA_EVENT_SIZE minimal value to build OTA * [Telink] Use Kconfigs and make PM dependency * [Telink] Set BLE device name via config * [Telink] Fix after tests * [Telink] decrease some values for FTD as well * [Telink]: Added public BLE MAC readout from vendor flash section The BLE MAC can be generated randomly or read from flash area. * [Telink] Increase BLE_CTRL_THREAD_STACK after B92 BLE stack update * [Telink] Update Telink image to 12 * [Telink] Enable NL_ASSERT_USE_FLAGS by default * [Telink] Increase stack size after OTA tests * [Telink] minor chnages * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .github/workflows/chef.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- config/telink/app/zephyr.conf | 147 ---------- config/telink/chip-gn/args.gni | 4 +- config/telink/chip-module/CMakeLists.txt | 4 + config/telink/chip-module/Kconfig | 24 +- config/telink/chip-module/Kconfig.defaults | 264 ++++++++++++++++++ .../all-clusters-app/telink/CMakeLists.txt | 2 +- examples/all-clusters-app/telink/Kconfig | 19 ++ examples/all-clusters-app/telink/Readme.md | 17 +- .../telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - examples/all-clusters-app/telink/prj.conf | 34 +-- .../all-clusters-app/telink/src/AppTask.cpp | 7 - .../telink/CMakeLists.txt | 2 +- .../all-clusters-minimal-app/telink/Kconfig | 19 ++ .../all-clusters-minimal-app/telink/Readme.md | 17 +- .../telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - .../all-clusters-minimal-app/telink/prj.conf | 37 ++- .../telink/src/AppTask.cpp | 7 - examples/bridge-app/telink/CMakeLists.txt | 2 +- examples/bridge-app/telink/Kconfig | 19 ++ examples/bridge-app/telink/README.md | 17 +- .../bridge-app/telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - examples/bridge-app/telink/prj.conf | 34 +-- examples/bridge-app/telink/src/AppTask.cpp | 7 - examples/bridge-app/telink/src/main.cpp | 82 ------ examples/chef/telink/CHIPProjectConfig.h | 7 - examples/chef/telink/CMakeLists.txt | 2 +- examples/chef/telink/Kconfig | 19 ++ examples/chef/telink/main.cpp | 8 +- examples/chef/telink/prj.conf | 27 +- .../contact-sensor-app/telink/CMakeLists.txt | 2 +- examples/contact-sensor-app/telink/Kconfig | 19 ++ examples/contact-sensor-app/telink/README.md | 17 +- .../telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - examples/contact-sensor-app/telink/prj.conf | 32 +-- .../contact-sensor-app/telink/src/AppTask.cpp | 7 - .../light-switch-app/telink/CMakeLists.txt | 2 +- examples/light-switch-app/telink/Kconfig | 19 ++ examples/light-switch-app/telink/README.md | 17 +- .../telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/light-switch-app/telink/prj.conf | 30 +- .../light-switch-app/telink/src/AppTask.cpp | 7 - examples/lighting-app/telink/CMakeLists.txt | 2 +- examples/lighting-app/telink/Kconfig | 19 ++ examples/lighting-app/telink/README.md | 17 +- .../lighting-app/telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - examples/lighting-app/telink/prj.conf | 30 +- examples/lighting-app/telink/src/AppTask.cpp | 7 - examples/lock-app/telink/CMakeLists.txt | 2 +- examples/lock-app/telink/Kconfig | 19 ++ examples/lock-app/telink/README.md | 17 +- examples/lock-app/telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/lock-app/telink/prj.conf | 30 +- examples/lock-app/telink/src/AppTask.cpp | 7 - examples/lock-app/telink/src/main.cpp | 82 ------ .../ota-requestor-app/telink/CMakeLists.txt | 2 +- examples/ota-requestor-app/telink/Kconfig | 19 ++ examples/ota-requestor-app/telink/Readme.md | 17 +- .../telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - examples/ota-requestor-app/telink/prj.conf | 37 ++- .../ota-requestor-app/telink/src/AppTask.cpp | 7 - .../telink/common/include/AppTaskCommon.h | 2 + .../telink/common/src/AppTaskCommon.cpp | 14 +- .../platform/telink/common/src/mainCommon.cpp | 10 +- .../telink/project_include/OpenThreadConfig.h | 9 +- examples/pump-app/telink/CMakeLists.txt | 2 +- examples/pump-app/telink/Kconfig | 19 ++ examples/pump-app/telink/README.md | 17 +- examples/pump-app/telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/pump-app/telink/prj.conf | 34 +-- examples/pump-app/telink/src/AppTask.cpp | 7 - .../pump-controller-app/telink/CMakeLists.txt | 2 +- examples/pump-controller-app/telink/Kconfig | 19 ++ examples/pump-controller-app/telink/README.md | 17 +- .../telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/pump-controller-app/telink/prj.conf | 30 +- .../telink/src/AppTask.cpp | 7 - .../telink/CMakeLists.txt | 2 +- .../resource-monitoring-app/telink/Kconfig | 19 ++ .../resource-monitoring-app/telink/README.md | 17 +- .../telink/include/AppConfig.h | 1 + .../telink/include/CHIPProjectConfig.h | 7 - .../resource-monitoring-app/telink/prj.conf | 30 +- .../telink/src/AppTask.cpp | 7 - examples/shell/telink/CMakeLists.txt | 2 +- examples/shell/telink/Kconfig | 19 ++ examples/shell/telink/README.md | 17 +- .../shell/telink/include/CHIPProjectConfig.h | 7 - examples/shell/telink/prj.conf | 28 +- .../smoke-co-alarm-app/telink/CMakeLists.txt | 2 +- examples/smoke-co-alarm-app/telink/Kconfig | 19 ++ examples/smoke-co-alarm-app/telink/README.md | 17 +- .../telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/smoke-co-alarm-app/telink/prj.conf | 38 +-- .../smoke-co-alarm-app/telink/src/AppTask.cpp | 7 - .../telink/CMakeLists.txt | 2 +- .../telink/Kconfig | 19 ++ .../telink/README.md | 17 +- .../telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - .../telink/prj.conf | 34 +-- .../telink/src/AppTask.cpp | 7 - examples/thermostat/telink/CMakeLists.txt | 2 +- examples/thermostat/telink/Kconfig | 19 ++ examples/thermostat/telink/Readme.md | 17 +- .../thermostat/telink/include/AppConfig.h | 3 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/thermostat/telink/prj.conf | 30 +- examples/thermostat/telink/src/AppTask.cpp | 7 - examples/window-app/telink/CMakeLists.txt | 2 +- examples/window-app/telink/Kconfig | 19 ++ examples/window-app/telink/README.md | 17 +- .../telink/include/CHIPProjectConfig.h | 7 - examples/window-app/telink/prj.conf | 34 +-- examples/window-app/telink/src/AppTask.cpp | 7 - src/platform/telink/BLEManagerImpl.cpp | 41 ++- .../telink/CHIPDevicePlatformConfig.h | 9 +- src/platform/telink/CHIPPlatformConfig.h | 42 ++- src/platform/telink/SystemPlatformConfig.h | 9 +- src/platform/telink/telink-mbedtls-config.h | 3 + src/platform/telink/tlsr9518adk80d.overlay | 6 +- src/platform/telink/tlsr9528a.overlay | 6 +- 134 files changed, 1084 insertions(+), 1116 deletions(-) delete mode 100644 config/telink/app/zephyr.conf create mode 100644 config/telink/chip-module/Kconfig.defaults create mode 100644 examples/all-clusters-app/telink/Kconfig create mode 100644 examples/all-clusters-minimal-app/telink/Kconfig create mode 100644 examples/bridge-app/telink/Kconfig delete mode 100644 examples/bridge-app/telink/src/main.cpp create mode 100644 examples/chef/telink/Kconfig create mode 100644 examples/contact-sensor-app/telink/Kconfig create mode 100644 examples/light-switch-app/telink/Kconfig create mode 100644 examples/lighting-app/telink/Kconfig create mode 100644 examples/lock-app/telink/Kconfig delete mode 100644 examples/lock-app/telink/src/main.cpp create mode 100644 examples/ota-requestor-app/telink/Kconfig create mode 100644 examples/pump-app/telink/Kconfig create mode 100644 examples/pump-controller-app/telink/Kconfig create mode 100644 examples/resource-monitoring-app/telink/Kconfig create mode 100644 examples/shell/telink/Kconfig create mode 100644 examples/smoke-co-alarm-app/telink/Kconfig create mode 100644 examples/temperature-measurement-app/telink/Kconfig create mode 100644 examples/thermostat/telink/Kconfig create mode 100644 examples/window-app/telink/Kconfig diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index c7268985a200fd..7b62aa4ca1276e 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -96,7 +96,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-telink:10 + image: ghcr.io/project-chip/chip-build-telink:12 options: --user root steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 144af18c4d4d89..29de908f11bd65 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-telink:10 + image: ghcr.io/project-chip/chip-build-telink:12 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/config/telink/app/zephyr.conf b/config/telink/app/zephyr.conf deleted file mode 100644 index 47c2b88f91aa3a..00000000000000 --- a/config/telink/app/zephyr.conf +++ /dev/null @@ -1,147 +0,0 @@ -# -# Copyright (c) 2021-2023 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. -# - -CONFIG_CHIP=y -CONFIG_STD_CPP17=y - -# Logging (set CONFIG_SERIAL to 'y' to enable logging and 'n' to disable logging) -CONFIG_SERIAL=y -CONFIG_LOG=y -CONFIG_LOG_MODE_MINIMAL=y -CONFIG_PRINTK=y -# CONFIG_ASSERT=y -CONFIG_CBPRINTF_LIBC_SUBSTS=y - -# Set the maximum log level (DEBUG) -CONFIG_LOG_DEFAULT_LEVEL=4 -CONFIG_MATTER_LOG_LEVEL_DBG=y -CONFIG_MCUBOOT_BOOTUTIL_LIB=y -CONFIG_MCUBOOT_UTIL_LOG_LEVEL_DBG=y -CONFIG_NET_LOG=y -CONFIG_IEEE802154_DRIVER_LOG_LEVEL_DBG=y -CONFIG_NVS_LOG_LEVEL_DBG=y -CONFIG_OPENTHREAD_LOG_LEVEL_DEBG=y -CONFIG_OPENTHREAD_L2_LOG_LEVEL_DBG=y - -# Set the actual log level -# - 0 OFF, logging is turned off -# - 1 ERROR, maximal level set to LOG_LEVEL_ERR -# - 2 WARNING, maximal level set to LOG_LEVEL_WRN -# - 3 INFO, maximal level set to LOG_LEVEL_INFO -# - 4 DEBUG, maximal level set to LOG_LEVEL_DBG -CONFIG_LOG_MAX_LEVEL=3 - -# Generic networking options -CONFIG_NETWORKING=y -CONFIG_NET_SOCKETS=y -CONFIG_NET_SOCKETS_POSIX_NAMES=n -CONFIG_NET_CONFIG_INIT_TIMEOUT=0 - -# Disable TCP and IPv4 (TCP disabled to avoid heavy traffic) -CONFIG_NET_TCP=n -CONFIG_NET_IPV4=n - -CONFIG_NET_CONFIG_NEED_IPV4=n -CONFIG_NET_CONFIG_MY_IPV4_ADDR="" -CONFIG_NET_CONFIG_PEER_IPV4_ADDR="" - -# Application stack size -CONFIG_MAIN_STACK_SIZE=4096 -CONFIG_INIT_STACKS=y -CONFIG_IDLE_STACK_SIZE=512 - -# Disable certain parts of Zephyr IPv6 stack -CONFIG_NET_IPV6_NBR_CACHE=n -CONFIG_NET_IPV6_MLD=n - -CONFIG_NET_MAX_CONN=1 -CONFIG_NET_MAX_CONTEXTS=1 - -# Network buffers -CONFIG_NET_PKT_RX_COUNT=8 -CONFIG_NET_PKT_TX_COUNT=8 -CONFIG_NET_BUF_RX_COUNT=32 -CONFIG_NET_BUF_TX_COUNT=32 - -# Bluetooth Low Energy configs -CONFIG_BT=y -CONFIG_BT_DEBUG_LOG=n -CONFIG_BT_PERIPHERAL=y -CONFIG_BT_MAX_CONN=1 -CONFIG_BT_DEVICE_NAME_DYNAMIC=y -CONFIG_BT_GATT_DYNAMIC_DB=y -# CONFIG_BT_DEVICE_NAME_MAX=15 -CONFIG_BT_L2CAP_TX_MTU=247 -CONFIG_BT_BUF_ACL_RX_SIZE=251 -CONFIG_BT_BUF_ACL_TX_SIZE=251 - -# L2 OpenThread enabling -CONFIG_NET_L2_OPENTHREAD=y -CONFIG_OPENTHREAD_DEBUG=y -CONFIG_OPENTHREAD_L2_DEBUG=y - -# OpenThread configs -CONFIG_OPENTHREAD_SLAAC=y -CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE=608 -CONFIG_OPENTHREAD_MANUAL_START=y - -# mbedTLS tweaks -CONFIG_MBEDTLS_TEST=y -CONFIG_MBEDTLS_PKCS5_C=y -CONFIG_MBEDTLS_USER_CONFIG_ENABLE=y -CONFIG_MBEDTLS_USER_CONFIG_FILE="telink-mbedtls-config.h" - -# TBD: Something wrong with this heap. Need to be investigated. Cirrently just set minimal size -CONFIG_MBEDTLS_HEAP_SIZE=0 -CONFIG_OPENTHREAD_EXTERNAL_HEAP=y - -# Config dynamic interrupts to have posibility to switch between BLE/Thread radio drivers -CONFIG_DYNAMIC_INTERRUPTS=y - -# Set multiplicator of Name Value Storage (NVS) as 1 to reach NVS sector size 4KB -# nvs_sector_size = flash_page_size * mult = 4KB * 1 = 4KB -CONFIG_SETTINGS_NVS_SECTOR_SIZE_MULT=1 - -# Enable NVS lookup cache -CONFIG_NVS_LOOKUP_CACHE=y -CONFIG_NVS_LOOKUP_CACHE_SIZE=2048 - -# Reboot system when fault happened -CONFIG_TELINK_B9X_REBOOT_ON_FAULT=y - -# Shell settings -CONFIG_SHELL=n - -# BLE MAC address -CONFIG_B9X_BLE_CTRL_MAC_FLASH_ADDR=0x1FE000 - -# getopt version -CONFIG_GETOPT_LONG=y - -# flash stream functionality -CONFIG_STREAM_FLASH=y -CONFIG_STREAM_FLASH_ERASE=y - -# In current config/zephyr/Kconfig -# next deprecated values are selected -# warning: Deprecated symbol CPLUSPLUS is enabled. -# warning: Deprecated symbol LIB_CPLUSPLUS is enabled. -# new one are: -# CONFIG_CPP -# CONFIG_LIBCPP_IMPLEMENTATION -# See https://docs.zephyrproject.org/latest/releases/release-notes-3.3.html -# Since not only Telink is using Zephyr just suppress warnings -CONFIG_WARN_DEPRECATED=n diff --git a/config/telink/chip-gn/args.gni b/config/telink/chip-gn/args.gni index 504db8fdd73246..eeb1695d45ee49 100644 --- a/config/telink/chip-gn/args.gni +++ b/config/telink/chip-gn/args.gni @@ -20,8 +20,8 @@ chip_device_platform = "telink" chip_build_tests = false -chip_project_config_include = "" -chip_system_project_config_include = "" +chip_project_config_include = "" +chip_system_project_config_include = "" chip_ble_project_config_include = "" chip_crypto = "mbedtls" diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 1ebe7bb91ce844..6946aa64b11498 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -52,6 +52,8 @@ if (CONFIG_POSIX_API) matter_add_flags(-isystem${ZEPHYR_BASE}/include/zephyr/posix) endif() +matter_add_flags(-DNL_ASSERT_USE_FLAGS_DEFAULT=1) + zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/) zephyr_get_compile_flags(ZEPHYR_CFLAGS_C C) @@ -61,6 +63,8 @@ matter_add_cxxflags("${ZEPHYR_CFLAGS_CC}") zephyr_get_gnu_cpp_standard(ZEPHYR_GNU_CPP_STD) matter_add_cxxflags(${ZEPHYR_GNU_CPP_STD}) +matter_add_flags(-DMBEDTLS_USER_CONFIG_FILE=) + # Set up custom OpenThread configuration if (CONFIG_CHIP_OPENTHREAD_CONFIG) diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index fb1f20e0dfbc63..513b2c04306290 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -16,9 +16,11 @@ rsource "../../zephyr/Kconfig" +if CHIP + # See config/zephyr/Kconfig for full definition config CHIP_DEVICE_VENDOR_NAME - default "Telink semiconductor" + default "Telink Semiconductor" config CHIP_APP_LOG_LEVEL int "Logging level in application" @@ -33,17 +35,18 @@ config CHIP_APP_LOG_LEVEL # See config/zephyr/Kconfig for full definition config CHIP_OTA_REQUESTOR bool - default y - imply BOOTLOADER_MCUBOOT - imply IMG_MANAGER + select BOOTLOADER_MCUBOOT + select IMG_MANAGER + select STREAM_FLASH + select STREAM_FLASH_ERASE config CHIP_OTA_REQUESTOR_BUFFER_SIZE int "OTA Requestor image buffer size" default 256 depends on CHIP_OTA_REQUESTOR help - Configures size of the buffer used by OTA Requestor when downloading and - writing a new firmware image to flash. + Configures the size of the buffer used by OTA Requestor when downloading + and writing a new firmware image to flash. config CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY bool "Auto-reboot when firmware update is applied" @@ -51,9 +54,9 @@ config CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY depends on CHIP_OTA_REQUESTOR imply REBOOT help - When a user consents to apply a firmware update, and the update package is - downloaded, reboot the device automatically to swap the old and the new - firmware images. + Reboots the device automatically after downloading a new firmware update + to swap the old and the new firmware images. The reboot happens only when + a user consents to apply the firmware update. # See config/zephyr/Kconfig for full definition config CHIP_OTA_IMAGE_BUILD @@ -149,9 +152,10 @@ config CHIP_FACTORY_RESET_ERASE_NVS bool default n +endif + config CHIP_LOG_SIZE_OPTIMIZATION bool "Disable some detailed logs to decrease flash usage" - default y help Disables some log levels for specific Matter log modules that provide information that is too detailed to be used in most cases. You can find diff --git a/config/telink/chip-module/Kconfig.defaults b/config/telink/chip-module/Kconfig.defaults new file mode 100644 index 00000000000000..d8312e18c62f3e --- /dev/null +++ b/config/telink/chip-module/Kconfig.defaults @@ -0,0 +1,264 @@ +# +# Copyright (c) 2023 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. +# + +# The purpose of this file is to define new default values of settings used when building Matter samples. +# This file only changes defaults and thus all symbols here must be promptless +# and safeguarded so that they only are applied when building Matter. + +if CHIP + +config LOG + default y + +if LOG + +choice LOG_MODE + default LOG_MODE_MINIMAL +endchoice + +choice MATTER_LOG_LEVEL_CHOICE + default MATTER_LOG_LEVEL_INF +endchoice + +config CHIP_APP_LOG_LEVEL + default 3 # info + +config LOG_DEFAULT_LEVEL + default 1 # error + +config CHIP_LOG_SIZE_OPTIMIZATION + default y + +endif + +config SHELL + default y if CHIP_LIB_SHELL + +config PTHREAD_IPC + bool + default n + +config POSIX_MAX_FDS + int + default 16 + +# Application stack size +config MAIN_STACK_SIZE + default 3240 if PM + default 4096 + +config INIT_STACKS + default y + +config IDLE_STACK_SIZE + default 387 if PM + +config ISR_STACK_SIZE + default 502 if PM + +config SYSTEM_WORKQUEUE_STACK_SIZE + default 616 if PM + +config HEAP_MEM_POOL_SIZE + default 128 if PM + +config NET_IPV6_MLD + default n + +# Network buffers +config NET_PKT_RX_COUNT + default 4 if PM + default 8 + +config NET_PKT_TX_COUNT + default 4 if PM + default 8 + +config NET_BUF_RX_COUNT + default 16 if PM + default 32 + +config NET_BUF_TX_COUNT + default 16 if PM + default 32 + +# Bluetooth Low Energy configs + +config BT + default y + +config BT_PERIPHERAL + default y + +config BT_GATT_DYNAMIC_DB + default y + +config BT_DEVICE_NAME_DYNAMIC + default y + +config BT_DEVICE_NAME_MAX + default 15 + +config BT_MAX_CONN + default 1 + +config BT_L2CAP_TX_MTU + default 247 + +config BT_BUF_ACL_RX_SIZE + default 251 + +config BT_BUF_ACL_TX_SIZE + default 251 + +config BT_RX_STACK_SIZE + default 810 + +config BT_HCI_TX_STACK_SIZE + default 640 + +config BT_DEVICE_NAME_GATT_WRITABLE + bool + default n + +config B9X_BLE_CTRL_THREAD_STACK_SIZE + default 576 + +config B9X_BLE_CTRL_MASTER_MAX_NUM + default 0 + +config B9X_BLE_CTRL_SLAVE_MAX_NUM + default 1 + +choice B9X_BLE_CTRL_MAC_TYPE + default B9X_BLE_CTRL_MAC_TYPE_RANDOM_STATIC +endchoice + +# Config dynamic interrupts to have posibility to switch between BLE/Thread radio drivers +config DYNAMIC_INTERRUPTS + default y + +config CHIP_OTA_REQUESTOR + default y + +# In current config/zephyr/Kconfig +# next deprecated values are selected +# warning: Deprecated symbol CPLUSPLUS is enabled. +# warning: Deprecated symbol LIB_CPLUSPLUS is enabled. +# new one are: +# CONFIG_CPP +# CONFIG_LIBCPP_IMPLEMENTATION +# See https://docs.zephyrproject.org/latest/releases/release-notes-3.3.html +# Since not only Telink is using Zephyr just suppress warnings +config WARN_DEPRECATED + default n + +# Reboot system when fault happened +config TELINK_B9X_REBOOT_ON_FAULT + default y + +config NVS_LOOKUP_CACHE + default y + +config NVS_LOOKUP_CACHE_SIZE + default 2048 if !PM + +# Set multiplicator of Name Value Storage (NVS) as 1 to reach NVS sector size 4KB +# nvs_sector_size = flash_page_size * mult = 4KB * 1 = 4KB +config SETTINGS_NVS_SECTOR_SIZE_MULT + default 1 + +# Enable OpenThread + +config NET_L2_OPENTHREAD + default y + +choice CHIP_THREAD_DEVICE_ROLE + prompt "Thread network device role" + default CHIP_THREAD_DEVICE_ROLE_ROUTER +config CHIP_THREAD_DEVICE_ROLE_ROUTER + depends on !PM + bool "thread device router" +config CHIP_THREAD_DEVICE_ROLE_END_DEVICE + depends on !PM + bool "thread end device" +config CHIP_THREAD_DEVICE_ROLE_SLEEPY_END_DEVICE + bool "thread sleepy end device" +endchoice + +choice OPENTHREAD_DEVICE_TYPE + default OPENTHREAD_FTD if CHIP_THREAD_DEVICE_ROLE_ROUTER + default OPENTHREAD_MTD if CHIP_THREAD_DEVICE_ROLE_END_DEVICE || CHIP_THREAD_DEVICE_ROLE_SLEEPY_END_DEVICE +endchoice + +config CHIP_ENABLE_ICD_SUPPORT + default y if CHIP_THREAD_DEVICE_ROLE_SLEEPY_END_DEVICE + +config OPENTHREAD_THREAD_STACK_SIZE + default 2178 if PM + +config OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE + default 361 if PM + default 608 + +config OPENTHREAD_SLAAC + default y + +config OPENTHREAD_MANUAL_START + default y + +config NET_TX_STACK_SIZE + default 554 if PM + +config NET_RX_STACK_SIZE + default 554 if PM + +# Disable certain parts of Zephyr IPv6 stack +config NET_IPV6_NBR_CACHE + bool + default n + +config NET_MAX_CONN + default 1 + +config NET_MAX_CONTEXTS + default 1 + +config NET_CONFIG_INIT_TIMEOUT + default 0 + +# mbedTLS tweaks +config MBEDTLS_USER_CONFIG_ENABLE + default y + +config MBEDTLS_USER_CONFIG_FILE + default "telink-mbedtls-config.h" + +config MBEDTLS_ENABLE_HEAP + default y + +# TBD: Something wrong with this heap. Need to be investigated. Cirrently just set minimal size +config MBEDTLS_HEAP_SIZE + default 0 + +config OPENTHREAD_EXTERNAL_HEAP + default y + +# getopt version +config GETOPT_LONG + default y + +endif diff --git a/examples/all-clusters-app/telink/CMakeLists.txt b/examples/all-clusters-app/telink/CMakeLists.txt index 7ca03211176776..fbc0b756eda8c3 100644 --- a/examples/all-clusters-app/telink/CMakeLists.txt +++ b/examples/all-clusters-app/telink/CMakeLists.txt @@ -41,7 +41,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/all-clusters-app/telink/Kconfig b/examples/all-clusters-app/telink/Kconfig new file mode 100644 index 00000000000000..3b3aa6b63f7cd4 --- /dev/null +++ b/examples/all-clusters-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink All Clusters Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/all-clusters-app/telink/Readme.md b/examples/all-clusters-app/telink/Readme.md index 3684a8cf432eb2..d83ba75fb1353b 100644 --- a/examples/all-clusters-app/telink/Readme.md +++ b/examples/all-clusters-app/telink/Readme.md @@ -8,35 +8,32 @@ creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/all-clusters-app/telink/include/AppConfig.h b/examples/all-clusters-app/telink/include/AppConfig.h index bf3fcd959f86e2..0329fd5f8a4392 100644 --- a/examples/all-clusters-app/telink/include/AppConfig.h +++ b/examples/all-clusters-app/telink/include/AppConfig.h @@ -20,6 +20,7 @@ // ---- All Clusters Application example config ---- #define APP_USE_EXAMPLE_START_BUTTON 0 +#define APP_USE_BLE_START_BUTTON 0 #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1 diff --git a/examples/all-clusters-app/telink/include/CHIPProjectConfig.h b/examples/all-clusters-app/telink/include/CHIPProjectConfig.h index e641615c721cc4..2f13c56a437d51 100644 --- a/examples/all-clusters-app/telink/include/CHIPProjectConfig.h +++ b/examples/all-clusters-app/telink/include/CHIPProjectConfig.h @@ -31,13 +31,6 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 - // All clusters app has 3 group endpoints. This needs to defined here so that // CHIP_CONFIG_MAX_GROUPS_PER_FABRIC is properly configured. #define CHIP_CONFIG_MAX_GROUP_ENDPOINTS_PER_FABRIC 3 diff --git a/examples/all-clusters-app/telink/prj.conf b/examples/all-clusters-app/telink/prj.conf index 1ae6d5b5cec6a3..8551f44e560424 100644 --- a/examples/all-clusters-app/telink/prj.conf +++ b/examples/all-clusters-app/telink/prj.conf @@ -18,48 +18,44 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=n -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # CHIP PID: 32769 == 0x8001 (all-clusters-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkApp" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n # Enable Power Management CONFIG_PM=n + +# Custom RF power values +CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y +CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/all-clusters-app/telink/src/AppTask.cpp b/examples/all-clusters-app/telink/src/AppTask.cpp index 74f1c4c3ec7494..03b81fb434a8ef 100644 --- a/examples/all-clusters-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-app/telink/src/AppTask.cpp @@ -35,12 +35,5 @@ CHIP_ERROR AppTask::Init(void) return err; } - err = ConnectivityMgr().SetBLEDeviceName("TelinkApp"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/all-clusters-minimal-app/telink/CMakeLists.txt b/examples/all-clusters-minimal-app/telink/CMakeLists.txt index d852f1534d0d73..ec296891479d16 100644 --- a/examples/all-clusters-minimal-app/telink/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/telink/CMakeLists.txt @@ -41,7 +41,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/all-clusters-minimal-app/telink/Kconfig b/examples/all-clusters-minimal-app/telink/Kconfig new file mode 100644 index 00000000000000..62c721153f258e --- /dev/null +++ b/examples/all-clusters-minimal-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink All Clusters Minimal Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/all-clusters-minimal-app/telink/Readme.md b/examples/all-clusters-minimal-app/telink/Readme.md index 96d8dfc751ccf1..aa751fecabea42 100644 --- a/examples/all-clusters-minimal-app/telink/Readme.md +++ b/examples/all-clusters-minimal-app/telink/Readme.md @@ -8,35 +8,32 @@ for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/all-clusters-minimal-app/telink/include/AppConfig.h b/examples/all-clusters-minimal-app/telink/include/AppConfig.h index 0575d9a70693a3..7cd1d6e62a3fc7 100644 --- a/examples/all-clusters-minimal-app/telink/include/AppConfig.h +++ b/examples/all-clusters-minimal-app/telink/include/AppConfig.h @@ -21,6 +21,7 @@ // ---- All Clusters Minimal Application example config ---- #define APP_USE_EXAMPLE_START_BUTTON 0 +#define APP_USE_BLE_START_BUTTON 0 #define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 0 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1 diff --git a/examples/all-clusters-minimal-app/telink/include/CHIPProjectConfig.h b/examples/all-clusters-minimal-app/telink/include/CHIPProjectConfig.h index 2fda70c57da9dc..280c26e78b46bf 100644 --- a/examples/all-clusters-minimal-app/telink/include/CHIPProjectConfig.h +++ b/examples/all-clusters-minimal-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/all-clusters-minimal-app/telink/prj.conf b/examples/all-clusters-minimal-app/telink/prj.conf index c7e50cd1c89afc..0e540f339d8d1f 100644 --- a/examples/all-clusters-minimal-app/telink/prj.conf +++ b/examples/all-clusters-minimal-app/telink/prj.conf @@ -18,43 +18,42 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=n -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # CHIP PID: 32769 == 0x8001 (all-clusters-minimal-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkMinApp" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n + +# Enable Power Management +CONFIG_PM=n + +# Custom RF power values +CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y +CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp index 93a83af0dbf44b..55d46154f98fad 100644 --- a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp @@ -35,12 +35,5 @@ CHIP_ERROR AppTask::Init() return err; } - err = ConnectivityMgr().SetBLEDeviceName("TelinkMinApp"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/bridge-app/telink/CMakeLists.txt b/examples/bridge-app/telink/CMakeLists.txt index 58ed38fd93ba89..588b4f7bbdf5b1 100644 --- a/examples/bridge-app/telink/CMakeLists.txt +++ b/examples/bridge-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/bridge-app/telink/Kconfig b/examples/bridge-app/telink/Kconfig new file mode 100644 index 00000000000000..389351288d7666 --- /dev/null +++ b/examples/bridge-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Bridge Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/bridge-app/telink/README.md b/examples/bridge-app/telink/README.md index 159516fcf9e476..48ae3eaec0a6e6 100644 --- a/examples/bridge-app/telink/README.md +++ b/examples/bridge-app/telink/README.md @@ -85,35 +85,32 @@ defined: ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/bridge-app/telink/include/AppConfig.h b/examples/bridge-app/telink/include/AppConfig.h index bb380991b813a4..15a358a2920abe 100644 --- a/examples/bridge-app/telink/include/AppConfig.h +++ b/examples/bridge-app/telink/include/AppConfig.h @@ -21,6 +21,7 @@ // ---- Bridge App Example Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 diff --git a/examples/bridge-app/telink/include/CHIPProjectConfig.h b/examples/bridge-app/telink/include/CHIPProjectConfig.h index 824acd90d46cbe..b896bb262aa20d 100644 --- a/examples/bridge-app/telink/include/CHIPProjectConfig.h +++ b/examples/bridge-app/telink/include/CHIPProjectConfig.h @@ -35,10 +35,3 @@ // Until this is improved in OpenThread we need to increase the retransmission // interval to survive the stall. #define CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL (1000_ms32) - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/bridge-app/telink/prj.conf b/examples/bridge-app/telink/prj.conf index e05717bf080a4b..fa580fce1076c5 100644 --- a/examples/bridge-app/telink/prj.conf +++ b/examples/bridge-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=n -CONFIG_CHIP_ENABLE_ICD_SUPPORT=n -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 -# 32769 == 0x8001 (example all-clusters-app), otherwise GoogleHome fails commissioning -CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +# 32770 == 0x8002 (example bridge-app) +CONFIG_CHIP_DEVICE_PRODUCT_ID=32770 + +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkBridge" +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index 52608062ac1a12..eff00fe9cffebe 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -413,13 +413,6 @@ CHIP_ERROR AppTask::Init(void) #endif InitCommonParts(); - err = ConnectivityMgr().SetBLEDeviceName("TelinkLight"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - memset(gDevices, 0, sizeof(gDevices)); gLight1.SetReachable(true); diff --git a/examples/bridge-app/telink/src/main.cpp b/examples/bridge-app/telink/src/main.cpp deleted file mode 100644 index 71aa52f9d91901..00000000000000 --- a/examples/bridge-app/telink/src/main.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright (c) 2023 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 "AppTask.h" - -#include -#include - -#include - -LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); - -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; - -int main(void) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - err = chip::Platform::MemoryInit(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("MemoryInit fail"); - goto exit; - } - - err = PlatformMgr().InitChipStack(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("InitChipStack fail"); - goto exit; - } - - err = PlatformMgr().StartEventLoopTask(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("StartEventLoopTask fail"); - goto exit; - } - - err = ThreadStackMgr().InitThreadStack(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("InitThreadStack fail"); - goto exit; - } - -#ifdef CONFIG_OPENTHREAD_MTD_SED - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); -#elif CONFIG_OPENTHREAD_MTD - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); -#else - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); -#endif - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetThreadDeviceType fail"); - goto exit; - } - - err = GetAppTask().StartApp(); - -exit: - LOG_ERR("Exit err %" CHIP_ERROR_FORMAT, err.Format()); - return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/examples/chef/telink/CHIPProjectConfig.h b/examples/chef/telink/CHIPProjectConfig.h index 27aa5c0b14517a..d1d9b02dc9b1c1 100755 --- a/examples/chef/telink/CHIPProjectConfig.h +++ b/examples/chef/telink/CHIPProjectConfig.h @@ -31,13 +31,6 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 - // Enable support functions for parsing command-line arguments #define CHIP_CONFIG_ENABLE_ARG_PARSER 1 diff --git a/examples/chef/telink/CMakeLists.txt b/examples/chef/telink/CMakeLists.txt index e5216ef566359e..10b2eec74c8961 100755 --- a/examples/chef/telink/CMakeLists.txt +++ b/examples/chef/telink/CMakeLists.txt @@ -47,7 +47,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/chef/telink/Kconfig b/examples/chef/telink/Kconfig new file mode 100644 index 00000000000000..b22d85cbd499f9 --- /dev/null +++ b/examples/chef/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Chef Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/chef/telink/main.cpp b/examples/chef/telink/main.cpp index 2df1c8378d0f78..088dd22a481063 100644 --- a/examples/chef/telink/main.cpp +++ b/examples/chef/telink/main.cpp @@ -76,10 +76,14 @@ int main() return 1; } -#ifdef CONFIG_OPENTHREAD_MTD +#if defined(CONFIG_CHIP_THREAD_DEVICE_ROLE_ROUTER) + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#elif defined(CONFIG_CHIP_THREAD_DEVICE_ROLE_END_DEVICE) err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#elif defined(CONFIG_CHIP_THREAD_DEVICE_ROLE_SLEEPY_END_DEVICE) + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#error THREAD_DEVICE_ROLE not selected #endif if (err != CHIP_NO_ERROR) { diff --git a/examples/chef/telink/prj.conf b/examples/chef/telink/prj.conf index 2104d0aaf3a999..9a15c1d2ac621e 100755 --- a/examples/chef/telink/prj.conf +++ b/examples/chef/telink/prj.conf @@ -18,47 +18,36 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32774 == 0x8006 (example contact-sensor-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2023" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n CONFIG_OPENTHREAD_SHELL=n CONFIG_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/contact-sensor-app/telink/CMakeLists.txt b/examples/contact-sensor-app/telink/CMakeLists.txt index 2a6e63cbc284da..154cfcc18678dc 100755 --- a/examples/contact-sensor-app/telink/CMakeLists.txt +++ b/examples/contact-sensor-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/contact-sensor-app/telink/Kconfig b/examples/contact-sensor-app/telink/Kconfig new file mode 100644 index 00000000000000..0a718e198e73a7 --- /dev/null +++ b/examples/contact-sensor-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Contact Sensor Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/contact-sensor-app/telink/README.md b/examples/contact-sensor-app/telink/README.md index 21c3c045f23f2d..3131839f440452 100755 --- a/examples/contact-sensor-app/telink/README.md +++ b/examples/contact-sensor-app/telink/README.md @@ -6,35 +6,32 @@ You can use this example as a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/contact-sensor-app/telink/include/AppConfig.h b/examples/contact-sensor-app/telink/include/AppConfig.h index e124b65eddd2fc..bd38d80b41282d 100644 --- a/examples/contact-sensor-app/telink/include/AppConfig.h +++ b/examples/contact-sensor-app/telink/include/AppConfig.h @@ -20,6 +20,7 @@ // ---- All Clusters Application example config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 #define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 diff --git a/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h b/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h index 2fda70c57da9dc..280c26e78b46bf 100755 --- a/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h +++ b/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/contact-sensor-app/telink/prj.conf b/examples/contact-sensor-app/telink/prj.conf index f5695b45866f39..8eea50ee19b9e4 100755 --- a/examples/contact-sensor-app/telink/prj.conf +++ b/examples/contact-sensor-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32774 == 0x8006 (example contact-sensor-app) -CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +CONFIG_CHIP_DEVICE_PRODUCT_ID=32774 + +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkSensor" +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/contact-sensor-app/telink/src/AppTask.cpp b/examples/contact-sensor-app/telink/src/AppTask.cpp index 3ee4cd19d30a60..ba6a8d8118a897 100644 --- a/examples/contact-sensor-app/telink/src/AppTask.cpp +++ b/examples/contact-sensor-app/telink/src/AppTask.cpp @@ -49,13 +49,6 @@ CHIP_ERROR AppTask::Init(void) ContactSensorMgr().SetCallback(OnStateChanged); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("TelinkSensor"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/light-switch-app/telink/CMakeLists.txt b/examples/light-switch-app/telink/CMakeLists.txt index d05508812f04e9..5312e902907138 100755 --- a/examples/light-switch-app/telink/CMakeLists.txt +++ b/examples/light-switch-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/light-switch-app/telink/Kconfig b/examples/light-switch-app/telink/Kconfig new file mode 100644 index 00000000000000..362322abd82a48 --- /dev/null +++ b/examples/light-switch-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Light Switch Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/light-switch-app/telink/README.md b/examples/light-switch-app/telink/README.md index 6e0cda2bcbf644..10e2500ab457fd 100755 --- a/examples/light-switch-app/telink/README.md +++ b/examples/light-switch-app/telink/README.md @@ -11,35 +11,32 @@ creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/light-switch-app/telink/include/AppConfig.h b/examples/light-switch-app/telink/include/AppConfig.h index 4a9877dea54768..3ee892f2494bad 100644 --- a/examples/light-switch-app/telink/include/AppConfig.h +++ b/examples/light-switch-app/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Light Switch Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/light-switch-app/telink/include/CHIPProjectConfig.h b/examples/light-switch-app/telink/include/CHIPProjectConfig.h index 2fda70c57da9dc..280c26e78b46bf 100755 --- a/examples/light-switch-app/telink/include/CHIPProjectConfig.h +++ b/examples/light-switch-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/light-switch-app/telink/prj.conf b/examples/light-switch-app/telink/prj.conf index 7d97baca2ee0cd..184e824904c519 100755 --- a/examples/light-switch-app/telink/prj.conf +++ b/examples/light-switch-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32772 == 0x8004 (example light-switch-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32772 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkSwitch" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/light-switch-app/telink/src/AppTask.cpp b/examples/light-switch-app/telink/src/AppTask.cpp index b78a09d547d478..1a21866cf6bd6b 100644 --- a/examples/light-switch-app/telink/src/AppTask.cpp +++ b/examples/light-switch-app/telink/src/AppTask.cpp @@ -38,13 +38,6 @@ CHIP_ERROR AppTask::Init(void) return err; } - err = ConnectivityMgr().SetBLEDeviceName("TelinkSwitch"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index 986338c723651b..f4a0edd1636734 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -57,7 +57,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${USB_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf ${USB_CONF_OVERLAY_FILE} prj.conf) +set(CONF_FILE ${USB_CONF_OVERLAY_FILE} prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/lighting-app/telink/Kconfig b/examples/lighting-app/telink/Kconfig new file mode 100644 index 00000000000000..837d26f52c26ce --- /dev/null +++ b/examples/lighting-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Lighting Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/lighting-app/telink/README.md b/examples/lighting-app/telink/README.md index e774a8b1ecf87a..b09df9c49fe3aa 100644 --- a/examples/lighting-app/telink/README.md +++ b/examples/lighting-app/telink/README.md @@ -9,35 +9,32 @@ a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/lighting-app/telink/include/AppConfig.h b/examples/lighting-app/telink/include/AppConfig.h index 883935907a474e..e677ba3a2ef7db 100644 --- a/examples/lighting-app/telink/include/AppConfig.h +++ b/examples/lighting-app/telink/include/AppConfig.h @@ -21,6 +21,7 @@ // ---- Lighting Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 1 #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 diff --git a/examples/lighting-app/telink/include/CHIPProjectConfig.h b/examples/lighting-app/telink/include/CHIPProjectConfig.h index 76d4372a80703f..830ad45de5816d 100644 --- a/examples/lighting-app/telink/include/CHIPProjectConfig.h +++ b/examples/lighting-app/telink/include/CHIPProjectConfig.h @@ -35,10 +35,3 @@ // Until this is improved in OpenThread we need to increase the retransmission // interval to survive the stall. #define CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL (1000_ms32) - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/lighting-app/telink/prj.conf b/examples/lighting-app/telink/prj.conf index 79e2714b0fc2a7..c5371f92565214 100644 --- a/examples/lighting-app/telink/prj.conf +++ b/examples/lighting-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=n -CONFIG_CHIP_ENABLE_ICD_SUPPORT=n -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32773 == 0x8005 (example lighting-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32773 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkLight" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 1d1f3b748a97fb..21f0257b12a6e2 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -90,13 +90,6 @@ CHIP_ERROR AppTask::Init(void) #endif InitCommonParts(); - err = ConnectivityMgr().SetBLEDeviceName("TelinkLight"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/lock-app/telink/CMakeLists.txt b/examples/lock-app/telink/CMakeLists.txt index 66f5e432f96d92..702648dab2daa0 100755 --- a/examples/lock-app/telink/CMakeLists.txt +++ b/examples/lock-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/lock-app/telink/Kconfig b/examples/lock-app/telink/Kconfig new file mode 100644 index 00000000000000..5238b4423a4196 --- /dev/null +++ b/examples/lock-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Lock Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/lock-app/telink/README.md b/examples/lock-app/telink/README.md index b215fa543839dc..9cca961b6262f6 100755 --- a/examples/lock-app/telink/README.md +++ b/examples/lock-app/telink/README.md @@ -9,35 +9,32 @@ a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/lock-app/telink/include/AppConfig.h b/examples/lock-app/telink/include/AppConfig.h index a2bddab66cecef..5c5eb8819cdd68 100644 --- a/examples/lock-app/telink/include/AppConfig.h +++ b/examples/lock-app/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Lock Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/lock-app/telink/include/CHIPProjectConfig.h b/examples/lock-app/telink/include/CHIPProjectConfig.h index 412932a59c3726..8465c19cdd0537 100755 --- a/examples/lock-app/telink/include/CHIPProjectConfig.h +++ b/examples/lock-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/lock-app/telink/prj.conf b/examples/lock-app/telink/prj.conf index 58aaca9b95d593..7b160ed7259367 100755 --- a/examples/lock-app/telink/prj.conf +++ b/examples/lock-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32774 == 0x8006 (example lock-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32774 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkLock" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/lock-app/telink/src/AppTask.cpp b/examples/lock-app/telink/src/AppTask.cpp index 589354f1a53aa8..bf7fc3311cd0e8 100644 --- a/examples/lock-app/telink/src/AppTask.cpp +++ b/examples/lock-app/telink/src/AppTask.cpp @@ -50,13 +50,6 @@ CHIP_ERROR AppTask::Init(void) // Disable auto-relock time feature. DoorLockServer::Instance().SetAutoRelockTime(kExampleEndpointId, 0); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("Telink Lock"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/lock-app/telink/src/main.cpp b/examples/lock-app/telink/src/main.cpp deleted file mode 100644 index 71aa52f9d91901..00000000000000 --- a/examples/lock-app/telink/src/main.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright (c) 2023 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 "AppTask.h" - -#include -#include - -#include - -LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); - -using namespace ::chip; -using namespace ::chip::Inet; -using namespace ::chip::DeviceLayer; - -int main(void) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - err = chip::Platform::MemoryInit(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("MemoryInit fail"); - goto exit; - } - - err = PlatformMgr().InitChipStack(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("InitChipStack fail"); - goto exit; - } - - err = PlatformMgr().StartEventLoopTask(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("StartEventLoopTask fail"); - goto exit; - } - - err = ThreadStackMgr().InitThreadStack(); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("InitThreadStack fail"); - goto exit; - } - -#ifdef CONFIG_OPENTHREAD_MTD_SED - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); -#elif CONFIG_OPENTHREAD_MTD - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); -#else - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); -#endif - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetThreadDeviceType fail"); - goto exit; - } - - err = GetAppTask().StartApp(); - -exit: - LOG_ERR("Exit err %" CHIP_ERROR_FORMAT, err.Format()); - return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE; -} diff --git a/examples/ota-requestor-app/telink/CMakeLists.txt b/examples/ota-requestor-app/telink/CMakeLists.txt index 5d88c0c504121f..b3558357cc59c8 100644 --- a/examples/ota-requestor-app/telink/CMakeLists.txt +++ b/examples/ota-requestor-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/ota-requestor-app/telink/Kconfig b/examples/ota-requestor-app/telink/Kconfig new file mode 100644 index 00000000000000..247094820c73a8 --- /dev/null +++ b/examples/ota-requestor-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink OTA Requestor Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/ota-requestor-app/telink/Readme.md b/examples/ota-requestor-app/telink/Readme.md index c04bbfcb463550..805f70a0d5435c 100755 --- a/examples/ota-requestor-app/telink/Readme.md +++ b/examples/ota-requestor-app/telink/Readme.md @@ -2,35 +2,32 @@ ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/ota-requestor-app/telink/include/AppConfig.h b/examples/ota-requestor-app/telink/include/AppConfig.h index 9e44f45a989c25..9cda66df104ff7 100644 --- a/examples/ota-requestor-app/telink/include/AppConfig.h +++ b/examples/ota-requestor-app/telink/include/AppConfig.h @@ -21,6 +21,7 @@ // ---- OTA Requestor Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 0 +#define APP_USE_BLE_START_BUTTON 0 #define APP_USE_THREAD_START_BUTTON 1 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 1 diff --git a/examples/ota-requestor-app/telink/include/CHIPProjectConfig.h b/examples/ota-requestor-app/telink/include/CHIPProjectConfig.h index 2fda70c57da9dc..280c26e78b46bf 100644 --- a/examples/ota-requestor-app/telink/include/CHIPProjectConfig.h +++ b/examples/ota-requestor-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/ota-requestor-app/telink/prj.conf b/examples/ota-requestor-app/telink/prj.conf index 50796f3077aab1..e854a2167fc02a 100755 --- a/examples/ota-requestor-app/telink/prj.conf +++ b/examples/ota-requestor-app/telink/prj.conf @@ -18,48 +18,45 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=n -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=y - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 -# CONFIG_CHIP_DEVICE_PRODUCT_ID=32773 -CONFIG_CHIP_DEVICE_TYPE=65535 +# 32776 == 0x8008 (example ota-requestor-app) +CONFIG_CHIP_DEVICE_PRODUCT_ID=32776 + +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkOTAReq" +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=y CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n # Enable Power Management CONFIG_PM=n + +# Custom RF power values +CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y +CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/ota-requestor-app/telink/src/AppTask.cpp b/examples/ota-requestor-app/telink/src/AppTask.cpp index 1742873befdf66..36e605acf24676 100644 --- a/examples/ota-requestor-app/telink/src/AppTask.cpp +++ b/examples/ota-requestor-app/telink/src/AppTask.cpp @@ -26,12 +26,5 @@ CHIP_ERROR AppTask::Init(void) { InitCommonParts(); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("TelinkOTAReq"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/platform/telink/common/include/AppTaskCommon.h b/examples/platform/telink/common/include/AppTaskCommon.h index 09a8e898cd6a8d..7204df2ba4b7a9 100644 --- a/examples/platform/telink/common/include/AppTaskCommon.h +++ b/examples/platform/telink/common/include/AppTaskCommon.h @@ -94,8 +94,10 @@ class AppTaskCommon static void FactoryResetButtonEventHandler(void); static void FactoryResetHandler(AppEvent * aEvent); +#if APP_USE_BLE_START_BUTTON static void StartBleAdvButtonEventHandler(void); static void StartBleAdvHandler(AppEvent * aEvent); +#endif #if APP_USE_THREAD_START_BUTTON static void StartThreadButtonEventHandler(void); diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index bf7c87efe70c33..decd0251ea1ee7 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -48,7 +48,9 @@ constexpr int kAppEventQueueSize = 10; #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE const struct gpio_dt_spec sFactoryResetButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_1), gpios); -const struct gpio_dt_spec sBleStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_2), gpios); +#if APP_USE_BLE_START_BUTTON +const struct gpio_dt_spec sBleStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_2), gpios); +#endif #if APP_USE_THREAD_START_BUTTON const struct gpio_dt_spec sThreadStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_3), gpios); #endif @@ -85,7 +87,9 @@ LEDWidget sStatusLED; #endif Button sFactoryResetButton; +#if APP_USE_BLE_START_BUTTON Button sBleAdvStartButton; +#endif #if APP_USE_EXAMPLE_START_BUTTON Button sExampleActionButton; #endif @@ -371,7 +375,9 @@ void AppTaskCommon::InitButtons(void) { #if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE sFactoryResetButton.Configure(&sFactoryResetButtonDt, FactoryResetButtonEventHandler); +#if APP_USE_BLE_START_BUTTON sBleAdvStartButton.Configure(&sBleStartButtonDt, StartBleAdvButtonEventHandler); +#endif #if APP_USE_EXAMPLE_START_BUTTON if (ExampleActionEventHandler) { @@ -383,7 +389,9 @@ void AppTaskCommon::InitButtons(void) #endif #else sFactoryResetButton.Configure(&sButtonRow1Dt, &sButtonCol1Dt, FactoryResetButtonEventHandler); +#if APP_USE_BLE_START_BUTTON sBleAdvStartButton.Configure(&sButtonRow2Dt, &sButtonCol2Dt, StartBleAdvButtonEventHandler); +#endif #if APP_USE_EXAMPLE_START_BUTTON if (ExampleActionEventHandler) { @@ -396,7 +404,9 @@ void AppTaskCommon::InitButtons(void) #endif ButtonManagerInst().AddButton(sFactoryResetButton); +#if APP_USE_BLE_START_BUTTON ButtonManagerInst().AddButton(sBleAdvStartButton); +#endif #if APP_USE_THREAD_START_BUTTON ButtonManagerInst().AddButton(sThreadStartButton); #endif @@ -511,6 +521,7 @@ void AppTaskCommon::IdentifyEffectHandler(Clusters::Identify::EffectIdentifierEn } #endif +#if APP_USE_BLE_START_BUTTON void AppTaskCommon::StartBleAdvButtonEventHandler(void) { AppEvent event; @@ -543,6 +554,7 @@ void AppTaskCommon::StartBleAdvHandler(AppEvent * aEvent) LOG_ERR("OpenBasicCommissioningWindow fail"); } } +#endif void AppTaskCommon::FactoryResetButtonEventHandler(void) { diff --git a/examples/platform/telink/common/src/mainCommon.cpp b/examples/platform/telink/common/src/mainCommon.cpp index 5adc0804872c72..612ac0e68cb89b 100644 --- a/examples/platform/telink/common/src/mainCommon.cpp +++ b/examples/platform/telink/common/src/mainCommon.cpp @@ -142,12 +142,14 @@ int main(void) goto exit; } -#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); -#elif CONFIG_OPENTHREAD_MTD +#if defined(CONFIG_CHIP_THREAD_DEVICE_ROLE_ROUTER) + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#elif defined(CONFIG_CHIP_THREAD_DEVICE_ROLE_END_DEVICE) err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#elif defined(CONFIG_CHIP_THREAD_DEVICE_ROLE_SLEEPY_END_DEVICE) + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); #else - err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#error THREAD_DEVICE_ROLE not selected #endif if (err != CHIP_NO_ERROR) { diff --git a/examples/platform/telink/project_include/OpenThreadConfig.h b/examples/platform/telink/project_include/OpenThreadConfig.h index cbd5e19f591da5..381b5e09bb07fc 100644 --- a/examples/platform/telink/project_include/OpenThreadConfig.h +++ b/examples/platform/telink/project_include/OpenThreadConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,8 +25,13 @@ // Project-specific settings #include "openthread/platform/logging.h" +/* Number of message buffers reduced to save RAM */ #undef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS -#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 64 +#if CONFIG_PM +#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 22 +#else +#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 44 +#endif #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART diff --git a/examples/pump-app/telink/CMakeLists.txt b/examples/pump-app/telink/CMakeLists.txt index 70886f44fa82b4..1e831ee268d2de 100755 --- a/examples/pump-app/telink/CMakeLists.txt +++ b/examples/pump-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/pump-app/telink/Kconfig b/examples/pump-app/telink/Kconfig new file mode 100644 index 00000000000000..0e3f346d8a5df0 --- /dev/null +++ b/examples/pump-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Pump Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/pump-app/telink/README.md b/examples/pump-app/telink/README.md index 3500672a41720f..ca97a9ec18c32d 100755 --- a/examples/pump-app/telink/README.md +++ b/examples/pump-app/telink/README.md @@ -10,35 +10,32 @@ reference for creating your own pump application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/pump-app/telink/include/AppConfig.h b/examples/pump-app/telink/include/AppConfig.h index 6701222f76151a..03aee4e8063bf8 100644 --- a/examples/pump-app/telink/include/AppConfig.h +++ b/examples/pump-app/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Pump Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/pump-app/telink/include/CHIPProjectConfig.h b/examples/pump-app/telink/include/CHIPProjectConfig.h index 412932a59c3726..8465c19cdd0537 100755 --- a/examples/pump-app/telink/include/CHIPProjectConfig.h +++ b/examples/pump-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/pump-app/telink/prj.conf b/examples/pump-app/telink/prj.conf index c105c33dccfe3d..3c0fd17786ef74 100755 --- a/examples/pump-app/telink/prj.conf +++ b/examples/pump-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 -# 32784 == 0x8010 (example pump-app) -CONFIG_CHIP_DEVICE_PRODUCT_ID=32784 -CONFIG_CHIP_DEVICE_TYPE=65535 +# 32778 == 0x800A (example pump-app) +CONFIG_CHIP_DEVICE_PRODUCT_ID=32778 + +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkPump" +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/pump-app/telink/src/AppTask.cpp b/examples/pump-app/telink/src/AppTask.cpp index 22396317f9e799..3f7122da81a37d 100644 --- a/examples/pump-app/telink/src/AppTask.cpp +++ b/examples/pump-app/telink/src/AppTask.cpp @@ -49,13 +49,6 @@ CHIP_ERROR AppTask::Init(void) PumpMgr().Init(); PumpMgr().SetCallbacks(ActionInitiated, ActionCompleted); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("Telink Pump"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/pump-controller-app/telink/CMakeLists.txt b/examples/pump-controller-app/telink/CMakeLists.txt index d45b4c8018bb77..32e6f4682e5f2c 100755 --- a/examples/pump-controller-app/telink/CMakeLists.txt +++ b/examples/pump-controller-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/pump-controller-app/telink/Kconfig b/examples/pump-controller-app/telink/Kconfig new file mode 100644 index 00000000000000..743441af5b2bac --- /dev/null +++ b/examples/pump-controller-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Pump Controller Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/pump-controller-app/telink/README.md b/examples/pump-controller-app/telink/README.md index ab73fabc6346af..41089fcc94a6ac 100755 --- a/examples/pump-controller-app/telink/README.md +++ b/examples/pump-controller-app/telink/README.md @@ -11,35 +11,32 @@ your own pump application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/pump-controller-app/telink/include/AppConfig.h b/examples/pump-controller-app/telink/include/AppConfig.h index 7fbff9ffb73eff..c843625ced4207 100644 --- a/examples/pump-controller-app/telink/include/AppConfig.h +++ b/examples/pump-controller-app/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Pump Controller Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/pump-controller-app/telink/include/CHIPProjectConfig.h b/examples/pump-controller-app/telink/include/CHIPProjectConfig.h index 412932a59c3726..8465c19cdd0537 100755 --- a/examples/pump-controller-app/telink/include/CHIPProjectConfig.h +++ b/examples/pump-controller-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/pump-controller-app/telink/prj.conf b/examples/pump-controller-app/telink/prj.conf index 964b7dca1951f3..2d4670fa37ebd8 100755 --- a/examples/pump-controller-app/telink/prj.conf +++ b/examples/pump-controller-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32785 == 0x8011 (example pump-controller-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32785 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkPumpCntr" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/pump-controller-app/telink/src/AppTask.cpp b/examples/pump-controller-app/telink/src/AppTask.cpp index 4cdb7c2cbba420..fa8ed8a11da842 100644 --- a/examples/pump-controller-app/telink/src/AppTask.cpp +++ b/examples/pump-controller-app/telink/src/AppTask.cpp @@ -47,13 +47,6 @@ CHIP_ERROR AppTask::Init(void) PumpMgr().Init(); PumpMgr().SetCallbacks(ActionInitiated, ActionCompleted); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("Telink Pump Controller"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/resource-monitoring-app/telink/CMakeLists.txt b/examples/resource-monitoring-app/telink/CMakeLists.txt index 3b86c7ef67af8d..07f4004a6f54a9 100644 --- a/examples/resource-monitoring-app/telink/CMakeLists.txt +++ b/examples/resource-monitoring-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/resource-monitoring-app/telink/Kconfig b/examples/resource-monitoring-app/telink/Kconfig new file mode 100644 index 00000000000000..c1e18dcb761bac --- /dev/null +++ b/examples/resource-monitoring-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Resource Monitoring Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/resource-monitoring-app/telink/README.md b/examples/resource-monitoring-app/telink/README.md index 4512f038fb053c..13962d281f43ac 100644 --- a/examples/resource-monitoring-app/telink/README.md +++ b/examples/resource-monitoring-app/telink/README.md @@ -6,35 +6,32 @@ You can use this example as a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/resource-monitoring-app/telink/include/AppConfig.h b/examples/resource-monitoring-app/telink/include/AppConfig.h index 211c2fb8ef03c0..f0149868a699b9 100644 --- a/examples/resource-monitoring-app/telink/include/AppConfig.h +++ b/examples/resource-monitoring-app/telink/include/AppConfig.h @@ -21,6 +21,7 @@ // ---- Air Quality Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 0 +#define APP_USE_BLE_START_BUTTON 0 #define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 diff --git a/examples/resource-monitoring-app/telink/include/CHIPProjectConfig.h b/examples/resource-monitoring-app/telink/include/CHIPProjectConfig.h index 412932a59c3726..8465c19cdd0537 100644 --- a/examples/resource-monitoring-app/telink/include/CHIPProjectConfig.h +++ b/examples/resource-monitoring-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/resource-monitoring-app/telink/prj.conf b/examples/resource-monitoring-app/telink/prj.conf index eec66455ef00cc..3996237b452b6b 100644 --- a/examples/resource-monitoring-app/telink/prj.conf +++ b/examples/resource-monitoring-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # CHIP PID: 32769 == 0x8001 (all-clusters-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkResMon" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support. CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/resource-monitoring-app/telink/src/AppTask.cpp b/examples/resource-monitoring-app/telink/src/AppTask.cpp index bdd9fba11fa60e..634de778321475 100644 --- a/examples/resource-monitoring-app/telink/src/AppTask.cpp +++ b/examples/resource-monitoring-app/telink/src/AppTask.cpp @@ -61,12 +61,5 @@ CHIP_ERROR AppTask::Init(void) gHepaFilterInstance.Init(); gActivatedCarbonFilterInstance.Init(); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("TelinkResMonDevice"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/shell/telink/CMakeLists.txt b/examples/shell/telink/CMakeLists.txt index 0c95e739097f63..fe3d961ca02758 100755 --- a/examples/shell/telink/CMakeLists.txt +++ b/examples/shell/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/shell/telink/Kconfig b/examples/shell/telink/Kconfig new file mode 100644 index 00000000000000..57a0c0bd571054 --- /dev/null +++ b/examples/shell/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Shell Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/shell/telink/README.md b/examples/shell/telink/README.md index d4a3c43e875180..19d115dc64cca1 100755 --- a/examples/shell/telink/README.md +++ b/examples/shell/telink/README.md @@ -6,35 +6,32 @@ You can use this example as a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/shell/telink/include/CHIPProjectConfig.h b/examples/shell/telink/include/CHIPProjectConfig.h index 6c1457895321b0..ba7e5304bb9c61 100755 --- a/examples/shell/telink/include/CHIPProjectConfig.h +++ b/examples/shell/telink/include/CHIPProjectConfig.h @@ -31,13 +31,6 @@ #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 - // Enable support functions for parsing command-line arguments #define CHIP_CONFIG_ENABLE_ARG_PARSER 1 diff --git a/examples/shell/telink/prj.conf b/examples/shell/telink/prj.conf index d0dccad1087d8c..53bdac24f943de 100755 --- a/examples/shell/telink/prj.conf +++ b/examples/shell/telink/prj.conf @@ -18,48 +18,36 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -#CONFIG_OPENTHREAD_MTD=n -CONFIG_OPENTHREAD_FTD=y -# CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32786 == 0x8012 (example shell-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32786 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2023" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=y CONFIG_OPENTHREAD_SHELL=y CONFIG_SHELL=y -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/smoke-co-alarm-app/telink/CMakeLists.txt b/examples/smoke-co-alarm-app/telink/CMakeLists.txt index 6df4292b041645..e1d5beec90d1c7 100755 --- a/examples/smoke-co-alarm-app/telink/CMakeLists.txt +++ b/examples/smoke-co-alarm-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/smoke-co-alarm-app/telink/Kconfig b/examples/smoke-co-alarm-app/telink/Kconfig new file mode 100644 index 00000000000000..3721f0622d14a7 --- /dev/null +++ b/examples/smoke-co-alarm-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Smoke CO Alarm Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/smoke-co-alarm-app/telink/README.md b/examples/smoke-co-alarm-app/telink/README.md index 20d4672b5688df..185f68213a3271 100755 --- a/examples/smoke-co-alarm-app/telink/README.md +++ b/examples/smoke-co-alarm-app/telink/README.md @@ -6,35 +6,32 @@ You can use this example as a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/smoke-co-alarm-app/telink/include/AppConfig.h b/examples/smoke-co-alarm-app/telink/include/AppConfig.h index 54a32f278d5672..bfaeb98eb8ac15 100644 --- a/examples/smoke-co-alarm-app/telink/include/AppConfig.h +++ b/examples/smoke-co-alarm-app/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Smoke Co Sendor App Example Config ---- #define APP_USE_EXAMPLE_START_BUTTON 1 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/smoke-co-alarm-app/telink/include/CHIPProjectConfig.h b/examples/smoke-co-alarm-app/telink/include/CHIPProjectConfig.h index 412932a59c3726..8465c19cdd0537 100755 --- a/examples/smoke-co-alarm-app/telink/include/CHIPProjectConfig.h +++ b/examples/smoke-co-alarm-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/smoke-co-alarm-app/telink/prj.conf b/examples/smoke-co-alarm-app/telink/prj.conf index 2b83eacd2936bd..299d79337065fe 100755 --- a/examples/smoke-co-alarm-app/telink/prj.conf +++ b/examples/smoke-co-alarm-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 -# 32774 == 0x8006 (example contact-sensor-app) -CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 -CONFIG_CHIP_DEVICE_TYPE=65535 +# 32774 == 0x8006 (example smoke-co-alarm-app) +CONFIG_CHIP_DEVICE_PRODUCT_ID=32774 + +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkCOSensor" +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2023" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n @@ -64,7 +56,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=y - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/smoke-co-alarm-app/telink/src/AppTask.cpp b/examples/smoke-co-alarm-app/telink/src/AppTask.cpp index 86ffb247965ae6..94be7e0cdf2bd7 100644 --- a/examples/smoke-co-alarm-app/telink/src/AppTask.cpp +++ b/examples/smoke-co-alarm-app/telink/src/AppTask.cpp @@ -38,13 +38,6 @@ CHIP_ERROR AppTask::Init(void) return err; } - err = ConnectivityMgr().SetBLEDeviceName("TelinkCOSensor"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/temperature-measurement-app/telink/CMakeLists.txt b/examples/temperature-measurement-app/telink/CMakeLists.txt index 35e0815a19f083..1adc7f29fe00a6 100644 --- a/examples/temperature-measurement-app/telink/CMakeLists.txt +++ b/examples/temperature-measurement-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/temperature-measurement-app/telink/Kconfig b/examples/temperature-measurement-app/telink/Kconfig new file mode 100644 index 00000000000000..2c8e7a1b978781 --- /dev/null +++ b/examples/temperature-measurement-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Temperature Measurement Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/temperature-measurement-app/telink/README.md b/examples/temperature-measurement-app/telink/README.md index ac6fec9325e39c..ea722c693d7679 100644 --- a/examples/temperature-measurement-app/telink/README.md +++ b/examples/temperature-measurement-app/telink/README.md @@ -10,35 +10,32 @@ creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/temperature-measurement-app/telink/include/AppConfig.h b/examples/temperature-measurement-app/telink/include/AppConfig.h index caa9762240f74d..76e68ac1b1349c 100644 --- a/examples/temperature-measurement-app/telink/include/AppConfig.h +++ b/examples/temperature-measurement-app/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Temperature measurement Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 0 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 0 diff --git a/examples/temperature-measurement-app/telink/include/CHIPProjectConfig.h b/examples/temperature-measurement-app/telink/include/CHIPProjectConfig.h index 412932a59c3726..8465c19cdd0537 100644 --- a/examples/temperature-measurement-app/telink/include/CHIPProjectConfig.h +++ b/examples/temperature-measurement-app/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/temperature-measurement-app/telink/prj.conf b/examples/temperature-measurement-app/telink/prj.conf index 2780ff4a686b19..9aabed07aa7a4a 100644 --- a/examples/temperature-measurement-app/telink/prj.conf +++ b/examples/temperature-measurement-app/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32781 == 0x800D (example temperature-measurement-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32781 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkTerm" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2023" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n @@ -64,7 +56,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n # Enable Power Management CONFIG_PM=y - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/temperature-measurement-app/telink/src/AppTask.cpp b/examples/temperature-measurement-app/telink/src/AppTask.cpp index 38d99ed3b190ab..023381e5225db2 100644 --- a/examples/temperature-measurement-app/telink/src/AppTask.cpp +++ b/examples/temperature-measurement-app/telink/src/AppTask.cpp @@ -50,13 +50,6 @@ CHIP_ERROR AppTask::Init(void) app::Clusters::TemperatureMeasurement::Attributes::MaxMeasuredValue::Set(kExampleEndpointId, SensorMgr().GetMaxMeasuredValue()); PlatformMgr().UnlockChipStack(); - err = ConnectivityMgr().SetBLEDeviceName("TelinkTerm"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/thermostat/telink/CMakeLists.txt b/examples/thermostat/telink/CMakeLists.txt index 58b4c58485a57f..7b9dff6ff3e6f8 100755 --- a/examples/thermostat/telink/CMakeLists.txt +++ b/examples/thermostat/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/thermostat/telink/Kconfig b/examples/thermostat/telink/Kconfig new file mode 100644 index 00000000000000..b24bba1e923845 --- /dev/null +++ b/examples/thermostat/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Thermostat Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/thermostat/telink/Readme.md b/examples/thermostat/telink/Readme.md index 905217a94a1ab8..a1ff048488b436 100755 --- a/examples/thermostat/telink/Readme.md +++ b/examples/thermostat/telink/Readme.md @@ -6,35 +6,32 @@ You can use this example as a reference for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/thermostat/telink/include/AppConfig.h b/examples/thermostat/telink/include/AppConfig.h index d3131fb3e32c69..8fc6ceac48ad19 100644 --- a/examples/thermostat/telink/include/AppConfig.h +++ b/examples/thermostat/telink/include/AppConfig.h @@ -21,7 +21,8 @@ // ---- Thermostat Example App Config ---- #define APP_USE_EXAMPLE_START_BUTTON 0 -#define APP_USE_THREAD_START_BUTTON 1 +#define APP_USE_BLE_START_BUTTON 0 +#define APP_USE_THREAD_START_BUTTON 0 #define APP_SET_DEVICE_INFO_PROVIDER 1 #define APP_SET_NETWORK_COMM_ENDPOINT_SEC 0 #define APP_USE_IDENTIFY_PWM 1 diff --git a/examples/thermostat/telink/include/CHIPProjectConfig.h b/examples/thermostat/telink/include/CHIPProjectConfig.h index 2fda70c57da9dc..280c26e78b46bf 100755 --- a/examples/thermostat/telink/include/CHIPProjectConfig.h +++ b/examples/thermostat/telink/include/CHIPProjectConfig.h @@ -30,10 +30,3 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/thermostat/telink/prj.conf b/examples/thermostat/telink/prj.conf index fdf42e9c76466f..70cb272b0da9c8 100755 --- a/examples/thermostat/telink/prj.conf +++ b/examples/thermostat/telink/prj.conf @@ -18,45 +18,37 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32782 == 0x800E (example thermostat) CONFIG_CHIP_DEVICE_PRODUCT_ID=32782 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkThermo" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n diff --git a/examples/thermostat/telink/src/AppTask.cpp b/examples/thermostat/telink/src/AppTask.cpp index 11b082e36b6e3e..d9b7a2c2883844 100644 --- a/examples/thermostat/telink/src/AppTask.cpp +++ b/examples/thermostat/telink/src/AppTask.cpp @@ -39,13 +39,6 @@ CHIP_ERROR AppTask::Init(void) return err; } - err = ConnectivityMgr().SetBLEDeviceName("TelinkThermo"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/examples/window-app/telink/CMakeLists.txt b/examples/window-app/telink/CMakeLists.txt index d4ca74d955d2db..d9e703db81ae94 100644 --- a/examples/window-app/telink/CMakeLists.txt +++ b/examples/window-app/telink/CMakeLists.txt @@ -40,7 +40,7 @@ else() set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) endif() -set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) +set(CONF_FILE prj.conf) # Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) diff --git a/examples/window-app/telink/Kconfig b/examples/window-app/telink/Kconfig new file mode 100644 index 00000000000000..794d4fd6490745 --- /dev/null +++ b/examples/window-app/telink/Kconfig @@ -0,0 +1,19 @@ +# +# Copyright (c) 2023 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. +# +mainmenu "Matter Telink Window Example Application" + +rsource "../../../config/telink/chip-module/Kconfig.defaults" +source "Kconfig.zephyr" diff --git a/examples/window-app/telink/README.md b/examples/window-app/telink/README.md index 7445e330a496d2..876764c2fb0b88 100644 --- a/examples/window-app/telink/README.md +++ b/examples/window-app/telink/README.md @@ -9,35 +9,32 @@ for creating your own application. ## Build and flash -1. Pull docker image from repository: +1. Run the Docker container: ```bash - $ docker pull ghcr.io/project-chip/chip-build-telink:10 + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') ``` -2. Run docker container: + Compatible docker image version can be found in next file: ```bash - $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" ghcr.io/project-chip/chip-build-telink:10 + $ .github/workflows/examples-telink.yaml ``` - here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay - attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** - -3. Activate the build environment: +2. Activate the build environment: ```bash $ source ./scripts/activate.sh ``` -4. In the example dir run (replace __ with your board name, for +3. In the example dir run (replace __ with your board name, for example, `tlsr9518adk80d` or `tlsr9528a`): ```bash $ west build -b ``` -5. Flash binary: +4. Flash binary: ``` $ west flash --erase diff --git a/examples/window-app/telink/include/CHIPProjectConfig.h b/examples/window-app/telink/include/CHIPProjectConfig.h index 824acd90d46cbe..b896bb262aa20d 100644 --- a/examples/window-app/telink/include/CHIPProjectConfig.h +++ b/examples/window-app/telink/include/CHIPProjectConfig.h @@ -35,10 +35,3 @@ // Until this is improved in OpenThread we need to increase the retransmission // interval to survive the stall. #define CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL (1000_ms32) - -/** - * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE - * - * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption - */ -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/window-app/telink/prj.conf b/examples/window-app/telink/prj.conf index 12b9e05d5a9964..23eba6ddd4aaec 100644 --- a/examples/window-app/telink/prj.conf +++ b/examples/window-app/telink/prj.conf @@ -18,52 +18,40 @@ # samples. This file should contain only options specific for this sample # or overrides of default values. +# Enable CHIP +CONFIG_CHIP=y +CONFIG_STD_CPP17=y + # enable GPIO CONFIG_GPIO=y # enable PWM CONFIG_PWM=y -# OpenThread configs -CONFIG_OPENTHREAD_MTD=y -CONFIG_CHIP_ENABLE_ICD_SUPPORT=y -CONFIG_CHIP_THREAD_SSED=n - -# Default OpenThread network settings -CONFIG_OPENTHREAD_PANID=4660 -CONFIG_OPENTHREAD_CHANNEL=15 -CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" -CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" - -# Disable Matter OTA DFU -CONFIG_CHIP_OTA_REQUESTOR=n - # CHIP configuration CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" -CONFIG_CHIP_DEVICE_VENDOR_ID=65521 # 32784 == 0x8010 (example window-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32784 -CONFIG_CHIP_DEVICE_TYPE=65535 +# Bluetooth Low Energy configuration +CONFIG_BT_DEVICE_NAME="TelinkWindow" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 -CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" # Enable CHIP pairing automatically on application start. CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y -# CHIP shell +# Disable CHIP shell support CONFIG_CHIP_LIB_SHELL=n -# Disable factory data support. +# Disable factory data support CONFIG_CHIP_FACTORY_DATA=n CONFIG_CHIP_FACTORY_DATA_BUILD=n CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n # Enable Power Management CONFIG_PM=y - -# Custom RF power values -CONFIG_B9X_BLE_CTRL_RF_POWER_P9P11DBM=y -CONFIG_OPENTHREAD_DEFAULT_TX_POWER=9 diff --git a/examples/window-app/telink/src/AppTask.cpp b/examples/window-app/telink/src/AppTask.cpp index c95e0bc5ae8c0b..9817b474a8840a 100644 --- a/examples/window-app/telink/src/AppTask.cpp +++ b/examples/window-app/telink/src/AppTask.cpp @@ -66,13 +66,6 @@ CHIP_ERROR AppTask::Init(void) k_timer_init(&sToggleMoveTypeTimer, &AppTask::OpenTimerTimeoutCallback, nullptr); k_timer_user_data_set(&sToggleMoveTypeTimer, this); - CHIP_ERROR err = ConnectivityMgr().SetBLEDeviceName("TelinkWindow"); - if (err != CHIP_NO_ERROR) - { - LOG_ERR("SetBLEDeviceName fail"); - return err; - } - return CHIP_NO_ERROR; } diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index 0d488c5c917c31..392d6049515238 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -39,10 +39,16 @@ #include #include +#include #include +#include #include #include +extern "C" { +#include +} + #if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) #include #endif @@ -110,30 +116,26 @@ bt_gatt_service sChipoBleService = BT_GATT_SERVICE(sChipoBleAttributes); // This value should be adjusted accordingly if the service declaration changes. constexpr int kCHIPoBLE_CCC_AttributeIndex = 3; -CHIP_ERROR InitRandomStaticAddress() +CHIP_ERROR InitBLEMACAddress() { - // Generate a random static address for the default identity. - // This must be done before bt_enable() as after that updating the default identity is not possible. + // By default the BLE public address will be applied. In case if previously generated random address doesn't exist + // or public address doesn't exist, the new random static address will be generated and written to flash int error = 0; bt_addr_le_t addr; - // generating the address - addr.type = BT_ADDR_LE_RANDOM; - error = sys_csrand_get(addr.a.val, sizeof(addr.a.val)); - BT_ADDR_SET_STATIC(&addr.a); + b9x_bt_blc_mac_init(addr.a.val); - if (error) + if (BT_ADDR_IS_STATIC(&addr.a)) // in case of Random static address, create a new id { - ChipLogError(DeviceLayer, "Failed to create BLE address: %d", error); - return System::MapErrorZephyr(error); - } + addr.type = BT_ADDR_LE_RANDOM; - error = bt_id_create(&addr, nullptr); + error = bt_id_create(&addr, nullptr); - if (error < 0) - { - ChipLogError(DeviceLayer, "Failed to create BLE identity: %d", error); - return System::MapErrorZephyr(error); + if (error < 0) + { + ChipLogError(DeviceLayer, "Failed to create BLE identity: %d", error); + return System::MapErrorZephyr(error); + } } ChipLogProgress(DeviceLayer, "BLE address: %02X:%02X:%02X:%02X:%02X:%02X", addr.a.val[5], addr.a.val[4], addr.a.val[3], @@ -158,7 +160,7 @@ CHIP_ERROR BLEManagerImpl::_Init(void) memset(mSubscribedConns, 0, sizeof(mSubscribedConns)); - ReturnErrorOnFailure(InitRandomStaticAddress()); + ReturnErrorOnFailure(InitBLEMACAddress()); // int err = bt_enable(NULL); // Can't init BLE stack here due to abscense of non-cuncurrent mode // VerifyOrReturnError(err == 0, MapErrorZephyr(err)); @@ -309,9 +311,6 @@ CHIP_ERROR BLEManagerImpl::StartAdvertisingProcess(void) if (!mBLERadioInitialized) { - char bt_dev_name[CONFIG_BT_DEVICE_NAME_MAX]; - strncpy(bt_dev_name, bt_get_name(), sizeof(bt_dev_name)); - /* Switch off Thread */ ThreadStackMgrImpl().SetThreadEnabled(false); ThreadStackMgrImpl().SetRadioBlocked(true); @@ -319,7 +318,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertisingProcess(void) /* Init BLE stack */ err = bt_enable(NULL); VerifyOrReturnError(err == 0, MapErrorZephyr(err)); - (void) bt_set_name(bt_dev_name); + mBLERadioInitialized = true; #if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); diff --git a/src/platform/telink/CHIPDevicePlatformConfig.h b/src/platform/telink/CHIPDevicePlatformConfig.h index 8670ac640ff62e..a3ce958945c0fe 100644 --- a/src/platform/telink/CHIPDevicePlatformConfig.h +++ b/src/platform/telink/CHIPDevicePlatformConfig.h @@ -187,7 +187,11 @@ #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE +#if CONFIG_PM +#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 4864 +#else #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192 +#endif #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 @@ -222,11 +226,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 #endif // CONFIG_CHIP_EXTENDED_DISCOVERY -#ifdef CONFIG_CHIP_ENABLE_ICD_SUPPORT -#define CHIP_DEVICE_CONFIG_ENABLE_SED 1 -#define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED -#endif // CONFIG_CHIP_ENABLE_ICD_SUPPORT - #ifndef CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL #ifdef CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL #define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL) diff --git a/src/platform/telink/CHIPPlatformConfig.h b/src/platform/telink/CHIPPlatformConfig.h index 0e7c2cbb2891b5..daaa99a3db4746 100644 --- a/src/platform/telink/CHIPPlatformConfig.h +++ b/src/platform/telink/CHIPPlatformConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021-2022 Project CHIP Authors + * Copyright (c) 2021-2023 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. @@ -62,6 +62,46 @@ #define CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS 1 #endif // CHIP_CONFIG_BDX_MAX_NUM_TRANSFERS +#if CONFIG_PM + +#ifndef CHIP_CONFIG_ENABLE_SERVER_IM_EVENT +#define CHIP_CONFIG_ENABLE_SERVER_IM_EVENT 0 +#endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT + +#ifndef CHIP_CONFIG_MAX_GROUP_DATA_PEERS +#define CHIP_CONFIG_MAX_GROUP_DATA_PEERS 7 +#endif // CHIP_CONFIG_MAX_GROUP_DATA_PEERS + +#ifndef CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_ENTRIES_PER_FABRIC +#define CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_ENTRIES_PER_FABRIC 2 +#endif // CHIP_CONFIG_EXAMPLE_ACCESS_CONTROL_MAX_ENTRIES_PER_FABRIC + +#ifndef CHIP_IM_MAX_NUM_COMMAND_HANDLER +#define CHIP_IM_MAX_NUM_COMMAND_HANDLER 1 +#endif // CHIP_IM_MAX_NUM_COMMAND_HANDLER + +#ifndef CHIP_IM_MAX_NUM_WRITE_HANDLER +#define CHIP_IM_MAX_NUM_WRITE_HANDLER 1 +#endif // CHIP_IM_MAX_NUM_WRITE_HANDLER + +#ifndef CHIP_IM_MAX_NUM_WRITE_CLIENT +#define CHIP_IM_MAX_NUM_WRITE_CLIENT 1 +#endif // CHIP_IM_MAX_NUM_WRITE_CLIENT + +#ifndef CHIP_IM_MAX_REPORTS_IN_FLIGHT +#define CHIP_IM_MAX_REPORTS_IN_FLIGHT 1 +#endif // CHIP_IM_MAX_REPORTS_IN_FLIGHT + +#ifndef CHIP_CONFIG_LAMBDA_EVENT_SIZE +#define CHIP_CONFIG_LAMBDA_EVENT_SIZE (16) +#endif // CHIP_CONFIG_LAMBDA_EVENT_SIZE + +#ifndef CHIP_CONFIG_DEVICE_MAX_ACTIVE_DEVICES +#define CHIP_CONFIG_DEVICE_MAX_ACTIVE_DEVICES 2 +#endif // CHIP_CONFIG_DEVICE_MAX_ACTIVE_DEVICES + +#endif // CONFIG_PM + #ifndef CHIP_CONFIG_MAX_FABRICS #define CHIP_CONFIG_MAX_FABRICS 5 #endif diff --git a/src/platform/telink/SystemPlatformConfig.h b/src/platform/telink/SystemPlatformConfig.h index 4e80b6e51ca413..8c1d5334029583 100644 --- a/src/platform/telink/SystemPlatformConfig.h +++ b/src/platform/telink/SystemPlatformConfig.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-2023 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. @@ -47,4 +47,11 @@ struct ChipDeviceEvent; #define CHIP_SYSTEM_CONFIG_USE_LWIP 0 #define CHIP_SYSTEM_CONFIG_USE_SOCKETS 1 +// Reduce packet buffer pool size (default 15) to reduce ram consumption +#if CONFIG_PM +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 +#else +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 +#endif + // ========== Platform-specific Configuration Overrides ========= diff --git a/src/platform/telink/telink-mbedtls-config.h b/src/platform/telink/telink-mbedtls-config.h index 0a37b4a632e274..ccd3de88f1f77e 100644 --- a/src/platform/telink/telink-mbedtls-config.h +++ b/src/platform/telink/telink-mbedtls-config.h @@ -25,10 +25,13 @@ #define MBEDTLS_TSLR9_CONF_H #define MBEDTLS_HKDF_C +#define MBEDTLS_PKCS5_C #define MBEDTLS_X509_CREATE_C #define MBEDTLS_X509_CSR_WRITE_C #define MBEDTLS_AES_ALT #define MBEDTLS_ECP_ALT +#undef MBEDTLS_ERROR_C + #endif /* MBEDTLS_TSLR9_CONF_H */ diff --git a/src/platform/telink/tlsr9518adk80d.overlay b/src/platform/telink/tlsr9518adk80d.overlay index 32fbb3f5661809..c419f8116441e5 100644 --- a/src/platform/telink/tlsr9518adk80d.overlay +++ b/src/platform/telink/tlsr9518adk80d.overlay @@ -87,6 +87,7 @@ /delete-node/ partition@88000; /delete-node/ partition@f0000; /delete-node/ partition@f4000; + /delete-node/ partition@fe000; boot_partition: partition@0 { label = "mcuboot"; reg = <0x00000000 0x19000>; @@ -107,6 +108,9 @@ label = "image-1"; reg = <0x110000 0xee000>; }; - /* region <0x1fe000 0x2000> is reserved for Telink B91 SDK's data */ + vendor_partition: partition@1fe000 { + label = "vendor-data"; + reg = <0x1fe000 0x2000>; + }; }; }; diff --git a/src/platform/telink/tlsr9528a.overlay b/src/platform/telink/tlsr9528a.overlay index 996981e6834b0b..c57cc0eb0341e2 100644 --- a/src/platform/telink/tlsr9528a.overlay +++ b/src/platform/telink/tlsr9528a.overlay @@ -87,6 +87,7 @@ /delete-node/ partition@88000; /delete-node/ partition@f0000; /delete-node/ partition@f4000; + /delete-node/ partition@fe000; boot_partition: partition@0 { label = "mcuboot"; reg = <0x00000000 0x19000>; @@ -107,6 +108,9 @@ label = "image-1"; reg = <0x110000 0xee000>; }; - /* region <0x1fe000 0x2000> is reserved for Telink B92 SDK's data */ + vendor_partition: partition@1fe000 { + label = "vendor-data"; + reg = <0x1fe000 0x2000>; + }; }; };