From 97e607db064fc77a66a7d69bc57c55a950828aa6 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Wed, 14 Dec 2022 13:35:35 +0200 Subject: [PATCH 01/18] [Telink] Rework flash partitions & use swap move algorithm --- config/telink/chip-module/CMakeLists.txt | 6 +++--- config/telink/chip-module/generate_factory_data.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 6113325da57f95..cb3b2f3246e015 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -297,7 +297,7 @@ add_dependencies(chip chip-gn) if (CONFIG_CHIP_OTA_IMAGE_BUILD) add_custom_target(build_mcuboot ALL COMMAND - west build -b tlsr9518adk80d -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr + west build -b tlsr9518adk80d -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr -- -DCONFIG_BOOT_SWAP_USING_MOVE=y ) add_custom_target(west_sign ALL @@ -311,7 +311,7 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD) COMMAND dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr.bin COMMAND - dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=96 + dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=76 ) chip_ota_image(chip-ota-image @@ -327,7 +327,7 @@ endif() if (CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE) add_custom_target(merge_factory_data ALL COMMAND - dd if=${PROJECT_BINARY_DIR}/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=2000 + dd if=${PROJECT_BINARY_DIR}/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=1040 ) if (CONFIG_CHIP_OTA_IMAGE_BUILD) add_dependencies(merge_factory_data merge_mcuboot) diff --git a/config/telink/chip-module/generate_factory_data.cmake b/config/telink/chip-module/generate_factory_data.cmake index a1c9f0ef9780a0..abf3fd087e42e2 100644 --- a/config/telink/chip-module/generate_factory_data.cmake +++ b/config/telink/chip-module/generate_factory_data.cmake @@ -140,7 +140,7 @@ function(telink_create_factory_data_hex_file factory_data_hex_target factory_dat set(cbor_script_args "-i ${output_path}/${factory_data_target}.json\n") string(APPEND cbor_script_args "-o ${output_path}/${factory_data_target}\n") # get partition address and offset from partition manager during compilation -string(APPEND cbor_script_args "--offset 0x1f4000\n") +string(APPEND cbor_script_args "--offset 0x104000\n") string(APPEND cbor_script_args "--size 0x1000\n") string(APPEND cbor_script_args "-r\n") From a7640de229ec6aaedd3b924ad88177d03fec4d79 Mon Sep 17 00:00:00 2001 From: Serhii Salamakha Date: Tue, 13 Dec 2022 17:26:38 +0200 Subject: [PATCH 02/18] [Telink] Removed timer to BLE disconnect --- src/platform/telink/BLEManagerImpl.cpp | 15 ++++----------- src/platform/telink/BLEManagerImpl.h | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index f11d3c087678b6..fdb120ef9414e6 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -886,24 +886,17 @@ ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gat } #endif -void BLEManagerImpl::BLEConnDisconnect(System::Layer * layer, void * param) +CHIP_ERROR BLEManagerImpl::HandleOperationalNetworkEnabled(const ChipDeviceEvent * event) { + ChipLogDetail(DeviceLayer, "HandleOperationalNetworkEnabled"); + int error = bt_conn_disconnect(BLEMgrImpl().mconId, BT_HCI_ERR_LOCALHOST_TERM_CONN); if (error) { ChipLogError(DeviceLayer, "Close BLEConn err: %d", error); } -} -CHIP_ERROR BLEManagerImpl::HandleOperationalNetworkEnabled(const ChipDeviceEvent * event) -{ - - ChipLogDetail(DeviceLayer, "HandleOperationalNetworkEnabled"); - - // Start timer to close BLE connection. - DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(20), BLEConnDisconnect, this); - - return CHIP_NO_ERROR; + return MapErrorZephyr(error); } CHIP_ERROR BLEManagerImpl::HandleThreadStateChange(const ChipDeviceEvent * event) diff --git a/src/platform/telink/BLEManagerImpl.h b/src/platform/telink/BLEManagerImpl.h index f6fcbf87c8e584..9937e1212724e2 100644 --- a/src/platform/telink/BLEManagerImpl.h +++ b/src/platform/telink/BLEManagerImpl.h @@ -127,7 +127,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla */ CHIP_ERROR HandleThreadStateChange(const ChipDeviceEvent * event); CHIP_ERROR HandleOperationalNetworkEnabled(const ChipDeviceEvent * event); - static void BLEConnDisconnect(chip::System::Layer * aLayer, void * aAppState); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING CHIP_ERROR PrepareC3CharData(); From 427039cb5378846825508657ffcbca5860f7bb49 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 19 Dec 2022 09:33:24 +0200 Subject: [PATCH 03/18] [Telink] Rework flash partitions & use swap move algorithm --- config/telink/chip-module/CMakeLists.txt | 6 +++--- config/telink/chip-module/generate_factory_data.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 6113325da57f95..cb3b2f3246e015 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -297,7 +297,7 @@ add_dependencies(chip chip-gn) if (CONFIG_CHIP_OTA_IMAGE_BUILD) add_custom_target(build_mcuboot ALL COMMAND - west build -b tlsr9518adk80d -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr + west build -b tlsr9518adk80d -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr -- -DCONFIG_BOOT_SWAP_USING_MOVE=y ) add_custom_target(west_sign ALL @@ -311,7 +311,7 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD) COMMAND dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr.bin COMMAND - dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=96 + dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=76 ) chip_ota_image(chip-ota-image @@ -327,7 +327,7 @@ endif() if (CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE) add_custom_target(merge_factory_data ALL COMMAND - dd if=${PROJECT_BINARY_DIR}/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=2000 + dd if=${PROJECT_BINARY_DIR}/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=1040 ) if (CONFIG_CHIP_OTA_IMAGE_BUILD) add_dependencies(merge_factory_data merge_mcuboot) diff --git a/config/telink/chip-module/generate_factory_data.cmake b/config/telink/chip-module/generate_factory_data.cmake index a1c9f0ef9780a0..abf3fd087e42e2 100644 --- a/config/telink/chip-module/generate_factory_data.cmake +++ b/config/telink/chip-module/generate_factory_data.cmake @@ -140,7 +140,7 @@ function(telink_create_factory_data_hex_file factory_data_hex_target factory_dat set(cbor_script_args "-i ${output_path}/${factory_data_target}.json\n") string(APPEND cbor_script_args "-o ${output_path}/${factory_data_target}\n") # get partition address and offset from partition manager during compilation -string(APPEND cbor_script_args "--offset 0x1f4000\n") +string(APPEND cbor_script_args "--offset 0x104000\n") string(APPEND cbor_script_args "--size 0x1000\n") string(APPEND cbor_script_args "-r\n") From 6d67236cb6b648e6f289e014314678c4caaa2421 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 19 Dec 2022 10:33:40 +0200 Subject: [PATCH 04/18] [Telink] Use latest Telink mcuboot changes --- config/telink/chip-module/CMakeLists.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index cb3b2f3246e015..31acdc50295eac 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -300,13 +300,6 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD) west build -b tlsr9518adk80d -d build_mcuboot ${ZEPHYR_BASE}/../bootloader/mcuboot/boot/zephyr -- -DCONFIG_BOOT_SWAP_USING_MOVE=y ) - add_custom_target(west_sign ALL - COMMAND - west sign -t imgtool -p ${ZEPHYR_BASE}/../bootloader/mcuboot/scripts/imgtool.py -d ${PROJECT_BINARY_DIR}/.. -- --key ${ZEPHYR_BASE}/../bootloader/mcuboot/root-rsa-2048.pem - BYPRODUCTS - ${PROJECT_BINARY_DIR}/zephyr.signed.bin - ) - add_custom_target(merge_mcuboot ALL COMMAND dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr.bin @@ -319,9 +312,8 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD) OUTPUT_FILE ${PROJECT_BINARY_DIR}/zephyr-ota.bin ) - add_dependencies(west_sign ${ZEPHYR_FINAL_EXECUTABLE}) - add_dependencies(merge_mcuboot west_sign) - add_dependencies(chip-ota-image west_sign) + add_dependencies(merge_mcuboot ${ZEPHYR_FINAL_EXECUTABLE}) + add_dependencies(chip-ota-image ${ZEPHYR_FINAL_EXECUTABLE}) endif() if (CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE) From 66e5a3607b15b213d1d1e51413b40af535e7d356 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Mon, 19 Dec 2022 10:34:04 +0200 Subject: [PATCH 05/18] [Telink] Enable reboot system when fault happened --- config/telink/app/zephyr.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/telink/app/zephyr.conf b/config/telink/app/zephyr.conf index 0bb8ffeca65103..017e0736a5fe13 100644 --- a/config/telink/app/zephyr.conf +++ b/config/telink/app/zephyr.conf @@ -118,6 +118,9 @@ CONFIG_DYNAMIC_INTERRUPTS=y # nvs_sector_size = flash_page_size * mult = 256 * 8 = 2048 CONFIG_SETTINGS_NVS_SECTOR_SIZE_MULT=8 +# Reboot system when fault happened +CONFIG_TELINK_B91_REBOOT_ON_FAULT=y + # Shell settings CONFIG_SHELL=n CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=255 From 99b433f0cd65238b332c97fd01f0a2157713b2c5 Mon Sep 17 00:00:00 2001 From: Serhii Salamakha Date: Tue, 20 Dec 2022 10:17:29 +0200 Subject: [PATCH 06/18] [Telink] Rework system status LED loop and made the Factory-Reset Button more user friendly --- .../telink/include/AppEvent.h | 12 +++ .../all-clusters-app/telink/include/AppTask.h | 6 ++ .../all-clusters-app/telink/src/AppTask.cpp | 85 +++++++++++++---- .../telink/include/AppEvent.h | 12 +++ .../telink/include/AppTask.h | 6 ++ .../telink/src/AppTask.cpp | 83 ++++++++++++++--- .../telink/include/AppEvent.h | 7 ++ .../light-switch-app/telink/include/AppTask.h | 6 ++ .../light-switch-app/telink/src/AppTask.cpp | 87 ++++++++++++++---- .../lighting-app/telink/include/AppEvent.h | 7 ++ .../lighting-app/telink/include/AppTask.h | 7 +- examples/lighting-app/telink/src/AppTask.cpp | 92 +++++++++++++++---- .../telink/include/AppEvent.h | 7 ++ .../telink/include/AppTask.h | 6 ++ .../ota-requestor-app/telink/src/AppTask.cpp | 85 +++++++++++++---- .../telink/util/include/ButtonManager.h | 3 +- .../platform/telink/util/include/LEDWidget.h | 11 ++- .../telink/util/src/ButtonManager.cpp | 22 ++--- .../platform/telink/util/src/LEDWidget.cpp | 59 ++++++++---- third_party/silabs/matter_support | 2 +- 20 files changed, 486 insertions(+), 119 deletions(-) diff --git a/examples/all-clusters-app/telink/include/AppEvent.h b/examples/all-clusters-app/telink/include/AppEvent.h index 000f3e8653d3ff..5c5d72f5b8ace1 100644 --- a/examples/all-clusters-app/telink/include/AppEvent.h +++ b/examples/all-clusters-app/telink/include/AppEvent.h @@ -23,11 +23,15 @@ struct AppEvent; typedef void (*EventHandler)(AppEvent *); +class LEDWidget; + struct AppEvent { enum AppEventTypes { kEventType_Button = 0, + kEventType_Timer, + kEventType_UpdateLedState, }; uint16_t Type; @@ -38,6 +42,14 @@ struct AppEvent { uint8_t Action; } ButtonEvent; + struct + { + void * Context; + } TimerEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; }; EventHandler Handler; diff --git a/examples/all-clusters-app/telink/include/AppTask.h b/examples/all-clusters-app/telink/include/AppTask.h index d893794235fb47..7787968458b867 100644 --- a/examples/all-clusters-app/telink/include/AppTask.h +++ b/examples/all-clusters-app/telink/include/AppTask.h @@ -19,6 +19,7 @@ #pragma once #include "AppEvent.h" +#include "LEDWidget.h" #include @@ -43,15 +44,20 @@ class AppTask void DispatchEvent(AppEvent * event); static void UpdateStatusLED(); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void FactoryResetButtonEventHandler(void); static void StartThreadButtonEventHandler(void); static void StartBleAdvButtonEventHandler(void); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetHandler(AppEvent * aEvent); static void StartThreadHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); static void InitButtons(void); diff --git a/examples/all-clusters-app/telink/src/AppTask.cpp b/examples/all-clusters-app/telink/src/AppTask.cpp index f5b8cac574c23a..9a6a8f2aa3b8de 100644 --- a/examples/all-clusters-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-app/telink/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" -#include "LEDWidget.h" #include "binding-handler.h" #include #include @@ -48,12 +47,13 @@ LOG_MODULE_DECLARE(app); namespace { - -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; LEDWidget sStatusLED; @@ -61,10 +61,11 @@ Button sFactoryResetButton; Button sThreadStartButton; Button sBleAdvStartButton; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sHaveBLEConnections = false; +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -118,12 +119,17 @@ CHIP_ERROR AppTask::Init() // Initialize status LED LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); sStatusLED.Init(SYSTEM_STATE_LED_PIN); UpdateStatusLED(); InitButtons(); + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + // Init ZCL Data Model and start server static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); @@ -192,8 +198,6 @@ CHIP_ERROR AppTask::StartApp() DispatchEvent(&event); ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); } - - sStatusLED.Animate(); } } @@ -209,8 +213,15 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { - LOG_INF("FactoryResetHandler"); - chip::Server::GetInstance().ScheduleFactoryReset(); + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } } void AppTask::StartThreadButtonEventHandler(void) @@ -272,6 +283,23 @@ void AppTask::StartBleAdvHandler(AppEvent * aEvent) } } +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + void AppTask::UpdateStatusLED() { if (sIsThreadProvisioned && sIsThreadEnabled) @@ -342,11 +370,36 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + void AppTask::InitButtons(void) { - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, false, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); ButtonManagerInst().AddButton(sFactoryResetButton); ButtonManagerInst().AddButton(sThreadStartButton); diff --git a/examples/all-clusters-minimal-app/telink/include/AppEvent.h b/examples/all-clusters-minimal-app/telink/include/AppEvent.h index 000f3e8653d3ff..5c5d72f5b8ace1 100644 --- a/examples/all-clusters-minimal-app/telink/include/AppEvent.h +++ b/examples/all-clusters-minimal-app/telink/include/AppEvent.h @@ -23,11 +23,15 @@ struct AppEvent; typedef void (*EventHandler)(AppEvent *); +class LEDWidget; + struct AppEvent { enum AppEventTypes { kEventType_Button = 0, + kEventType_Timer, + kEventType_UpdateLedState, }; uint16_t Type; @@ -38,6 +42,14 @@ struct AppEvent { uint8_t Action; } ButtonEvent; + struct + { + void * Context; + } TimerEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; }; EventHandler Handler; diff --git a/examples/all-clusters-minimal-app/telink/include/AppTask.h b/examples/all-clusters-minimal-app/telink/include/AppTask.h index d6a02734a40e74..7d0168759055d0 100644 --- a/examples/all-clusters-minimal-app/telink/include/AppTask.h +++ b/examples/all-clusters-minimal-app/telink/include/AppTask.h @@ -19,6 +19,7 @@ #pragma once #include "AppEvent.h" +#include "LEDWidget.h" #include @@ -43,13 +44,18 @@ class AppTask void DispatchEvent(AppEvent * event); static void UpdateStatusLED(); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void FactoryResetButtonEventHandler(void); static void StartBleAdvButtonEventHandler(void); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); static void InitButtons(void); diff --git a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp index 8ecf29eda06939..7701778b8ec77f 100644 --- a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" -#include "LEDWidget.h" #include "binding-handler.h" #include #include @@ -45,22 +44,24 @@ LOG_MODULE_DECLARE(app); namespace { - -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; LEDWidget sStatusLED; Button sFactoryResetButton; Button sBleAdvStartButton; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sHaveBLEConnections = false; +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; } // namespace @@ -81,12 +82,17 @@ CHIP_ERROR AppTask::Init() // Initialize status LED LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); sStatusLED.Init(SYSTEM_STATE_LED_PIN); UpdateStatusLED(); InitButtons(); + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + // Init ZCL Data Model and start server static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); @@ -152,8 +158,6 @@ CHIP_ERROR AppTask::StartApp() DispatchEvent(&event); ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); } - - sStatusLED.Animate(); } } @@ -169,8 +173,15 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { - LOG_INF("FactoryResetHandler"); - chip::Server::GetInstance().ScheduleFactoryReset(); + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } } void AppTask::StartBleAdvButtonEventHandler(void) @@ -206,6 +217,23 @@ void AppTask::StartBleAdvHandler(AppEvent * aEvent) } } +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + void AppTask::UpdateStatusLED() { if (sIsThreadProvisioned && sIsThreadEnabled) @@ -276,10 +304,35 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + void AppTask::InitButtons(void) { - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); ButtonManagerInst().AddButton(sFactoryResetButton); ButtonManagerInst().AddButton(sBleAdvStartButton); diff --git a/examples/light-switch-app/telink/include/AppEvent.h b/examples/light-switch-app/telink/include/AppEvent.h index ed69564c270adb..9a6fd3060c1685 100755 --- a/examples/light-switch-app/telink/include/AppEvent.h +++ b/examples/light-switch-app/telink/include/AppEvent.h @@ -23,12 +23,15 @@ struct AppEvent; typedef void (*EventHandler)(AppEvent *); +class LEDWidget; + struct AppEvent { enum AppEventTypes { kEventType_Button = 0, kEventType_Timer, + kEventType_UpdateLedState, kEventType_Lighting, kEventType_Install, }; @@ -50,6 +53,10 @@ struct AppEvent uint8_t Action; int32_t Actor; } LightingEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; }; EventHandler Handler; diff --git a/examples/light-switch-app/telink/include/AppTask.h b/examples/light-switch-app/telink/include/AppTask.h index 6cf0a330cf2317..6509613e3741b8 100755 --- a/examples/light-switch-app/telink/include/AppTask.h +++ b/examples/light-switch-app/telink/include/AppTask.h @@ -19,6 +19,7 @@ #pragma once #include "AppEvent.h" +#include "LEDWidget.h" #include @@ -60,6 +61,7 @@ class AppTask void DispatchEvent(AppEvent * event); static void UpdateStatusLED(); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void SwitchActionButtonEventHandler(void); static void FactoryResetButtonEventHandler(void); static void StartThreadButtonEventHandler(void); @@ -67,10 +69,14 @@ class AppTask static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetHandler(AppEvent * aEvent); static void StartThreadHandler(AppEvent * aEvent); static void SwitchActionEventHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); static void InitButtons(void); diff --git a/examples/light-switch-app/telink/src/AppTask.cpp b/examples/light-switch-app/telink/src/AppTask.cpp index c5a77caae8f701..20c3202f83038e 100644 --- a/examples/light-switch-app/telink/src/AppTask.cpp +++ b/examples/light-switch-app/telink/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" -#include "LEDWidget.h" #include "binding-handler.h" #include "ThreadUtil.h" @@ -54,10 +53,10 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; namespace { - -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; // NOTE! This key is for test/certification only and should not be available in production devices! // If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. @@ -65,6 +64,7 @@ uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; LEDWidget sStatusLED; @@ -73,10 +73,11 @@ Button sSwitchButton; Button sThreadStartButton; Button sBleAdvStartButton; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sHaveBLEConnections = false; +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -123,12 +124,17 @@ CHIP_ERROR AppTask::Init() // Initialize status LED LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); sStatusLED.Init(SYSTEM_STATE_LED_PIN); UpdateStatusLED(); InitButtons(); + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + // Initialize CHIP server #if CONFIG_CHIP_FACTORY_DATA ReturnErrorOnFailure(mFactoryDataProvider.Init()); @@ -206,8 +212,6 @@ CHIP_ERROR AppTask::StartApp() DispatchEvent(&event); ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); } - - sStatusLED.Animate(); } } @@ -245,8 +249,15 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { - LOG_INF("FactoryResetHandler"); - chip::Server::GetInstance().ScheduleFactoryReset(); + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } } void AppTask::StartThreadButtonEventHandler(void) @@ -308,6 +319,23 @@ void AppTask::StartBleAdvHandler(AppEvent * aEvent) } } +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + void AppTask::UpdateStatusLED() { if (sIsThreadProvisioned && sIsThreadEnabled) @@ -386,12 +414,37 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState() {} +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + void AppTask::InitButtons(void) { - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sSwitchButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, SwitchActionButtonEventHandler); - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sSwitchButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, false, SwitchActionButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, false, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); ButtonManagerInst().AddButton(sFactoryResetButton); ButtonManagerInst().AddButton(sSwitchButton); diff --git a/examples/lighting-app/telink/include/AppEvent.h b/examples/lighting-app/telink/include/AppEvent.h index 548d737f5c65d7..1766b5d77577a1 100644 --- a/examples/lighting-app/telink/include/AppEvent.h +++ b/examples/lighting-app/telink/include/AppEvent.h @@ -23,12 +23,15 @@ struct AppEvent; typedef void (*EventHandler)(AppEvent *); +class LEDWidget; + struct AppEvent { enum AppEventTypes { kEventType_Button = 0, kEventType_Timer, + kEventType_UpdateLedState, kEventType_Lighting, kEventType_Install, }; @@ -50,6 +53,10 @@ struct AppEvent uint8_t Action; int32_t Actor; } LightingEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; }; EventHandler Handler; diff --git a/examples/lighting-app/telink/include/AppTask.h b/examples/lighting-app/telink/include/AppTask.h index 09ba6ef240f26c..3ff9b01da4e329 100644 --- a/examples/lighting-app/telink/include/AppTask.h +++ b/examples/lighting-app/telink/include/AppTask.h @@ -20,7 +20,7 @@ #include "AppEvent.h" #include "LightingManager.h" - +#include "LEDWidget.h" #include #if CONFIG_CHIP_FACTORY_DATA @@ -65,6 +65,7 @@ class AppTask void DispatchEvent(AppEvent * event); static void UpdateStatusLED(); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void LightingActionButtonEventHandler(void); static void FactoryResetButtonEventHandler(void); static void StartThreadButtonEventHandler(void); @@ -72,10 +73,14 @@ class AppTask static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetHandler(AppEvent * aEvent); static void StartThreadHandler(AppEvent * aEvent); static void LightingActionEventHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); static void ButtonEventHandler(ButtonId_t btnId, bool btnPressed); static void InitButtons(void); diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 2a311a2a052413..daedbb7adc64f5 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -21,8 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" -#include "LEDWidget.h" -#include "LightingManager.h" #include "ThreadUtil.h" @@ -55,12 +53,12 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; namespace { - -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; -constexpr uint8_t kDefaultMinLevel = 0; -constexpr uint8_t kDefaultMaxLevel = 254; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; +constexpr uint8_t kDefaultMinLevel = 0; +constexpr uint8_t kDefaultMaxLevel = 254; // NOTE! This key is for test/certification only and should not be available in production devices! // If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. @@ -68,6 +66,7 @@ uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; LEDWidget sStatusLED; @@ -76,10 +75,11 @@ Button sLightingButton; Button sThreadStartButton; Button sBleAdvStartButton; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sHaveBLEConnections = false; +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -124,12 +124,17 @@ CHIP_ERROR AppTask::Init() // Initialize status LED LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); sStatusLED.Init(SYSTEM_STATE_LED_PIN); UpdateStatusLED(); InitButtons(); + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + // Init lighting manager uint8_t minLightLevel = kDefaultMinLevel; Clusters::LevelControl::Attributes::MinLevel::Get(1, &minLightLevel); @@ -214,8 +219,6 @@ CHIP_ERROR AppTask::StartApp() DispatchEvent(&event); ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); } - - sStatusLED.Animate(); } } @@ -263,8 +266,15 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { - LOG_INF("FactoryResetHandler"); - chip::Server::GetInstance().ScheduleFactoryReset(); + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } } void AppTask::StartThreadButtonEventHandler(void) @@ -326,6 +336,23 @@ void AppTask::StartBleAdvHandler(AppEvent * aEvent) } } +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + void AppTask::UpdateStatusLED() { if (sIsThreadProvisioned && sIsThreadEnabled) @@ -456,6 +483,31 @@ void AppTask::UpdateClusterState() } } +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + void AppTask::ButtonEventHandler(ButtonId_t btnId, bool btnPressed) { if (!btnPressed) @@ -482,10 +534,10 @@ void AppTask::ButtonEventHandler(ButtonId_t btnId, bool btnPressed) void AppTask::InitButtons(void) { - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sLightingButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, LightingActionButtonEventHandler); - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sLightingButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, false, LightingActionButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, false, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); ButtonManagerInst().AddButton(sFactoryResetButton); ButtonManagerInst().AddButton(sLightingButton); diff --git a/examples/ota-requestor-app/telink/include/AppEvent.h b/examples/ota-requestor-app/telink/include/AppEvent.h index ed69564c270adb..9a6fd3060c1685 100644 --- a/examples/ota-requestor-app/telink/include/AppEvent.h +++ b/examples/ota-requestor-app/telink/include/AppEvent.h @@ -23,12 +23,15 @@ struct AppEvent; typedef void (*EventHandler)(AppEvent *); +class LEDWidget; + struct AppEvent { enum AppEventTypes { kEventType_Button = 0, kEventType_Timer, + kEventType_UpdateLedState, kEventType_Lighting, kEventType_Install, }; @@ -50,6 +53,10 @@ struct AppEvent uint8_t Action; int32_t Actor; } LightingEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; }; EventHandler Handler; diff --git a/examples/ota-requestor-app/telink/include/AppTask.h b/examples/ota-requestor-app/telink/include/AppTask.h index 712212e38fd80d..a8b5c2dd3e7a93 100755 --- a/examples/ota-requestor-app/telink/include/AppTask.h +++ b/examples/ota-requestor-app/telink/include/AppTask.h @@ -19,6 +19,7 @@ #pragma once #include "AppEvent.h" +#include "LEDWidget.h" #include @@ -56,15 +57,20 @@ class AppTask void DispatchEvent(AppEvent * event); static void UpdateStatusLED(); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void FactoryResetButtonEventHandler(void); static void StartThreadButtonEventHandler(void); static void StartBleAdvButtonEventHandler(void); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetHandler(AppEvent * aEvent); static void StartThreadHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); static void InitButtons(void); diff --git a/examples/ota-requestor-app/telink/src/AppTask.cpp b/examples/ota-requestor-app/telink/src/AppTask.cpp index 8343e3ddc38f65..89b497ad08d27c 100644 --- a/examples/ota-requestor-app/telink/src/AppTask.cpp +++ b/examples/ota-requestor-app/telink/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" -#include "LEDWidget.h" #include #include @@ -56,12 +55,13 @@ LOG_MODULE_DECLARE(app); namespace { - -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; LEDWidget sStatusLED; @@ -69,10 +69,11 @@ Button sFactoryResetButton; Button sThreadStartButton; Button sBleAdvStartButton; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sHaveBLEConnections = false; +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -126,12 +127,17 @@ CHIP_ERROR AppTask::Init() // Initialize status LED LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); sStatusLED.Init(SYSTEM_STATE_LED_PIN); UpdateStatusLED(); InitButtons(); + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + // Init ZCL Data Model and start server static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); @@ -191,8 +197,6 @@ CHIP_ERROR AppTask::StartApp() DispatchEvent(&event); ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); } - - sStatusLED.Animate(); } } @@ -208,8 +212,15 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { - LOG_INF("FactoryResetHandler"); - chip::Server::GetInstance().ScheduleFactoryReset(); + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } } void AppTask::StartThreadButtonEventHandler(void) @@ -271,6 +282,23 @@ void AppTask::StartBleAdvHandler(AppEvent * aEvent) } } +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + void AppTask::UpdateStatusLED() { if (sIsThreadProvisioned && sIsThreadEnabled) @@ -341,11 +369,36 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + void AppTask::InitButtons(void) { - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, false, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); ButtonManagerInst().AddButton(sFactoryResetButton); ButtonManagerInst().AddButton(sThreadStartButton); diff --git a/examples/platform/telink/util/include/ButtonManager.h b/examples/platform/telink/util/include/ButtonManager.h index 9c164fd7120c82..c728d59a5ea48d 100644 --- a/examples/platform/telink/util/include/ButtonManager.h +++ b/examples/platform/telink/util/include/ButtonManager.h @@ -26,7 +26,7 @@ class Button { public: - void Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, void (*callback)(void)); + void Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, bool intBothLevel, void (*callback)(void)); void Poll(Button * previous); void SetCallback(void (*callback)(void)); @@ -38,6 +38,7 @@ class Button gpio_pin_t mOutPin; gpio_pin_t mInPin; int mPreviousState = STATE_LOW; + bool mIntBothLevel = false; void (*mCallback)(void) = NULL; }; diff --git a/examples/platform/telink/util/include/LEDWidget.h b/examples/platform/telink/util/include/LEDWidget.h index e851c03ccc04e2..b1e25d4f91a703 100644 --- a/examples/platform/telink/util/include/LEDWidget.h +++ b/examples/platform/telink/util/include/LEDWidget.h @@ -19,25 +19,32 @@ #include #include +#include class LEDWidget { public: + typedef void (*LEDWidgetStateUpdateHandler)(LEDWidget * ledWidget); + static void InitGpio(const device * port); + static void SetStateUpdateCallback(LEDWidgetStateUpdateHandler stateUpdateCb); const static struct device * mPort; void Init(gpio_pin_t gpioNum); void Set(bool state); void Invert(void); void Blink(uint32_t changeRateMS); void Blink(uint32_t onTimeMS, uint32_t offTimeMS); - void Animate(); + void UpdateState(); private: - int64_t mLastChangeTimeMS; uint32_t mBlinkOnTimeMS; uint32_t mBlinkOffTimeMS; gpio_pin_t mGPIONum; bool mState; + k_timer mLedTimer; + + static void LedStateTimerHandler(k_timer * timer); void DoSet(bool state); + void ScheduleStateChange(); }; diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index 9afc6ed0f2493d..89d78cf6020277 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -29,14 +29,15 @@ LOG_MODULE_REGISTER(ButtonManager); ButtonManager ButtonManager::sInstance; -void Button::Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, void (*callback)(void)) +void Button::Configure(const struct device * port, gpio_pin_t outPin, gpio_pin_t inPin, bool intBothLevel, void (*callback)(void)) { __ASSERT(device_is_ready(port), "%s is not ready\n", port->name); - mPort = port; - mOutPin = outPin; - mInPin = inPin; - mCallback = callback; + mPort = port; + mOutPin = outPin; + mInPin = inPin; + mIntBothLevel = intBothLevel; + mCallback = callback; } int Button::Init(void) @@ -91,19 +92,16 @@ void Button::Poll(Button * previous) ret = gpio_pin_get(mPort, mInPin); assert(ret >= 0); - if (ret == STATE_HIGH && mPreviousState != STATE_HIGH) + if ((mIntBothLevel && ret != mPreviousState) + || (!mIntBothLevel && ret == STATE_HIGH && ret != mPreviousState)) { - mPreviousState = STATE_HIGH; - if (mCallback != NULL) { mCallback(); } } - else if (ret == STATE_LOW) - { - mPreviousState = STATE_LOW; - } + + mPreviousState = ret; k_msleep(10); } diff --git a/examples/platform/telink/util/src/LEDWidget.cpp b/examples/platform/telink/util/src/LEDWidget.cpp index 3b97fe64375058..cefb8bbc1cb2a0 100644 --- a/examples/platform/telink/util/src/LEDWidget.cpp +++ b/examples/platform/telink/util/src/LEDWidget.cpp @@ -21,6 +21,7 @@ #include const struct device * LEDWidget::mPort = NULL; +static LEDWidget::LEDWidgetStateUpdateHandler sStateUpdateCallback; void LEDWidget::InitGpio(const device * port) { @@ -28,17 +29,25 @@ void LEDWidget::InitGpio(const device * port) __ASSERT(device_is_ready(mPort), "%s is not ready\n", mPort->name); } +void LEDWidget::SetStateUpdateCallback(LEDWidgetStateUpdateHandler stateUpdateCb) +{ + if (stateUpdateCb) + sStateUpdateCallback = stateUpdateCb; +} + void LEDWidget::Init(gpio_pin_t gpioNum) { - mLastChangeTimeMS = 0; - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - mGPIONum = gpioNum; - mState = false; + mBlinkOnTimeMS = 0; + mBlinkOffTimeMS = 0; + mGPIONum = gpioNum; + mState = false; int ret = gpio_pin_configure(mPort, mGPIONum, GPIO_OUTPUT_ACTIVE); __ASSERT(ret >= 0, "GPIO pin %d configure - fail. Status%d\n", mGPIONum, ret); + k_timer_init(&mLedTimer, &LEDWidget::LedStateTimerHandler, nullptr); + k_timer_user_data_set(&mLedTimer, this); + Set(false); } @@ -49,7 +58,8 @@ void LEDWidget::Invert(void) void LEDWidget::Set(bool state) { - mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; + k_timer_stop(&mLedTimer); + mBlinkOnTimeMS = mBlinkOffTimeMS = 0; DoSet(state); } @@ -60,29 +70,42 @@ void LEDWidget::Blink(uint32_t changeRateMS) void LEDWidget::Blink(uint32_t onTimeMS, uint32_t offTimeMS) { + k_timer_stop(&mLedTimer); + mBlinkOnTimeMS = onTimeMS; mBlinkOffTimeMS = offTimeMS; - Animate(); -} -void LEDWidget::Animate() -{ if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) { - int64_t nowMS = k_uptime_get(); - int64_t stateDurMS = mState ? mBlinkOnTimeMS : mBlinkOffTimeMS; - - if (nowMS > mLastChangeTimeMS + stateDurMS) - { - DoSet(!mState); - mLastChangeTimeMS = nowMS; - } + DoSet(!mState); + ScheduleStateChange(); } } +void LEDWidget::ScheduleStateChange() +{ + k_timer_start(&mLedTimer, K_MSEC(mState ? mBlinkOnTimeMS : mBlinkOffTimeMS), K_NO_WAIT); +} + void LEDWidget::DoSet(bool state) { mState = state; int ret = gpio_pin_set(mPort, mGPIONum, state); __ASSERT(ret >= 0, "GPIO pin %d set -fail. Status: %d\n", mGPIONum, ret); } + +void LEDWidget::UpdateState() +{ + /* Prevent from keep updating the state if LED was set to solid On/Off value */ + if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) + { + DoSet(!mState); + ScheduleStateChange(); + } +} + +void LEDWidget::LedStateTimerHandler(k_timer * timer) +{ + if (sStateUpdateCallback) + sStateUpdateCallback(reinterpret_cast(timer->user_data)); +} diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index da8827efde529d..3b70797dae4a24 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit da8827efde529d79e6d7f29277721ba460efbca7 +Subproject commit 3b70797dae4a24302f8320a38dc704bde3addf16 From a42f52e14683870b35a1f8b46732cf78df8c945a Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 20 Dec 2022 12:44:34 +0200 Subject: [PATCH 07/18] [Telink] Revert submodule change --- third_party/silabs/matter_support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 3b70797dae4a24..da8827efde529d 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 3b70797dae4a24302f8320a38dc704bde3addf16 +Subproject commit da8827efde529d79e6d7f29277721ba460efbca7 From fde3529dbe693d71b5becbe58390eb5ea0c69d66 Mon Sep 17 00:00:00 2001 From: Serhii Salamakha Date: Tue, 20 Dec 2022 13:53:37 +0200 Subject: [PATCH 08/18] [Telink] Added last changes also to the Thermostat example --- examples/thermostat/telink/include/AppEvent.h | 7 ++ examples/thermostat/telink/include/AppTask.h | 6 ++ examples/thermostat/telink/src/AppTask.cpp | 85 +++++++++++++++---- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/examples/thermostat/telink/include/AppEvent.h b/examples/thermostat/telink/include/AppEvent.h index 21933d1d03d1d3..07a10228175763 100755 --- a/examples/thermostat/telink/include/AppEvent.h +++ b/examples/thermostat/telink/include/AppEvent.h @@ -23,12 +23,15 @@ struct AppEvent; typedef void (*EventHandler)(AppEvent *); +class LEDWidget; + struct AppEvent { enum AppEventTypes { kEventType_Button = 0, kEventType_Timer, + kEventType_UpdateLedState, kEventType_Thermostat, kEventType_Install, }; @@ -45,6 +48,10 @@ struct AppEvent { void * Context; } TimerEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; }; EventHandler Handler; diff --git a/examples/thermostat/telink/include/AppTask.h b/examples/thermostat/telink/include/AppTask.h index 8a3322d11d1342..18edadc0436845 100755 --- a/examples/thermostat/telink/include/AppTask.h +++ b/examples/thermostat/telink/include/AppTask.h @@ -19,6 +19,7 @@ #pragma once #include "AppEvent.h" +#include "LEDWidget.h" #include "SensorManager.h" #include "TemperatureManager.h" @@ -50,15 +51,20 @@ class AppTask void DispatchEvent(AppEvent * event); static void UpdateStatusLED(); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void FactoryResetButtonEventHandler(void); static void StartThreadButtonEventHandler(void); static void StartBleAdvButtonEventHandler(void); static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); static void FactoryResetHandler(AppEvent * aEvent); static void StartThreadHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); static void InitButtons(void); diff --git a/examples/thermostat/telink/src/AppTask.cpp b/examples/thermostat/telink/src/AppTask.cpp index e56092d65262a1..86cb7190bf4ee5 100644 --- a/examples/thermostat/telink/src/AppTask.cpp +++ b/examples/thermostat/telink/src/AppTask.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" -#include "LEDWidget.h" #include "ThreadUtil.h" @@ -53,10 +52,10 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; namespace { - -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; // NOTE! This key is for test/certification only and should not be available in production devices! // If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. @@ -64,6 +63,7 @@ uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; LEDWidget sStatusLED; @@ -71,10 +71,11 @@ Button sFactoryResetButton; Button sThreadStartButton; Button sBleAdvStartButton; -bool sIsThreadProvisioned = false; -bool sIsThreadEnabled = false; -bool sIsThreadAttached = false; -bool sHaveBLEConnections = false; +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; @@ -121,12 +122,17 @@ CHIP_ERROR AppTask::Init() // Initialize status LED LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); sStatusLED.Init(SYSTEM_STATE_LED_PIN); UpdateStatusLED(); InitButtons(); + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + // Initialize CHIP server #if CONFIG_CHIP_FACTORY_DATA ReturnErrorOnFailure(mFactoryDataProvider.Init()); @@ -209,8 +215,6 @@ CHIP_ERROR AppTask::StartApp() DispatchEvent(&event); ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); } - - sStatusLED.Animate(); } } @@ -232,8 +236,15 @@ void AppTask::FactoryResetButtonEventHandler(void) void AppTask::FactoryResetHandler(AppEvent * aEvent) { - LOG_INF("FactoryResetHandler"); - chip::Server::GetInstance().ScheduleFactoryReset(); + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } } void AppTask::StartThreadButtonEventHandler(void) @@ -295,6 +306,23 @@ void AppTask::StartBleAdvHandler(AppEvent * aEvent) } } +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + void AppTask::UpdateStatusLED() { if (sIsThreadProvisioned && sIsThreadEnabled) @@ -363,11 +391,36 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState() {} +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + void AppTask::InitButtons(void) { - sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); - sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); - sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, false, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); ButtonManagerInst().AddButton(sFactoryResetButton); ButtonManagerInst().AddButton(sThreadStartButton); From 76a728290381bab91fa7e508584d3334cf11339b Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 20 Dec 2022 15:42:11 +0200 Subject: [PATCH 09/18] [Telink] Restyled --- examples/all-clusters-app/telink/include/AppEvent.h | 2 +- examples/all-clusters-app/telink/src/AppTask.cpp | 7 ++++--- .../all-clusters-minimal-app/telink/include/AppEvent.h | 2 +- examples/all-clusters-minimal-app/telink/src/AppTask.cpp | 7 ++++--- examples/light-switch-app/telink/src/AppTask.cpp | 7 ++++--- examples/lighting-app/telink/include/AppTask.h | 2 +- examples/lighting-app/telink/src/AppTask.cpp | 7 ++++--- examples/ota-requestor-app/telink/src/AppTask.cpp | 7 ++++--- examples/platform/telink/util/src/ButtonManager.cpp | 3 +-- examples/thermostat/telink/src/AppTask.cpp | 7 ++++--- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/examples/all-clusters-app/telink/include/AppEvent.h b/examples/all-clusters-app/telink/include/AppEvent.h index 5c5d72f5b8ace1..54250995e06ca8 100644 --- a/examples/all-clusters-app/telink/include/AppEvent.h +++ b/examples/all-clusters-app/telink/include/AppEvent.h @@ -42,7 +42,7 @@ struct AppEvent { uint8_t Action; } ButtonEvent; - struct + struct { void * Context; } TimerEvent; diff --git a/examples/all-clusters-app/telink/src/AppTask.cpp b/examples/all-clusters-app/telink/src/AppTask.cpp index 9a6a8f2aa3b8de..9115d89174cbdf 100644 --- a/examples/all-clusters-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-app/telink/src/AppTask.cpp @@ -218,7 +218,8 @@ void AppTask::FactoryResetHandler(AppEvent * aEvent) k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); sIsFactoryResetTimerActive = true; } - else { + else + { k_timer_stop(&sFactoryResetTimer); sIsFactoryResetTimerActive = false; } @@ -378,8 +379,8 @@ void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) } AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.Handler = FactoryResetTimerEventHandler; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; sAppTask.PostEvent(&event); } diff --git a/examples/all-clusters-minimal-app/telink/include/AppEvent.h b/examples/all-clusters-minimal-app/telink/include/AppEvent.h index 5c5d72f5b8ace1..54250995e06ca8 100644 --- a/examples/all-clusters-minimal-app/telink/include/AppEvent.h +++ b/examples/all-clusters-minimal-app/telink/include/AppEvent.h @@ -42,7 +42,7 @@ struct AppEvent { uint8_t Action; } ButtonEvent; - struct + struct { void * Context; } TimerEvent; diff --git a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp index 7701778b8ec77f..9ba7ed94593dc5 100644 --- a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp @@ -178,7 +178,8 @@ void AppTask::FactoryResetHandler(AppEvent * aEvent) k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); sIsFactoryResetTimerActive = true; } - else { + else + { k_timer_stop(&sFactoryResetTimer); sIsFactoryResetTimerActive = false; } @@ -312,8 +313,8 @@ void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) } AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.Handler = FactoryResetTimerEventHandler; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; sAppTask.PostEvent(&event); } diff --git a/examples/light-switch-app/telink/src/AppTask.cpp b/examples/light-switch-app/telink/src/AppTask.cpp index 20c3202f83038e..294e81fdfb609f 100644 --- a/examples/light-switch-app/telink/src/AppTask.cpp +++ b/examples/light-switch-app/telink/src/AppTask.cpp @@ -254,7 +254,8 @@ void AppTask::FactoryResetHandler(AppEvent * aEvent) k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); sIsFactoryResetTimerActive = true; } - else { + else + { k_timer_stop(&sFactoryResetTimer); sIsFactoryResetTimerActive = false; } @@ -422,8 +423,8 @@ void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) } AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.Handler = FactoryResetTimerEventHandler; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; sAppTask.PostEvent(&event); } diff --git a/examples/lighting-app/telink/include/AppTask.h b/examples/lighting-app/telink/include/AppTask.h index 3ff9b01da4e329..26575805d70a5d 100644 --- a/examples/lighting-app/telink/include/AppTask.h +++ b/examples/lighting-app/telink/include/AppTask.h @@ -19,8 +19,8 @@ #pragma once #include "AppEvent.h" -#include "LightingManager.h" #include "LEDWidget.h" +#include "LightingManager.h" #include #if CONFIG_CHIP_FACTORY_DATA diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index daedbb7adc64f5..f24d8a315c6ef3 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -271,7 +271,8 @@ void AppTask::FactoryResetHandler(AppEvent * aEvent) k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); sIsFactoryResetTimerActive = true; } - else { + else + { k_timer_stop(&sFactoryResetTimer); sIsFactoryResetTimerActive = false; } @@ -491,8 +492,8 @@ void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) } AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.Handler = FactoryResetTimerEventHandler; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; sAppTask.PostEvent(&event); } diff --git a/examples/ota-requestor-app/telink/src/AppTask.cpp b/examples/ota-requestor-app/telink/src/AppTask.cpp index 89b497ad08d27c..fddb95b4ae2989 100644 --- a/examples/ota-requestor-app/telink/src/AppTask.cpp +++ b/examples/ota-requestor-app/telink/src/AppTask.cpp @@ -217,7 +217,8 @@ void AppTask::FactoryResetHandler(AppEvent * aEvent) k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); sIsFactoryResetTimerActive = true; } - else { + else + { k_timer_stop(&sFactoryResetTimer); sIsFactoryResetTimerActive = false; } @@ -377,8 +378,8 @@ void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) } AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.Handler = FactoryResetTimerEventHandler; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; sAppTask.PostEvent(&event); } diff --git a/examples/platform/telink/util/src/ButtonManager.cpp b/examples/platform/telink/util/src/ButtonManager.cpp index 89d78cf6020277..21decd38b54298 100644 --- a/examples/platform/telink/util/src/ButtonManager.cpp +++ b/examples/platform/telink/util/src/ButtonManager.cpp @@ -92,8 +92,7 @@ void Button::Poll(Button * previous) ret = gpio_pin_get(mPort, mInPin); assert(ret >= 0); - if ((mIntBothLevel && ret != mPreviousState) - || (!mIntBothLevel && ret == STATE_HIGH && ret != mPreviousState)) + if ((mIntBothLevel && ret != mPreviousState) || (!mIntBothLevel && ret == STATE_HIGH && ret != mPreviousState)) { if (mCallback != NULL) { diff --git a/examples/thermostat/telink/src/AppTask.cpp b/examples/thermostat/telink/src/AppTask.cpp index 86cb7190bf4ee5..2fa744dd7a7f94 100644 --- a/examples/thermostat/telink/src/AppTask.cpp +++ b/examples/thermostat/telink/src/AppTask.cpp @@ -241,7 +241,8 @@ void AppTask::FactoryResetHandler(AppEvent * aEvent) k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); sIsFactoryResetTimerActive = true; } - else { + else + { k_timer_stop(&sFactoryResetTimer); sIsFactoryResetTimerActive = false; } @@ -399,8 +400,8 @@ void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) } AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.Handler = FactoryResetTimerEventHandler; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; sAppTask.PostEvent(&event); } From bacc0da7355acbd39301517939a0497e68617114 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 20 Dec 2022 15:42:40 +0200 Subject: [PATCH 10/18] [Telink] Add contact sensor app example --- examples/contact-sensor-app/telink/.gitignore | 1 + .../contact-sensor-app/telink/CMakeLists.txt | 64 +++ examples/contact-sensor-app/telink/Readme.md | 159 ++++++ .../telink/include/AppConfig.h | 37 ++ .../telink/include/AppEvent.h | 57 ++ .../telink/include/AppTask.h | 107 ++++ .../telink/include/CHIPProjectConfig.h | 39 ++ .../telink/include/ContactSensorManager.h | 62 +++ examples/contact-sensor-app/telink/prj.conf | 58 ++ .../contact-sensor-app/telink/src/AppTask.cpp | 506 ++++++++++++++++++ .../telink/src/ContactSensorManager.cpp | 87 +++ .../telink/src/ZclCallbacks.cpp | 56 ++ .../contact-sensor-app/telink/src/main.cpp | 82 +++ .../telink/third_party/connectedhomeip | 1 + 14 files changed, 1316 insertions(+) create mode 100644 examples/contact-sensor-app/telink/.gitignore create mode 100755 examples/contact-sensor-app/telink/CMakeLists.txt create mode 100755 examples/contact-sensor-app/telink/Readme.md create mode 100755 examples/contact-sensor-app/telink/include/AppConfig.h create mode 100755 examples/contact-sensor-app/telink/include/AppEvent.h create mode 100644 examples/contact-sensor-app/telink/include/AppTask.h create mode 100755 examples/contact-sensor-app/telink/include/CHIPProjectConfig.h create mode 100644 examples/contact-sensor-app/telink/include/ContactSensorManager.h create mode 100755 examples/contact-sensor-app/telink/prj.conf create mode 100644 examples/contact-sensor-app/telink/src/AppTask.cpp create mode 100644 examples/contact-sensor-app/telink/src/ContactSensorManager.cpp create mode 100644 examples/contact-sensor-app/telink/src/ZclCallbacks.cpp create mode 100755 examples/contact-sensor-app/telink/src/main.cpp create mode 120000 examples/contact-sensor-app/telink/third_party/connectedhomeip diff --git a/examples/contact-sensor-app/telink/.gitignore b/examples/contact-sensor-app/telink/.gitignore new file mode 100644 index 00000000000000..84c048a73cc2e5 --- /dev/null +++ b/examples/contact-sensor-app/telink/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/examples/contact-sensor-app/telink/CMakeLists.txt b/examples/contact-sensor-app/telink/CMakeLists.txt new file mode 100755 index 00000000000000..b75ad4764331b4 --- /dev/null +++ b/examples/contact-sensor-app/telink/CMakeLists.txt @@ -0,0 +1,64 @@ +# +# Copyright (c) 2022 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. +# +cmake_minimum_required(VERSION 3.13.1) + +set(BOARD tlsr9518adk80d) + +get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH) +get_filename_component(TELINK_COMMON ${CHIP_ROOT}/examples/platform/telink REALPATH) +get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH) + +set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) + +# Load NCS/Zephyr build system +list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) +find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) + +project(chip-telink-contact-sensor-example) + +include(${CHIP_ROOT}/config/telink/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) + +target_compile_options(app PRIVATE -fpermissive) + +target_include_directories(app PRIVATE + include + ${GEN_DIR}/app-common + ${GEN_DIR}/contact-sensor-app + ${TELINK_COMMON}/util/include) + +add_definitions( + "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" +) + +target_sources(app PRIVATE + src/AppTask.cpp + src/ContactSensorManager.cpp + src/main.cpp + src/ZclCallbacks.cpp + ${GEN_DIR}/contact-sensor-app/zap-generated/IMClusterCommandHandler.cpp + ${TELINK_COMMON}/util/src/LEDWidget.cpp + ${TELINK_COMMON}/util/src/ButtonManager.cpp + ${TELINK_COMMON}/util/src/ThreadUtil.cpp) + +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../contact-sensor-common/contact-sensor-app.zap +) + +if(CONFIG_CHIP_OTA_REQUESTOR) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/contact-sensor-app/telink/Readme.md b/examples/contact-sensor-app/telink/Readme.md new file mode 100755 index 00000000000000..31b004dd7aaa5b --- /dev/null +++ b/examples/contact-sensor-app/telink/Readme.md @@ -0,0 +1,159 @@ +# Matter Telink Contact Sensor Example Application + +You can use this example as a reference for creating your own application. + +![Telink B91 EVK](http://wiki.telink-semi.cn/wiki/assets/Hardware/B91_Generic_Starter_Kit_Hardware_Guide/connection_chart.png) + +## Build and flash + +1. Pull docker image from repository: + + ```bash + $ docker pull connectedhomeip/chip-build-telink:latest + ``` + +1. Run docker container: + + ```bash + $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" connectedhomeip/chip-build-telink:latest + ``` + + here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay + attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** + +1. Activate the build environment: + + ```bash + $ source ./scripts/activate.sh + ``` + +1. In the example dir run: + + ```bash + $ west build + ``` + +1. Flash binary: + + ``` + $ west flash --erase + ``` + +## Usage + +### UART + +To get output from device, connect UART to following pins: + +| Name | Pin | +| :--: | :---------------------------- | +| RX | PB3 (pin 17 of J34 connector) | +| TX | PB2 (pin 16 of J34 connector) | +| GND | GND | + +### Buttons + +The following buttons are available on **tlsr9518adk80d** board: + +| Name | Function | Description | +| :------- | :--------------------- | :----------------------------------------------------------------------------------------------------- | +| Button 1 | Factory reset | Perform factory reset to forget currently commissioned Thread network and back to uncommissioned state | +| Button 2 | Toggle Contact State | Manually triggers the Contact Sensor State | +| Button 3 | NA | NA | +| Button 4 | Open commission window | The button is opening commissioning window to perform commissioning over BLE | + +### LEDs + +**Red** LED indicates current state of Thread network. It ables to be in +following states: + +| State | Description | +| :-------------------------- | :--------------------------------------------------------------------------- | +| Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled | +| Blinls with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | +| Blinks with whde pulses | Device commissioned and joined to thread network as CHILD | + +**Blue** LED shows current state of Contact Sensor + +### CHIP tool commands + +1. Build + [chip-tool cli](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) + +2. Pair with device + + ``` + ${CHIP_TOOL_DIR}/chip-tool pairing ble-thread ${NODE_ID} hex:${DATASET} ${PIN_CODE} ${DISCRIMINATOR} + ``` + + Example: + + ``` + ./chip-tool pairing ble-thread 1234 hex:0e080000000000010000000300000f35060004001fffe0020811111111222222220708fd61f77bd3df233e051000112233445566778899aabbccddeeff030e4f70656e54687265616444656d6f010212340410445f2b5ca6f2a93a55ce570a70efeecb0c0402a0fff8 20202021 3840 + ``` + +### OTA with Linux OTA Provider + +OTA feature enabled by default only for ota-requestor-app example. To enable OTA +feature for another Telink example: + +- set CONFIG_CHIP_OTA_REQUESTOR=y in corresponding "prj.conf" configuration + file. + +After build application with enabled OTA feature, use next binary files: + +- zephyr.bin - main binary to flash PCB (Use 2MB PCB). +- zephyr-ota.bin - binary for OTA Provider + +All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have +higher SW version than base SW. Set CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2 in +corresponding “prj.conf” configuration file. + +Usage of OTA: + +- Build the [Linux OTA Provider](../../ota-provider-app/linux) + + ``` + ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false + ``` + +- Run the Linux OTA Provider with OTA image. + + ``` + ./chip-ota-provider-app -f zephyr-ota.bin + ``` + +- Provision the Linux OTA Provider using chip-tool + + ``` + ./chip-tool pairing onnetwork ${OTA_PROVIDER_NODE_ID} 20202021 + ``` + + here: + + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider + +- Configure the ACL of the ota-provider-app to allow access + + ``` + ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' ${OTA_PROVIDER_NODE_ID} 0 + ``` + + here: + + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider + +- Use the chip-tool to announce the ota-provider-app to start the OTA process + + ``` + ./chip-tool otasoftwareupdaterequestor announce-ota-provider ${OTA_PROVIDER_NODE_ID} 0 0 0 ${DEVICE_NODE_ID} 0 + ``` + + here: + + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider + - \${DEVICE_NODE_ID} is the node id of paired device + +Once the transfer is complete, OTA requestor sends ApplyUpdateRequest command to +OTA provider for applying the image. Device will restart on successful +application of OTA image. diff --git a/examples/contact-sensor-app/telink/include/AppConfig.h b/examples/contact-sensor-app/telink/include/AppConfig.h new file mode 100755 index 00000000000000..01128b76e4d929 --- /dev/null +++ b/examples/contact-sensor-app/telink/include/AppConfig.h @@ -0,0 +1,37 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +// ---- Contact Sensor Example App Config ---- + +// Buttons config +#define BUTTON_PORT DEVICE_DT_GET(DT_NODELABEL(gpioc)) + +#define BUTTON_PIN_1 2 +#define BUTTON_PIN_3 3 +#define BUTTON_PIN_4 1 +#define BUTTON_PIN_2 0 + +// LEDs config +// System led config +#define SYSTEM_STATE_LED_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) +#define SYSTEM_STATE_LED_PIN 7 + +// Contact state led +#define CONTACT_STATE_LED_PIN 4 diff --git a/examples/contact-sensor-app/telink/include/AppEvent.h b/examples/contact-sensor-app/telink/include/AppEvent.h new file mode 100755 index 00000000000000..4051ba31cbb465 --- /dev/null +++ b/examples/contact-sensor-app/telink/include/AppEvent.h @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +struct AppEvent; +typedef void (*EventHandler)(AppEvent *); + +class LEDWidget; + +struct AppEvent +{ + enum AppEventTypes + { + kEventType_Button = 0, + kEventType_Timer, + kEventType_UpdateLedState, + kEventType_Contact, + }; + + uint16_t Type; + + union + { + struct + { + uint8_t Action; + } ButtonEvent; + struct + { + uint8_t Action; + } ContactEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; + }; + + EventHandler Handler; +}; diff --git a/examples/contact-sensor-app/telink/include/AppTask.h b/examples/contact-sensor-app/telink/include/AppTask.h new file mode 100644 index 00000000000000..ad6f98c7c2cf66 --- /dev/null +++ b/examples/contact-sensor-app/telink/include/AppTask.h @@ -0,0 +1,107 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "AppEvent.h" +#include "ContactSensorManager.h" +#include "LEDWidget.h" + +#include + +#include + +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + +#include + +// Application-defined error codes in the CHIP_ERROR space. +#define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) + +struct k_timer; + +class AppTask +{ +public: + CHIP_ERROR StartApp(void); + + void PostContactActionRequest(ContactSensorManager::Action aAction); + void PostEvent(AppEvent * event); + void UpdateClusterState(void); + void UpdateDeviceState(void); + + bool IsSyncClusterToButtonAction(void); + void SetSyncClusterToButtonAction(bool value); + +private: + friend AppTask & GetAppTask(void); + CHIP_ERROR Init(void); + + void DispatchEvent(AppEvent * event); + + static void OnStateChanged(ContactSensorManager::State aState); + + static void UpdateClusterStateInternal(intptr_t arg); + static void UpdateDeviceStateInternal(intptr_t arg); + + static void UpdateStatusLED(void); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); + static void FactoryResetButtonEventHandler(void); + static void StartBleAdvButtonEventHandler(void); + static void ToggleContactStateButtonEventHandler(void); + + static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); + static void FactoryResetHandler(AppEvent * aEvent); + static void StartBleAdvHandler(AppEvent * aEvent); + static void ContactActionEventHandler(AppEvent * aEvent); + static void UpdateLedStateEventHandler(AppEvent * aEvent); + + static void InitButtons(void); + + static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + + bool mSyncClusterToButtonAction = false; + + static AppTask sAppTask; + +#if CONFIG_CHIP_FACTORY_DATA + // chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} + +inline bool AppTask::IsSyncClusterToButtonAction() +{ + return mSyncClusterToButtonAction; +} + +inline void AppTask::SetSyncClusterToButtonAction(bool value) +{ + mSyncClusterToButtonAction = value; +} diff --git a/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h b/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h new file mode 100755 index 00000000000000..2fda70c57da9dc --- /dev/null +++ b/examples/contact-sensor-app/telink/include/CHIPProjectConfig.h @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2022 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. + */ + +/** + * @file + * Example project configuration file for CHIP. + * + * This is a place to put application or project-specific overrides + * to the default configuration values for general CHIP features. + * + */ + +#pragma once + +// 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/include/ContactSensorManager.h b/examples/contact-sensor-app/telink/include/ContactSensorManager.h new file mode 100644 index 00000000000000..0f735288b6ee39 --- /dev/null +++ b/examples/contact-sensor-app/telink/include/ContactSensorManager.h @@ -0,0 +1,62 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "AppEvent.h" + +class ContactSensorManager +{ +public: + enum class Action : uint8_t + { + kSignalDetected = 0, + kSignalLost, + kInvalid + }; + + enum class State : uint8_t + { + kContactClosed = 0, + kContactOpened, + kInvalid + }; + + int Init(); + bool IsContactClosed(); + void InitiateAction(Action aAction); + + typedef void (*CallbackStateChanged)(State aState); + void SetCallback(CallbackStateChanged aCallbackStateChanged); + + static void HandleAction(AppEvent * aEvent); + +private: + friend ContactSensorManager & ContactSensorMgr(void); + State mState; + CallbackStateChanged mCallbackStateChanged; + static ContactSensorManager sContactSensor; +}; + +inline ContactSensorManager & ContactSensorMgr(void) +{ + return ContactSensorManager::sContactSensor; +} diff --git a/examples/contact-sensor-app/telink/prj.conf b/examples/contact-sensor-app/telink/prj.conf new file mode 100755 index 00000000000000..6c4ad9d8975f05 --- /dev/null +++ b/examples/contact-sensor-app/telink/prj.conf @@ -0,0 +1,58 @@ +# +# Copyright (c) 2022 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. +# + +# This sample uses sample-defaults.conf to set options common for all +# samples. This file should contain only options specific for this sample +# or overrides of default values. + +# enable GPIO +CONFIG_GPIO=y + +# OpenThread configs +CONFIG_OPENTHREAD_MTD=y +CONFIG_OPENTHREAD_FTD=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_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 +CONFIG_CHIP_LIB_SHELL=n + +# Disable factory data support. +CONFIG_CHIP_FACTORY_DATA=n +CONFIG_CHIP_FACTORY_DATA_BUILD=n +CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n \ No newline at end of file diff --git a/examples/contact-sensor-app/telink/src/AppTask.cpp b/examples/contact-sensor-app/telink/src/AppTask.cpp new file mode 100644 index 00000000000000..e6933571a7a041 --- /dev/null +++ b/examples/contact-sensor-app/telink/src/AppTask.cpp @@ -0,0 +1,506 @@ +/* + * + * Copyright (c) 2022 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 "AppConfig.h" +#include "AppEvent.h" +#include "ButtonManager.h" + +#include "ThreadUtil.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if CONFIG_CHIP_OTA_REQUESTOR +#include "OTAUtil.h" +#endif + +#include +#include + +LOG_MODULE_DECLARE(app); + +using namespace ::chip; +using namespace ::chip::app; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; + +namespace { + +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; + +// NOTE! This key is for test/certification only and should not be available in production devices! +// If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. +uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; + +K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); +k_timer sFactoryResetTimer; + +LEDWidget sStatusLED; +LEDWidget sContactSensorLED; + +Button sFactoryResetButton; +Button sToggleContactStateButton; +Button sBleAdvStartButton; + +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; +bool sIsFactoryResetTimerActive = false; + +chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; + +void OnIdentifyTriggerEffect(Identify * identify) +{ + switch (identify->mCurrentEffectIdentifier) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + break; + } + return; +} + +Identify sIdentify = { + chip::EndpointId{ 1 }, + [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); }, + [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnIdentifyTriggerEffect, +}; + +} // namespace + +AppTask AppTask::sAppTask; + +CHIP_ERROR AppTask::Init() +{ + CHIP_ERROR err; + + LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); + + // Initialize status LED + LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); + sStatusLED.Init(SYSTEM_STATE_LED_PIN); + + UpdateStatusLED(); + + sContactSensorLED.Init(CONTACT_STATE_LED_PIN); + sContactSensorLED.Set(ContactSensorMgr().IsContactClosed()); + + UpdateDeviceState(); + + InitButtons(); + + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + + // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); + // Read EnableKey from the factory data. + MutableByteSpan enableKey(sTestEventTriggerEnableKey); + err = mFactoryDataProvider.GetEnableKey(enableKey); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("GetEnableKey fail"); + memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); + } +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + + static CommonCaseDeviceServerInitParams initParams; + // static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + // initParams.testEventTriggerDelegate = &testEventTriggerDelegate; + ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); + + gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + +#if CONFIG_CHIP_OTA_REQUESTOR + InitBasicOTARequestor(); +#endif + + ConfigurationMgr().LogDeviceConfig(); + PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); + + // Add CHIP event handler and start CHIP thread. + // Note that all the initialization code should happen prior to this point to avoid data races + // between the main and the CHIP threads. + PlatformMgr().AddEventHandler(ChipEventHandler, 0); + + ContactSensorMgr().SetCallback(OnStateChanged); + + err = ConnectivityMgr().SetBLEDeviceName("TelinkSensor"); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("SetBLEDeviceName fail"); + return err; + } + + return err; +} + +void AppTask::OnStateChanged(ContactSensorManager::State aState) +{ + // If the contact state was changed, update LED state and cluster state (only if button was pressed). + // - turn on the contact LED if contact sensor is in closed state. + // - turn off the lock LED if contact sensor is in opened state. + if (ContactSensorManager::State::kContactClosed == aState) + { + LOG_INF("Contact state changed to CLOSED"); + sContactSensorLED.Set(true); + } + else if (ContactSensorManager::State::kContactOpened == aState) + { + LOG_INF("Contact state changed to OPEN"); + sContactSensorLED.Set(false); + } + + if (sAppTask.IsSyncClusterToButtonAction()) + { + sAppTask.UpdateClusterState(); + } +} + +CHIP_ERROR AppTask::StartApp(void) +{ + CHIP_ERROR err = Init(); + + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppTask Init fail"); + return err; + } + + AppEvent event = {}; + + while (true) + { + int ret = k_msgq_get(&sAppEventQueue, &event, K_MSEC(10)); + + while (!ret) + { + DispatchEvent(&event); + ret = k_msgq_get(&sAppEventQueue, &event, K_NO_WAIT); + } + } +} + +void AppTask::PostContactActionRequest(ContactSensorManager::Action aAction) +{ + AppEvent event; + event.Type = AppEvent::kEventType_Contact; + event.ContactEvent.Action = static_cast(aAction); + event.Handler = ContactActionEventHandler; + + sAppTask.PostEvent(&event); +} + +void AppTask::ToggleContactStateButtonEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = ContactActionEventHandler; + + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetButtonEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = FactoryResetHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetHandler(AppEvent * aEvent) +{ + if (!sIsFactoryResetTimerActive) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetTriggerTimeout), K_NO_WAIT); + sIsFactoryResetTimerActive = true; + } + else + { + k_timer_stop(&sFactoryResetTimer); + sIsFactoryResetTimerActive = false; + } +} + +void AppTask::UpdateClusterStateInternal(intptr_t arg) +{ + uint8_t newValue = ContactSensorMgr().IsContactClosed(); + + ChipLogProgress(NotSpecified, "emberAfWriteAttribute : %d", newValue); + + // write the new boolean state value + EmberAfStatus status = emberAfWriteAttribute(1, ZCL_BOOLEAN_STATE_CLUSTER_ID, ZCL_STATE_VALUE_ATTRIBUTE_ID, + (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: updating boolean status value %x", status); + } +} + +void AppTask::ContactActionEventHandler(AppEvent * aEvent) +{ + ContactSensorManager::Action action = ContactSensorManager::Action::kInvalid; + CHIP_ERROR err = CHIP_NO_ERROR; + + ChipLogProgress(NotSpecified, "ContactActionEventHandler"); + + if (aEvent->Type == AppEvent::kEventType_Contact) + { + action = static_cast(aEvent->ContactEvent.Action); + } + else if (aEvent->Type == AppEvent::kEventType_Button) + { + if (ContactSensorMgr().IsContactClosed()) + { + action = ContactSensorManager::Action::kSignalLost; + } + else + { + action = ContactSensorManager::Action::kSignalDetected; + } + + sAppTask.SetSyncClusterToButtonAction(true); + } + else + { + err = APP_ERROR_UNHANDLED_EVENT; + action = ContactSensorManager::Action::kInvalid; + } + + if (err == CHIP_NO_ERROR) + { + ContactSensorMgr().InitiateAction(action); + } +} + +void AppTask::StartBleAdvButtonEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = StartBleAdvHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::StartBleAdvHandler(AppEvent * aEvent) +{ + LOG_INF("StartBleAdvHandler"); + + // Don't allow on starting Matter service BLE advertising after Thread provisioning. + if (ConnectivityMgr().IsThreadProvisioned()) + { + LOG_INF("Device already commissioned"); + return; + } + + if (ConnectivityMgr().IsBLEAdvertisingEnabled()) + { + LOG_INF("BLE adv already enabled"); + return; + } + + if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR) + { + LOG_ERR("OpenBasicCommissioningWindow fail"); + } +} + +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + +void AppTask::UpdateStatusLED(void) +{ + if (sIsThreadProvisioned && sIsThreadEnabled) + { + if (sIsThreadAttached) + { + sStatusLED.Blink(950, 50); + } + else + { + sStatusLED.Blink(100, 100); + } + } + else + { + sStatusLED.Blink(50, 950); + } +} + +void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */) +{ + switch (event->Type) + { + case DeviceEventType::kCHIPoBLEAdvertisingChange: + sHaveBLEConnections = ConnectivityMgr().NumBLEConnections() != 0; + UpdateStatusLED(); + break; + case DeviceEventType::kThreadStateChange: + sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); + sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); + sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); + UpdateStatusLED(); + break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; + default: + break; + } +} + +void AppTask::PostEvent(AppEvent * aEvent) +{ + if (k_msgq_put(&sAppEventQueue, aEvent, K_NO_WAIT) != 0) + { + LOG_INF("PostEvent fail"); + } +} + +void AppTask::DispatchEvent(AppEvent * aEvent) +{ + if (aEvent->Handler) + { + aEvent->Handler(aEvent); + } + else + { + LOG_INF("Dropping event without handler"); + } +} + +void AppTask::UpdateClusterState(void) +{ + PlatformMgr().ScheduleWork(UpdateClusterStateInternal, 0); +} + +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sIsFactoryResetTimerActive = false; + LOG_INF("FactoryResetHandler"); + chip::Server::GetInstance().ScheduleFactoryReset(); +} + +void AppTask::InitButtons(void) +{ + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, true, FactoryResetButtonEventHandler); + sToggleContactStateButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, false, ToggleContactStateButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, false, StartBleAdvButtonEventHandler); + + ButtonManagerInst().AddButton(sFactoryResetButton); + ButtonManagerInst().AddButton(sToggleContactStateButton); + ButtonManagerInst().AddButton(sBleAdvStartButton); +} + +void AppTask::UpdateDeviceState(void) +{ + PlatformMgr().ScheduleWork(UpdateDeviceStateInternal, 0); +} + +void AppTask::UpdateDeviceStateInternal(intptr_t arg) +{ + bool stateValueAttrValue = 0; + + /* get boolean state attribute value */ + (void) emberAfReadAttribute(1, ZCL_BOOLEAN_STATE_CLUSTER_ID, ZCL_STATE_VALUE_ATTRIBUTE_ID, (uint8_t *) &stateValueAttrValue, 1); + + ChipLogProgress(NotSpecified, "emberAfReadAttribute : %d", stateValueAttrValue); + sContactSensorLED.Set(stateValueAttrValue); +} diff --git a/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp b/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp new file mode 100644 index 00000000000000..b555e4e0a2c958 --- /dev/null +++ b/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2022 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 "ContactSensorManager.h" + +#include "AppConfig.h" +#include "AppTask.h" + +#include + +#include +#include +#include + +LOG_MODULE_DECLARE(app); + +ContactSensorManager ContactSensorManager::sContactSensor; + +int ContactSensorManager::Init() +{ + int err = 0; + + mState = State::kContactOpened; + mCallbackStateChanged = nullptr; + + return err; +} + +void ContactSensorManager::SetCallback(CallbackStateChanged aCallbackStateChanged) +{ + mCallbackStateChanged = aCallbackStateChanged; +} + +bool ContactSensorManager::IsContactClosed() +{ + return mState == State::kContactClosed; +} + +void ContactSensorManager::InitiateAction(Action aAction) +{ + AppEvent event; + event.Type = AppEvent::kEventType_Contact; + event.ContactEvent.Action = static_cast(aAction); + event.Handler = HandleAction; + GetAppTask().PostEvent(&event); +} + +void ContactSensorManager::HandleAction(AppEvent * aEvent) +{ + Action action = static_cast(aEvent->ContactEvent.Action); + // Change current state based on action: + // - if state is closed and action is signal lost, change state to opened + // - if state is opened and action is signal detected, change state to closed + // - else, the state/action combination does not change the state. + if (sContactSensor.mState == State::kContactClosed && action == Action::kSignalLost) + { + sContactSensor.mState = State::kContactOpened; + } + else if (sContactSensor.mState == State::kContactOpened && action == Action::kSignalDetected) + { + sContactSensor.mState = State::kContactClosed; + } + + if (sContactSensor.mCallbackStateChanged != nullptr) + { + sContactSensor.mCallbackStateChanged(sContactSensor.mState); + } + else + { + LOG_ERR("Callback for state change was not set. Please set an appropriate callback."); + } +} diff --git a/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp b/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp new file mode 100644 index 00000000000000..89d6aed77f16d2 --- /dev/null +++ b/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp @@ -0,0 +1,56 @@ +/* + * + * Copyright (c) 2022 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 +#include + +using namespace chip; +using namespace chip::app::Clusters; + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + + if (clusterId == BooleanState::Id && attributeId == BooleanState::Attributes::StateValue::Id) + { + ChipLogProgress(Zcl, "Cluster BooleanState: attribute StateValue set to %u", *value); + AppTask & task = GetAppTask(); + if (task.IsSyncClusterToButtonAction()) + { + task.SetSyncClusterToButtonAction(false); + } + else + { + task.PostContactActionRequest(*value ? ContactSensorManager::Action::kSignalDetected + : ContactSensorManager::Action::kSignalLost); + } + } +} + +void emberAfBooleanStateClusterInitCallback(EndpointId endpoint) +{ + ChipLogProgress(Zcl, "emberAfBooleanStateClusterInitCallback"); + GetAppTask().UpdateClusterState(); +} diff --git a/examples/contact-sensor-app/telink/src/main.cpp b/examples/contact-sensor-app/telink/src/main.cpp new file mode 100755 index 00000000000000..e71632de12fddb --- /dev/null +++ b/examples/contact-sensor-app/telink/src/main.cpp @@ -0,0 +1,82 @@ +/* + * + * Copyright (c) 2022 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); + +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/contact-sensor-app/telink/third_party/connectedhomeip b/examples/contact-sensor-app/telink/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/contact-sensor-app/telink/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file From b74fc0d681a96f10b1dd8c20402938715feab93f Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Tue, 20 Dec 2022 16:08:39 +0200 Subject: [PATCH 11/18] [Telink] Add new target for CI --- .github/workflows/examples-telink.yaml | 9 +++++++++ .vscode/tasks.json | 1 + scripts/build/build/targets.py | 1 + scripts/build/builders/telink.py | 5 +++++ scripts/build/testdata/all_targets_linux_x64.txt | 2 +- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 2099621e165ed3..6f6247aa2b2240 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -111,6 +111,15 @@ jobs: out/telink-tlsr9518adk80d-thermostat/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - name: Build example Telink Contact Sensor App + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-contact-sensor' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tlsr9518adk80d contact-sensor-app \ + out/telink-tlsr9518adk80d-contact-sensor/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + - name: Uploading Size Reports uses: actions/upload-artifact@v3 if: ${{ !env.ACT }} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index fd815494affee7..a4bf754c4a21f7 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -642,6 +642,7 @@ "telink-tlsr9518adk80d-light-switch", "telink-tlsr9518adk80d-ota-requestor", "telink-tlsr9518adk80d-thermostat", + "telink-tlsr9518adk80d-contact-sensor", "tizen-arm-light" ] }, diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 2e1dff050641d6..47852e004b8162 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -531,6 +531,7 @@ def BuildTelinkTarget(): TargetPart('light-switch', app=TelinkApp.SWITCH), TargetPart('ota-requestor', app=TelinkApp.OTA_REQUESTOR), TargetPart('thermostat', app=TelinkApp.THERMOSTAT), + TargetPart('contact-sensor', app=TelinkApp.CONTACT_SENSOR), ]) return target diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 32a9bf85c3187e..6e0103ce9f1836 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -27,6 +27,7 @@ class TelinkApp(Enum): SWITCH = auto() OTA_REQUESTOR = auto() THERMOSTAT = auto() + CONTACT_SENSOR = auto() def ExampleName(self): if self == TelinkApp.ALL_CLUSTERS: @@ -41,6 +42,8 @@ def ExampleName(self): return 'ota-requestor-app' elif self == TelinkApp.THERMOSTAT: return 'thermostat' + elif self == TelinkApp.CONTACT_SENSOR: + return 'contact-sensor' else: raise Exception('Unknown app type: %r' % self) @@ -57,6 +60,8 @@ def AppNamePrefix(self): return 'chip-telink-ota-requestor-example' elif self == TelinkApp.THERMOSTAT: return 'chip-telink-thermostat-example' + elif self == TelinkApp.CONTACT_SENSOR: + return 'chip-telink-contact-sensor-example' else: raise Exception('Unknown app type: %r' % self) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 2fbf8d8813520f..d0476ad66f26ba 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -18,5 +18,5 @@ nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,loc nrf-native-posix-64-tests qpg-qpg6105-{lock,light,shell,persistent-storage} tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light}[-no-ble][-no-wifi][-asan][-ubsan] -telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,light,light-switch,ota-requestor,thermostat} +telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,light,light-switch,ota-requestor,thermostat,contact-sensor} openiotsdk-{shell,lock} From 274ba8a1edda13049a64b9ead8ec9e10f658bb1c Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Wed, 21 Dec 2022 16:52:46 +0200 Subject: [PATCH 12/18] [Telink] Fix device re-pairing --- .../all-clusters-app/telink/src/AppTask.cpp | 18 ++++++++++++++++ .../telink/src/AppTask.cpp | 18 ++++++++++++++++ .../contact-sensor-app/telink/src/AppTask.cpp | 20 +++++++++++++++++- .../light-switch-app/telink/src/AppTask.cpp | 21 ++++++++++++++++++- examples/lighting-app/telink/src/AppTask.cpp | 21 ++++++++++++++++++- .../ota-requestor-app/telink/src/AppTask.cpp | 18 ++++++++++++++++ examples/thermostat/telink/src/AppTask.cpp | 21 ++++++++++++++++++- 7 files changed, 133 insertions(+), 4 deletions(-) diff --git a/examples/all-clusters-app/telink/src/AppTask.cpp b/examples/all-clusters-app/telink/src/AppTask.cpp index 9115d89174cbdf..9f831beecfaf9b 100644 --- a/examples/all-clusters-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-app/telink/src/AppTask.cpp @@ -109,6 +109,17 @@ using namespace ::chip::DeviceLayer::Internal; AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; CHIP_ERROR AppTask::Init() @@ -174,6 +185,13 @@ CHIP_ERROR AppTask::Init() return ret; } + ret = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (ret != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return ret; + } + return CHIP_NO_ERROR; } diff --git a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp index 9ba7ed94593dc5..4d0f29cb87efea 100644 --- a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp @@ -72,6 +72,17 @@ using namespace ::chip::DeviceLayer::Internal; AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; CHIP_ERROR AppTask::Init() @@ -134,6 +145,13 @@ CHIP_ERROR AppTask::Init() return ret; } + ret = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (ret != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return ret; + } + return CHIP_NO_ERROR; } diff --git a/examples/contact-sensor-app/telink/src/AppTask.cpp b/examples/contact-sensor-app/telink/src/AppTask.cpp index e6933571a7a041..a2dc322fcc50de 100644 --- a/examples/contact-sensor-app/telink/src/AppTask.cpp +++ b/examples/contact-sensor-app/telink/src/AppTask.cpp @@ -115,6 +115,17 @@ Identify sIdentify = { AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + CHIP_ERROR AppTask::Init() { CHIP_ERROR err; @@ -187,7 +198,14 @@ CHIP_ERROR AppTask::Init() return err; } - return err; + err = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return err; + } + + return CHIP_NO_ERROR; } void AppTask::OnStateChanged(ContactSensorManager::State aState) diff --git a/examples/light-switch-app/telink/src/AppTask.cpp b/examples/light-switch-app/telink/src/AppTask.cpp index 294e81fdfb609f..5b7817831ed68a 100644 --- a/examples/light-switch-app/telink/src/AppTask.cpp +++ b/examples/light-switch-app/telink/src/AppTask.cpp @@ -116,6 +116,17 @@ Identify sIdentify = { AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + CHIP_ERROR AppTask::Init() { CHIP_ERROR err; @@ -186,9 +197,17 @@ CHIP_ERROR AppTask::Init() if (err != CHIP_NO_ERROR) { LOG_ERR("SetBLEDeviceName fail"); + return err; + } + + err = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return err; } - return err; + return CHIP_NO_ERROR; } CHIP_ERROR AppTask::StartApp() diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index f24d8a315c6ef3..f7866db456c370 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -118,6 +118,17 @@ Identify sIdentify = { AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + CHIP_ERROR AppTask::Init() { LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); @@ -193,9 +204,17 @@ CHIP_ERROR AppTask::Init() if (err != CHIP_NO_ERROR) { LOG_ERR("SetBLEDeviceName fail"); + return err; + } + + err = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return err; } - return err; + return CHIP_NO_ERROR; } CHIP_ERROR AppTask::StartApp() diff --git a/examples/ota-requestor-app/telink/src/AppTask.cpp b/examples/ota-requestor-app/telink/src/AppTask.cpp index fddb95b4ae2989..15f3c6f17ff274 100644 --- a/examples/ota-requestor-app/telink/src/AppTask.cpp +++ b/examples/ota-requestor-app/telink/src/AppTask.cpp @@ -117,6 +117,17 @@ using namespace ::chip::DeviceLayer::Internal; AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; CHIP_ERROR AppTask::Init() @@ -173,6 +184,13 @@ CHIP_ERROR AppTask::Init() return ret; } + ret = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (ret != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return ret; + } + return CHIP_NO_ERROR; } diff --git a/examples/thermostat/telink/src/AppTask.cpp b/examples/thermostat/telink/src/AppTask.cpp index 2fa744dd7a7f94..96caac3e06e2bd 100644 --- a/examples/thermostat/telink/src/AppTask.cpp +++ b/examples/thermostat/telink/src/AppTask.cpp @@ -114,6 +114,17 @@ Identify sIdentify = { AppTask AppTask::sAppTask; +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + CHIP_ERROR AppTask::Init() { CHIP_ERROR err; @@ -189,9 +200,17 @@ CHIP_ERROR AppTask::Init() if (err != CHIP_NO_ERROR) { LOG_ERR("SetBLEDeviceName fail"); + return err; + } + + err = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return err; } - return err; + return CHIP_NO_ERROR; } CHIP_ERROR AppTask::StartApp() From 829efd32329437778c1980939b5326046e5e0e04 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 23 Dec 2022 10:03:03 +0200 Subject: [PATCH 13/18] [Telink] Enable NVS lookup cache --- config/telink/app/zephyr.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/telink/app/zephyr.conf b/config/telink/app/zephyr.conf index 017e0736a5fe13..9d02f8f06d4b31 100644 --- a/config/telink/app/zephyr.conf +++ b/config/telink/app/zephyr.conf @@ -118,6 +118,9 @@ CONFIG_DYNAMIC_INTERRUPTS=y # nvs_sector_size = flash_page_size * mult = 256 * 8 = 2048 CONFIG_SETTINGS_NVS_SECTOR_SIZE_MULT=8 +# Enable NVS lookup cache +CONFIG_NVS_LOOKUP_CACHE=y + # Reboot system when fault happened CONFIG_TELINK_B91_REBOOT_ON_FAULT=y From 6df90e712929e7e6dc5eb68b68a2ac75d9a47a61 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 23 Dec 2022 11:44:05 +0200 Subject: [PATCH 14/18] [Telink] Update every image to 0.6.27 --- .devcontainer/devcontainer.json | 2 +- .github/workflows/bloat_check.yaml | 2 +- .github/workflows/build.yaml | 6 +++--- .github/workflows/chef.yaml | 6 +++--- .github/workflows/cirque.yaml | 4 ++-- .github/workflows/doxygen.yaml | 2 +- .github/workflows/examples-ameba.yaml | 2 +- .github/workflows/examples-bouffalolab.yaml | 2 +- .github/workflows/examples-cc13x2x7_26x2x7.yaml | 2 +- .github/workflows/examples-efr32.yaml | 2 +- .github/workflows/examples-esp32.yaml | 4 ++-- .github/workflows/examples-infineon.yaml | 2 +- .github/workflows/examples-k32w.yaml | 2 +- .github/workflows/examples-linux-arm.yaml | 2 +- .github/workflows/examples-linux-imx.yaml | 2 +- .github/workflows/examples-linux-standalone.yaml | 2 +- .github/workflows/examples-mbed.yaml | 2 +- .github/workflows/examples-mw320.yaml | 2 +- .github/workflows/examples-nrfconnect.yaml | 2 +- .github/workflows/examples-openiotsdk.yaml | 2 +- .github/workflows/examples-qpg.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- .github/workflows/examples-tizen.yaml | 2 +- .github/workflows/full-android.yaml | 2 +- .github/workflows/fuzzing-build.yaml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/qemu.yaml | 2 +- .github/workflows/release_artifacts.yaml | 4 ++-- .github/workflows/smoketest-android.yaml | 2 +- .github/workflows/tests.yaml | 6 +++--- .github/workflows/unit_integration_test.yaml | 2 +- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- integrations/cloudbuild/build-all.yaml | 6 +++--- integrations/cloudbuild/build-coverage.yaml | 4 ++-- integrations/cloudbuild/chef.yaml | 6 +++--- integrations/cloudbuild/smoke-test.yaml | 14 +++++++------- 37 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 70c206f1058ce3..36747bebdc060f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.6.18" + "BUILD_VERSION": "0.6.27" } }, "remoteUser": "vscode", diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index b5325da5ec1ff3..ba734f22758ca9 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 443210b15c3c05..00ab192750e13f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -138,7 +138,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -308,7 +308,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 3a7a91d60663e9..088fad5136a24b 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,7 +29,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --user root steps: @@ -57,7 +57,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 options: --user root steps: @@ -85,7 +85,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.18 + image: connectedhomeip/chip-build-nrf-platform:0.6.27 options: --user root steps: diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index c55e84b7a9273d..58fc8091a224df 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.6.18 + DOCKER_RUN_VERSION: 0.6.27 GITHUB_CACHE_PATH: /tmp/cirque-cache/ runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.6.18 + # image: connectedhomeip/chip-build-cirque:0.6.27 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index d5f84576ff0fc7..669efca5f6d4c7 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.6.18 + image: connectedhomeip/chip-build-doxygen:0.6.27 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index 6986e6b6bda00b..3b568a270aa0ae 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.6.18 + image: connectedhomeip/chip-build-ameba:0.6.27 options: --user root steps: diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index a62e0dad3c74dd..04331435bc6e14 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-bouffalolab:0.6.18 + image: connectedhomeip/chip-build-bouffalolab:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index d8598c6561eba9..4952d066c60ee4 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.18 + image: connectedhomeip/chip-build-ti:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 30374f090bfe96..90e0e397c82517 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.6.18 + image: connectedhomeip/chip-build-efr32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 61d9d032042c9d..13a025fe229767 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -140,7 +140,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 51d89d81c0b316..bb629fa999fcf2 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.6.18 + image: connectedhomeip/chip-build-infineon:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 76f8d8237f2d56..53b1aa46701771 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.6.18 + image: connectedhomeip/chip-build-k32w:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 1a5b9c07395482..159960bef927a4 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.6.18 + image: connectedhomeip/chip-build-crosscompile:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index b8bfdc0c086c14..42f426bfa959b0 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.6.18 + image: connectedhomeip/chip-build-imx:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 2c09f5871e7f7f..11c913cfee488c 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 3a9d522b1aa676..91f9f6f82a2097 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.6.18 + image: connectedhomeip/chip-build-mbed-os:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index aedded0398df28..7fc6238cc81034 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 7d0c274dc2d029..1fa32d751037e8 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.18 + image: connectedhomeip/chip-build-nrf-platform:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index f3b49f828704ff..7e043d58d98ee5 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-openiotsdk:0.6.18 + image: connectedhomeip/chip-build-openiotsdk:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" options: --privileged diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index c32dd590ddc930..35bc2987a4d10a 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 6f6247aa2b2240..d7bda32b3a83b1 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.6.18 + image: connectedhomeip/chip-build-telink:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 259733a008237c..8f892c8c712f13 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -33,7 +33,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.6.18 + image: connectedhomeip/chip-build-tizen:0.6.27 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 1173adaf7c82d5..8f87a48a9e6043 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.18 + image: connectedhomeip/chip-build-android:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index bd96ff35792e31..bfb1eac538a138 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89e8c44d26a37f..375c215e962adc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,7 +28,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 1a0c88e28d47b3..965e69ae1f3576 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.6.18 + image: connectedhomeip/chip-build-esp32-qemu:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 6b57156ba01f2d..5a6c13f85f8f14 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.6.18 + image: connectedhomeip/chip-build-efr32:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index 04c4c8ecb77d2b..dc8ee425c28fca 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.18 + image: connectedhomeip/chip-build-android:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7d35cde0db27ff..44232dfdc97c8d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -352,7 +352,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -426,7 +426,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index a0ea6842e24dc0..a6cb192b058a99 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 7db5b259340810..1906613500816d 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.24 + image: connectedhomeip/chip-build:0.6.27 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index d59598bff10781..b7459e76d53996 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.24 + image: connectedhomeip/chip-build:0.6.27 defaults: run: shell: sh diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 5a80129f54496b..408b68510125cf 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -76,7 +76,7 @@ steps: --target k32w-shell build --create-archives /workspace/artifacts/ - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/build-coverage.yaml b/integrations/cloudbuild/build-coverage.yaml index 3973c85147a623..8beb8b6d18f19c 100644 --- a/integrations/cloudbuild/build-coverage.yaml +++ b/integrations/cloudbuild/build-coverage.yaml @@ -7,7 +7,7 @@ steps: - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build:0.6.18" + - name: "connectedhomeip/chip-build:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build:0.6.17" + - name: "connectedhomeip/chip-build:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index 0cfebde9cf97ea..494869a38e318e 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 2700s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -26,7 +26,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 47145edfc2aabc..ed396cfb3891cf 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" entrypoint: "bash" args: - "-c" @@ -7,7 +7,7 @@ steps: git config --global --add safe.directory "*" git submodule update --init --recursive id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -41,7 +41,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -62,7 +62,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -84,7 +84,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -142,7 +142,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv From 03ba586579434a9bf944d8be380a9ee4a994bee5 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 23 Dec 2022 12:01:02 +0200 Subject: [PATCH 15/18] [Telink] Ordered by alphabet targets --- .github/workflows/examples-telink.yaml | 18 +++++++++--------- .vscode/tasks.json | 2 +- scripts/build/build/targets.py | 2 +- scripts/build/builders/telink.py | 10 +++++----- .../build/testdata/all_targets_linux_x64.txt | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index d7bda32b3a83b1..28d5c7faf03f4f 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -75,6 +75,15 @@ jobs: out/telink-tlsr9518adk80d-all-clusters-minimal/zephyr/zephyr.elf \ /tmp/bloat_reports/ + - name: Build example Telink Contact Sensor App + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-contact-sensor' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tlsr9518adk80d contact-sensor-app \ + out/telink-tlsr9518adk80d-contact-sensor/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + - name: Build example Telink Lighting App run: | ./scripts/run_in_build_env.sh \ @@ -111,15 +120,6 @@ jobs: out/telink-tlsr9518adk80d-thermostat/zephyr/zephyr.elf \ /tmp/bloat_reports/ - - name: Build example Telink Contact Sensor App - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-contact-sensor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d contact-sensor-app \ - out/telink-tlsr9518adk80d-contact-sensor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - name: Uploading Size Reports uses: actions/upload-artifact@v3 if: ${{ !env.ACT }} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a4bf754c4a21f7..178210ae842f62 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -638,11 +638,11 @@ "qpg-qpg6100-lock", "telink-tlsr9518adk80d-all-clusters", "telink-tlsr9518adk80d-all-clusters-minimal", + "telink-tlsr9518adk80d-contact-sensor", "telink-tlsr9518adk80d-light", "telink-tlsr9518adk80d-light-switch", "telink-tlsr9518adk80d-ota-requestor", "telink-tlsr9518adk80d-thermostat", - "telink-tlsr9518adk80d-contact-sensor", "tizen-arm-light" ] }, diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 47852e004b8162..bd7dc36231c699 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -527,11 +527,11 @@ def BuildTelinkTarget(): target.AppendFixedTargets([ TargetPart('all-clusters', app=TelinkApp.ALL_CLUSTERS), TargetPart('all-clusters-minimal', app=TelinkApp.ALL_CLUSTERS_MINIMAL), + TargetPart('contact-sensor', app=TelinkApp.CONTACT_SENSOR), TargetPart('light', app=TelinkApp.LIGHT), TargetPart('light-switch', app=TelinkApp.SWITCH), TargetPart('ota-requestor', app=TelinkApp.OTA_REQUESTOR), TargetPart('thermostat', app=TelinkApp.THERMOSTAT), - TargetPart('contact-sensor', app=TelinkApp.CONTACT_SENSOR), ]) return target diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 6e0103ce9f1836..6c9eca681b7950 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -23,17 +23,19 @@ class TelinkApp(Enum): ALL_CLUSTERS = auto() ALL_CLUSTERS_MINIMAL = auto() + CONTACT_SENSOR = auto() LIGHT = auto() SWITCH = auto() OTA_REQUESTOR = auto() THERMOSTAT = auto() - CONTACT_SENSOR = auto() def ExampleName(self): if self == TelinkApp.ALL_CLUSTERS: return 'all-clusters-app' elif self == TelinkApp.ALL_CLUSTERS_MINIMAL: return 'all-clusters-minimal-app' + elif self == TelinkApp.CONTACT_SENSOR: + return 'contact-sensor' elif self == TelinkApp.LIGHT: return 'lighting-app' elif self == TelinkApp.SWITCH: @@ -42,8 +44,6 @@ def ExampleName(self): return 'ota-requestor-app' elif self == TelinkApp.THERMOSTAT: return 'thermostat' - elif self == TelinkApp.CONTACT_SENSOR: - return 'contact-sensor' else: raise Exception('Unknown app type: %r' % self) @@ -52,6 +52,8 @@ def AppNamePrefix(self): return 'chip-telink-all-clusters-example' elif self == TelinkApp.ALL_CLUSTERS_MINIMAL: return 'chip-telink-all-clusters-minimal-example' + elif self == TelinkApp.CONTACT_SENSOR: + return 'chip-telink-contact-sensor-example' elif self == TelinkApp.LIGHT: return 'chip-telink-lighting-example' elif self == TelinkApp.SWITCH: @@ -60,8 +62,6 @@ def AppNamePrefix(self): return 'chip-telink-ota-requestor-example' elif self == TelinkApp.THERMOSTAT: return 'chip-telink-thermostat-example' - elif self == TelinkApp.CONTACT_SENSOR: - return 'chip-telink-contact-sensor-example' else: raise Exception('Unknown app type: %r' % self) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index d0476ad66f26ba..015f917dac3200 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -18,5 +18,5 @@ nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,loc nrf-native-posix-64-tests qpg-qpg6105-{lock,light,shell,persistent-storage} tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light}[-no-ble][-no-wifi][-asan][-ubsan] -telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,light,light-switch,ota-requestor,thermostat,contact-sensor} +telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,contact-sensor,light,light-switch,ota-requestor,thermostat} openiotsdk-{shell,lock} From 52535b050a06bf0736a8a66fdc0e132f49378f03 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Wed, 4 Jan 2023 22:16:46 +0200 Subject: [PATCH 16/18] [Telink] Fix example name --- scripts/build/builders/telink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 6c9eca681b7950..5be30cb72ceb80 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -35,7 +35,7 @@ def ExampleName(self): elif self == TelinkApp.ALL_CLUSTERS_MINIMAL: return 'all-clusters-minimal-app' elif self == TelinkApp.CONTACT_SENSOR: - return 'contact-sensor' + return 'contact-sensor-app' elif self == TelinkApp.LIGHT: return 'lighting-app' elif self == TelinkApp.SWITCH: From b0d8fff5d2cc04dbf8156ea724932cccb84684c5 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Thu, 5 Jan 2023 19:09:03 +0200 Subject: [PATCH 17/18] Revert "[Telink] Update every image to 0.6.27" This reverts commit 6df90e712929e7e6dc5eb68b68a2ac75d9a47a61. --- .devcontainer/devcontainer.json | 2 +- .github/workflows/bloat_check.yaml | 2 +- .github/workflows/build.yaml | 6 +++--- .github/workflows/chef.yaml | 6 +++--- .github/workflows/cirque.yaml | 4 ++-- .github/workflows/doxygen.yaml | 2 +- .github/workflows/examples-ameba.yaml | 2 +- .github/workflows/examples-bouffalolab.yaml | 2 +- .github/workflows/examples-cc13x2x7_26x2x7.yaml | 2 +- .github/workflows/examples-efr32.yaml | 2 +- .github/workflows/examples-esp32.yaml | 4 ++-- .github/workflows/examples-infineon.yaml | 2 +- .github/workflows/examples-k32w.yaml | 2 +- .github/workflows/examples-linux-arm.yaml | 2 +- .github/workflows/examples-linux-imx.yaml | 2 +- .github/workflows/examples-linux-standalone.yaml | 2 +- .github/workflows/examples-mbed.yaml | 2 +- .github/workflows/examples-mw320.yaml | 2 +- .github/workflows/examples-nrfconnect.yaml | 2 +- .github/workflows/examples-openiotsdk.yaml | 2 +- .github/workflows/examples-qpg.yaml | 2 +- .github/workflows/examples-telink.yaml | 2 +- .github/workflows/examples-tizen.yaml | 2 +- .github/workflows/full-android.yaml | 2 +- .github/workflows/fuzzing-build.yaml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/qemu.yaml | 2 +- .github/workflows/release_artifacts.yaml | 4 ++-- .github/workflows/smoketest-android.yaml | 2 +- .github/workflows/tests.yaml | 6 +++--- .github/workflows/unit_integration_test.yaml | 2 +- .github/workflows/zap_regeneration.yaml | 2 +- .github/workflows/zap_templates.yaml | 2 +- integrations/cloudbuild/build-all.yaml | 6 +++--- integrations/cloudbuild/build-coverage.yaml | 4 ++-- integrations/cloudbuild/chef.yaml | 6 +++--- integrations/cloudbuild/smoke-test.yaml | 14 +++++++------- 37 files changed, 57 insertions(+), 57 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 36747bebdc060f..70c206f1058ce3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.6.27" + "BUILD_VERSION": "0.6.18" } }, "remoteUser": "vscode", diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index ba734f22758ca9..b5325da5ec1ff3 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 00ab192750e13f..443210b15c3c05 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -138,7 +138,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -308,7 +308,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 088fad5136a24b..3a7a91d60663e9 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,7 +29,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 options: --user root steps: @@ -57,7 +57,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.27 + image: connectedhomeip/chip-build-esp32:0.6.18 options: --user root steps: @@ -85,7 +85,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.27 + image: connectedhomeip/chip-build-nrf-platform:0.6.18 options: --user root steps: diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index 58fc8091a224df..c55e84b7a9273d 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.6.27 + DOCKER_RUN_VERSION: 0.6.18 GITHUB_CACHE_PATH: /tmp/cirque-cache/ runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.6.27 + # image: connectedhomeip/chip-build-cirque:0.6.18 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index 669efca5f6d4c7..d5f84576ff0fc7 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.6.27 + image: connectedhomeip/chip-build-doxygen:0.6.18 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index 3b568a270aa0ae..6986e6b6bda00b 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.6.27 + image: connectedhomeip/chip-build-ameba:0.6.18 options: --user root steps: diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index 04331435bc6e14..a62e0dad3c74dd 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-bouffalolab:0.6.27 + image: connectedhomeip/chip-build-bouffalolab:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index 4952d066c60ee4..d8598c6561eba9 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.27 + image: connectedhomeip/chip-build-ti:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 90e0e397c82517..30374f090bfe96 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.6.27 + image: connectedhomeip/chip-build-efr32:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 13a025fe229767..61d9d032042c9d 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.27 + image: connectedhomeip/chip-build-esp32:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -140,7 +140,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.27 + image: connectedhomeip/chip-build-esp32:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index bb629fa999fcf2..51d89d81c0b316 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.6.27 + image: connectedhomeip/chip-build-infineon:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 53b1aa46701771..76f8d8237f2d56 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.6.27 + image: connectedhomeip/chip-build-k32w:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 159960bef927a4..1a5b9c07395482 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.6.27 + image: connectedhomeip/chip-build-crosscompile:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index 42f426bfa959b0..b8bfdc0c086c14 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.6.27 + image: connectedhomeip/chip-build-imx:0.6.18 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 11c913cfee488c..2c09f5871e7f7f 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 91f9f6f82a2097..3a9d522b1aa676 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.6.27 + image: connectedhomeip/chip-build-mbed-os:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index 7fc6238cc81034..aedded0398df28 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 1fa32d751037e8..7d0c274dc2d029 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.27 + image: connectedhomeip/chip-build-nrf-platform:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index 7e043d58d98ee5..f3b49f828704ff 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-openiotsdk:0.6.27 + image: connectedhomeip/chip-build-openiotsdk:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" options: --privileged diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index 35bc2987a4d10a..c32dd590ddc930 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 28d5c7faf03f4f..6bceec786a30a6 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.6.27 + image: connectedhomeip/chip-build-telink:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 8f892c8c712f13..259733a008237c 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -33,7 +33,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.6.27 + image: connectedhomeip/chip-build-tizen:0.6.18 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 8f87a48a9e6043..1173adaf7c82d5 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.27 + image: connectedhomeip/chip-build-android:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index bfb1eac538a138..bd96ff35792e31 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 375c215e962adc..89e8c44d26a37f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,7 +28,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 965e69ae1f3576..1a0c88e28d47b3 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.6.27 + image: connectedhomeip/chip-build-esp32-qemu:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 5a6c13f85f8f14..6b57156ba01f2d 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.6.27 + image: connectedhomeip/chip-build-esp32:0.6.18 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.6.27 + image: connectedhomeip/chip-build-efr32:0.6.18 steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index dc8ee425c28fca..04c4c8ecb77d2b 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.27 + image: connectedhomeip/chip-build-android:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 44232dfdc97c8d..7d35cde0db27ff 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -352,7 +352,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -426,7 +426,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index a6cb192b058a99..a0ea6842e24dc0 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.18 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 1906613500816d..7db5b259340810 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.24 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index b7459e76d53996..d59598bff10781 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.27 + image: connectedhomeip/chip-build:0.6.24 defaults: run: shell: sh diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 408b68510125cf..5a80129f54496b 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -76,7 +76,7 @@ steps: --target k32w-shell build --create-archives /workspace/artifacts/ - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/build-coverage.yaml b/integrations/cloudbuild/build-coverage.yaml index 8beb8b6d18f19c..3973c85147a623 100644 --- a/integrations/cloudbuild/build-coverage.yaml +++ b/integrations/cloudbuild/build-coverage.yaml @@ -7,7 +7,7 @@ steps: - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build:0.6.27" + - name: "connectedhomeip/chip-build:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build:0.6.27" + - name: "connectedhomeip/chip-build:0.6.17" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index 494869a38e318e..0cfebde9cf97ea 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 2700s - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -26,7 +26,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index ed396cfb3891cf..47145edfc2aabc 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" entrypoint: "bash" args: - "-c" @@ -7,7 +7,7 @@ steps: git config --global --add safe.directory "*" git submodule update --init --recursive id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -41,7 +41,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -62,7 +62,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -84,7 +84,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -142,7 +142,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.27" + - name: "connectedhomeip/chip-build-vscode:0.6.18" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv From 5376082aac6ebf3c2eb44857f2a6aeeb667ca846 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Thu, 5 Jan 2023 19:11:00 +0200 Subject: [PATCH 18/18] [Telink] Update Telink image to 0.6.27 --- .github/workflows/examples-telink.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 6bceec786a30a6..28d5c7faf03f4f 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.6.18 + image: connectedhomeip/chip-build-telink:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports"