diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 1b6fd20aa72260..f4721d7ec414b6 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -60,75 +60,6 @@ jobs: # - name: Update Zephyr to specific revision (for developers purpose) # run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 8b29ee6b118ebe6eeec3224dbe343474e11403d8" - - name: Build example Telink (B92 retention) Air Quality Sensor App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-air-quality-sensor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a_retention air-quality-sensor-app \ - out/telink-tlsr9528a_retention-air-quality-sensor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (W91) All Clusters App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - continue-on-error: true - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-all-clusters' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9118bdk40d all-clusters-app \ - out/telink-tlsr9118bdk40d-all-clusters/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92) All Clusters Minimal App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a-all-clusters-minimal' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a all-clusters-minimal-app \ - out/telink-tlsr9528a-all-clusters-minimal/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B95) Bridge App - # Run test for master and all PRs - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9258a-bridge' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9258a bridge-app \ - out/telink-tlsr9258a-bridge/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92 retention) Contact Sensor App - # Run test for master and all PRs - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-contact-sensor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a_retention contact-sensor-app \ - out/telink-tlsr9528a_retention-contact-sensor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - name: Build tools required for Factory Data # Run test for master and all PRs run: | @@ -140,33 +71,6 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (W91) Lighting App with OTA, Factory Data - # Run test for master and all PRs - continue-on-error: true - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-light-ota-factory-data' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9118bdk40d lighting-app-ota-factory-data \ - out/telink-tlsr9118bdk40d-light-ota-factory-data/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output (keep tools) - run: rm -rf ./out/telink* - - - name: Build example Telink (B91) Lighting App with OTA, RPC, Factory Data and 4Mb flash - # Run test for master and all PRs - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-light-ota-rpc-factory-data-4mb' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d lighting-app-ota-rpc-factory-data-4mb \ - out/telink-tlsr9518adk80d-light-ota-rpc-factory-data-4mb/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output (keep tools) - run: rm -rf ./out/telink* - - name: Build example Telink (tl321x) Lighting App with OTA (LZMA), Shell, Factory Data # Run test for master and all PRs run: | @@ -180,145 +84,18 @@ jobs: - name: clean out build output (keep tools) run: rm -rf ./out/telink* - - name: Build example Telink (B92) Light Switch App with OTA (LZMA), Shell, Factory Data + - name: Build example Telink (tlsr9528a) Lighting App with OTA (LZMA), Shell, Factory Data # Run test for master and all PRs run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-switch-ota-compress-lzma-shell-factory-data' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a light-switch-app-ota-compress-lzma-shell-factory-data \ - out/telink-tlsr9528a-light-switch-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92) Lock App with DFU - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a-lock-dfu' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a lock-app-dfu \ - out/telink-tlsr9528a-lock-dfu/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B95) OTA Requestor App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9258a-ota-requestor' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9258a ota-requestor-app \ - out/telink-tlsr9258a-ota-requestor/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91 USB) Pump App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-pump-usb' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d pump-app-usb \ - out/telink-tlsr9518adk80d-pump-usb/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91) Pump Controller App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-pump-controller' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d pump-controller-app \ - out/telink-tlsr9518adk80d-pump-controller/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91) Shell App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-shell' build" + "./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-ota-shell-factory-data' build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d shell \ - out/telink-tlsr9518adk80d-shell/zephyr/zephyr.elf \ + telink tlsr9528a light-app-ota-compress-lzma-shell-factory-data \ + out/telink-tlsr9528a-light-ota-compress-lzma-shell-factory-data/zephyr/zephyr.elf \ /tmp/bloat_reports/ - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B92 retention) Smoke CO Alarm App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9528a_retention-smoke-co-alarm' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9528a_retention smoke_co_alarm-app \ - out/telink-tlsr9528a_retention-smoke-co-alarm/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91 Mars) Temperature Measurement App with OTA - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-temperature-measurement-mars-ota' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d temperature-measurement-app-mars-ota \ - out/telink-tlsr9518adk80d-temperature-measurement-mars-ota/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (B91) Thermostat App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-thermostat' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9518adk80d thermostat \ - out/telink-tlsr9518adk80d-thermostat/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out - - - name: Build example Telink (W91) Window Covering App - # Run test for master and s07641069 PRs - if: github.event.pull_request.number == null || github.event.pull_request.head.repo.full_name == 's07641069/connectedhomeip' - continue-on-error: true - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target 'telink-tlsr9118bdk40d-window-covering' build" - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - telink tlsr9118bdk40d window-covering \ - out/telink-tlsr9118bdk40d-window-covering/zephyr/zephyr.elf \ - /tmp/bloat_reports/ - - - name: clean out build output - run: rm -rf ./out + - name: clean out build output (keep tools) + run: rm -rf ./out/telink* - name: Uploading Size Reports uses: ./.github/actions/upload-size-reports diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 9e419150712c3c..0f35734e043e68 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -60,6 +60,14 @@ CHIP_ERROR AppTask::Init(void) SetExampleButtonCallbacks(LightingActionEventHandler); InitCommonParts(); + if(sBoot_zb){ + /* Switch from the touch link, need to restore previous values */ + sfixture_on = user_para.onoff; + sBrightness = user_para.lightness; + sAppTask.UpdateClusterState(); + printk("Matter: Updated ZB On/Off state and brightness.\n"); + } + Protocols::InteractionModel::Status status; app::DataModel::Nullable brightness; diff --git a/examples/platform/telink/common/include/AppTaskCommon.h b/examples/platform/telink/common/include/AppTaskCommon.h index 26f6211ce8a172..828a527e792285 100644 --- a/examples/platform/telink/common/include/AppTaskCommon.h +++ b/examples/platform/telink/common/include/AppTaskCommon.h @@ -42,14 +42,26 @@ #include #include -#define USER_INIT_VAL 0xff -#define USER_ZB_SW_VAL 0xaa -#define USER_MATTER_PAIR_VAL 0x55 +#define USER_INIT_VAL 0xff +#define USER_ZB_SW_VAL 0xaa +#define USER_MATTER_PAIR_VAL 0x55 +#define USER_PARA_MAC_OFFSET 0x100 #define USER_PARTITION user_para_partition #define USER_PARTITION_DEVICE FIXED_PARTITION_DEVICE(USER_PARTITION) #define USER_PARTITION_OFFSET FIXED_PARTITION_OFFSET(USER_PARTITION) #define USER_PARTITION_SIZE FIXED_PARTITION_SIZE(USER_PARTITION) +typedef struct{ + uint8_t val ; + uint8_t rfu; + uint8_t onoff; + uint8_t lightness; +}user_para_t; + +extern user_para_t user_para; +extern uint8_t para_lightness; +extern uint8_t sBoot_zb; + #include using namespace ::chip; diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 1e8ad2f10fe323..3ad4f80d6852e9 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -51,6 +51,10 @@ #include #include +uint8_t sBoot_zb = 0; +user_para_t user_para; +uint8_t para_lightness = 0; + using namespace chip::app; LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); @@ -62,7 +66,6 @@ constexpr int kAppEventQueueSize = 10; const struct device * flash_para_dev = USER_PARTITION_DEVICE; constexpr int kDnssTimeout = 60000; k_timer sDnssTimer; -uint8_t sBoot_zb = 0; constexpr uint32_t kIdentifyBlinkRateMs = 200; constexpr uint32_t kIdentifyOkayOnRateMs = 50; @@ -226,13 +229,31 @@ void AppTaskCommon::DnssTimerTimeoutCallback(k_timer * timer) if (!timer){ return; } - /*if from init to dnss cost large than 60s , it will reboot and back to zigbee mode*/ - printk("matter: dnss initialize timeout .\r\n"); + /*If initialization of Dnss takes longer than 60 seconds, the device will reboot and revert to Zigbee mode*/ + printk("Matter: DnssTimer expired.\r\n"); sys_reboot(0); } CHIP_ERROR AppTaskCommon::StartApp(void) { + /* Proc ota boot flag , and erase flag */ + flash_read(flash_para_dev, USER_PARTITION_OFFSET, &user_para, sizeof(user_para)); + /* Boot from Zigbee , need to clean the user parameters sector first and set a flag */ + if (user_para.val == USER_ZB_SW_VAL){ + sBoot_zb = 1; + /* Ensure lightness is at least 2 to avoid display error on HomePod Mini */ + if(user_para.lightness < 2){ + user_para.lightness = 2; + } + /* Pass the value to the init part to avoid gaps in pwm_pool init */ + if(user_para.onoff){ + para_lightness = user_para.lightness; + } + k_timer_init(&sDnssTimer, &AppTask::DnssTimerTimeoutCallback, nullptr); + k_timer_start(&sDnssTimer, K_MSEC(kDnssTimeout), K_NO_WAIT); + printk("Matter: start timer to protect Dnss initialized %x \r\n",*(int *)(&user_para)); + } + CHIP_ERROR err = GetAppTask().Init(); if (err != CHIP_NO_ERROR) @@ -259,18 +280,6 @@ CHIP_ERROR AppTaskCommon::StartApp(void) } #endif /* CONFIG_BOOTLOADER_MCUBOOT */ - /* Proc ota boot flag , and erase flag */ - uint8_t val = 0; - flash_read(flash_para_dev, USER_PARTITION_OFFSET, &val, 1); - /* Boot from zibee , need clean the user-para sector first and set a flag */ - if (val == USER_ZB_SW_VAL){ - flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE); - sBoot_zb = 1; - k_timer_init(&sDnssTimer, &AppTask::DnssTimerTimeoutCallback, nullptr); - k_timer_start(&sDnssTimer, K_MSEC(kDnssTimeout), K_NO_WAIT); - printk("matter: start timer to protect dnss initialized \r\n"); - } - while (true) { GetEvent(&event); @@ -795,13 +804,13 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* } break; case DeviceEventType::kFailSafeTimerExpired: - if (sBoot_zb) - { - flash_erase(flash_para_dev, USER_PARTITION_OFFSET, USER_PARTITION_SIZE); - printk("matter commission FailSafeTimerExpired, will back to zigbee ,rebooting \r\n"); + /* Reset to Zigbee mode if commissioning fails */ + if (sBoot_zb){ + printk("FailSafeTimer expired, Matter commissioning failed, rebooting to Zigbee mode.\r\n"); sys_reboot(0); + }else{ + printk("FailSafeTimer expired, Matter commissioning failed.\r\n"); } - printk("matter commission FailSafeTimerExpired"); break; #if CHIP_DEVICE_CONFIG_ENABLE_THREAD @@ -819,7 +828,7 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* #endif if(sBoot_zb){ k_timer_stop(&sDnssTimer); - printk("matter commission kDnssdInitialized \r\n"); + printk("Dnss Timer stopped, Matter commissioning kDnssdInitialized.\r\n"); } break; case DeviceEventType::kThreadStateChange: diff --git a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c index 3f1651844f1cec..f665f70b98da04 100644 --- a/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c +++ b/examples/platform/telink/zephyr_ext/zephyr_pwm_pool.c @@ -175,7 +175,8 @@ bool pwm_pool_init(struct pwm_pool_data * pwm_pool) /* init all PWMs are ready */ for (size_t i = 0; i < pwm_pool->out_len; i++) { - if (pwm_set_dt(&pwm_pool->out[i], pwm_pool->out[i].period, 0)) + extern unsigned char para_lightness ; + if (pwm_set_dt(&pwm_pool->out[i], pwm_pool->out[i].period, para_lightness*pwm_pool->out[i].period/255)) { result = false; break; diff --git a/src/platform/telink/tlsr9528a.overlay b/src/platform/telink/tlsr9528a.overlay index fcd51928576ecf..d80b61f12434cf 100644 --- a/src/platform/telink/tlsr9528a.overlay +++ b/src/platform/telink/tlsr9528a.overlay @@ -34,9 +34,10 @@ pwm_pool { compatible = "pwm-leds"; out { - pwms = <&pwm0 2 PWM_MSEC(20) PWM_POLARITY_NORMAL>, - <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>, - <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_NORMAL>; + pwms = <&pwm0 2 PWM_MSEC(1) PWM_POLARITY_NORMAL>, + <&pwm0 0 PWM_MSEC(1) PWM_POLARITY_NORMAL>, + <&pwm0 1 PWM_MSEC(1) PWM_POLARITY_NORMAL>, + <&pwm0 2 PWM_MSEC(1) PWM_POLARITY_NORMAL>; }; }; }; @@ -59,4 +60,3 @@ pinmux = ; }; }; -