Skip to content

Commit

Permalink
Merge branch 'master' into feature/fix-tv-app-install-flow-and-suppor…
Browse files Browse the repository at this point in the history
…ted-clusters
  • Loading branch information
lazarkov authored Jun 20, 2024
2 parents 61dde7a + be26a8f commit 21fce36
Show file tree
Hide file tree
Showing 25 changed files with 783 additions and 665 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/chef.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-telink:54
image: ghcr.io/project-chip/chip-build-telink:57
options: --user root

steps:
Expand All @@ -110,7 +110,7 @@ jobs:
platform: telink
# - name: Update Zephyr to specific revision (for developers purpose)
# shell: bash
# run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 0e8032dfef7e02498f34ba0b5d5d2df71a62adb1"
# run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ab81a585fca6a83b30e1f4e58a021113d6a3acb8"
- name: CI Examples Telink
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-telink:54
image: ghcr.io/project-chip/chip-build-telink:57
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"

Expand All @@ -57,7 +57,7 @@ jobs:
gh-context: ${{ toJson(github) }}

# - name: Update Zephyr to specific revision (for developers purpose)
# run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 0e8032dfef7e02498f34ba0b5d5d2df71a62adb1"
# run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ab81a585fca6a83b30e1f4e58a021113d6a3acb8"

- name: Build example Telink (B92 retention) Air Quality Sensor App
run: |
Expand Down
31 changes: 16 additions & 15 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,39 +95,40 @@ matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG)
matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT)
matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4)
matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4)
matter_add_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING)
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" FALSE)
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1)
matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
matter_add_gn_arg_bool ("chip_automation_logging" FALSE)
matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_WIFI_W91)
matter_add_gn_arg_bool ("chip_enable_icd_server" CONFIG_CHIP_ENABLE_ICD_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_factory_data" CONFIG_CHIP_FACTORY_DATA)
matter_add_gn_arg_bool ("chip_mdns_minimal" CONFIG_WIFI_W91)
matter_add_gn_arg_bool ("chip_mdns_platform" CONFIG_NET_L2_OPENTHREAD)

if (CONFIG_CHIP_ENABLE_ICD_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_icd_lit" CONFIG_CHIP_ICD_LIT_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_icd_checkin" CONFIG_CHIP_ICD_CHECK_IN_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_icd_user_active_mode_trigger" CONFIG_CHIP_ICD_UAT_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_icd_lit" CONFIG_CHIP_ICD_LIT_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_icd_checkin" CONFIG_CHIP_ICD_CHECK_IN_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_icd_user_active_mode_trigger" CONFIG_CHIP_ICD_UAT_SUPPORT)
endif()

if (CONFIG_CHIP_FACTORY_DATA)
matter_add_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
matter_add_gn_arg_bool ("chip_enable_factory_data" "true")
elseif (CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND)
matter_add_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
if (CONFIG_CHIP_FACTORY_DATA OR CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND)
matter_add_gn_arg_bool("chip_use_transitional_commissionable_data_provider" FALSE)
matter_add_gn_arg_bool("chip_use_transitional_device_instance_info_provider" FALSE)
endif()

if (CONFIG_CHIP_ROTATING_DEVICE_ID)
matter_add_gn_arg_bool("chip_enable_rotating_device_id" "true")
matter_add_gn_arg_bool("chip_enable_additional_data_advertising" "true")
matter_add_gn_arg_bool("chip_enable_rotating_device_id" TRUE)
matter_add_gn_arg_bool("chip_enable_additional_data_advertising" TRUE)
endif()

if (CONFIG_NET_L2_OPENTHREAD)
matter_add_gn_arg_string("chip_mdns" "platform")
elseif(CONFIG_WIFI_W91)
if(CONFIG_WIFI_W91)
matter_add_gn_arg_string("chip_mdns" "minimal")
elseif (CONFIG_NET_L2_OPENTHREAD)
matter_add_gn_arg_string("chip_mdns" "platform")
else()
matter_add_gn_arg_string("chip_mdns" "none")
endif()
Expand Down
11 changes: 10 additions & 1 deletion config/telink/chip-module/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,18 @@ config CHIP_LOG_SIZE_OPTIMIZATION
full configuration enabled by this option in the
platform/telink/CHIPPlatformConfig.h file.

config CHIP_IPV4
bool "IPv4 support for Matter"
default n
depends on NET_IPV4
help
If disabled, it allows to build Telink SDK application
with IPv4 support independently of the Matter stack still
running over IPv6.

config CHIP_BUTTON_MANAGER_IRQ_MODE
bool "Use GPIO in an IRQ mode instead of polling the GPIO"
default PM || BOARD_TLSR9118BDK40D
default PM
help
Use GPIO in an IRQ mode to avoid button polling loop and extend the battery lifetime by waking up by GPIO event.
GPIO events are working only with GPIO IRQ. This option changes button matrix configuration.
Expand Down
32 changes: 26 additions & 6 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ choice LOG_MODE
endchoice

choice MATTER_LOG_LEVEL_CHOICE
default MATTER_LOG_LEVEL_INF
default MATTER_LOG_LEVEL_DBG
endchoice

config CHIP_APP_LOG_LEVEL
default 3 # info
default 4 # debug

config LOG_DEFAULT_LEVEL
default 1 # error
Expand Down Expand Up @@ -108,7 +108,6 @@ config GPIO
# Bluetooth Low Energy configs

config BT
default n if BOARD_TLSR9118BDK40D
default y

if BT
Expand Down Expand Up @@ -138,10 +137,12 @@ config BT_BUF_ACL_TX_SIZE
default 251

config BT_RX_STACK_SIZE
default 810
default 810 if BT_B9X
default 2048 if BT_W91

config BT_HCI_TX_STACK_SIZE
default 640
default 640 if BT_B9X
default 2048 if BT_W91

config BT_DEVICE_NAME_GATT_WRITABLE
bool
Expand Down Expand Up @@ -300,13 +301,32 @@ config CHIP_WIFI
select WIFI_W91
select WIFI
select NET_STATISTICS
select NET_L2_ETHERNET
select NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements
select NET_IPV6_NBR_CACHE
select NET_STATISTICS_USER_API
# select NET_IPV4 # TODO: remove IPv4 when IPv6 will be ready (see CHIP_IPV4)
# select NET_CONFIG_NEED_IPV4
# select NET_DHCPV4

if CHIP_WIFI

config DEFAULT_WIFI_SSID
string "Default WiFi SSID"
depends on CHIP_WIFI
default ""
help
The SSID of network to connect to if no WiFi station configuration exists in NV storage
at the time the device boots.
This option is for testing only and should be disabled in production releases

config DEFAULT_WIFI_PASSWORD
string "Default WiFi Password"
depends on CHIP_WIFI
default ""
help
The password for the default WiFi network.
This option is for testing only and should be disabled in production releases.

config CHIP_WIFI_CONNECTION_RECOVERY_MINIMUM_INTERVAL
int "Define the minimum connection recovery time interval in milliseconds"
depends on CHIP_WIFI
Expand Down
6 changes: 5 additions & 1 deletion examples/platform/telink/common/include/AppTaskCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class AppTaskCommon
{
kButtonId_ExampleAction = 1,
kButtonId_FactoryReset,
kButtonId_StartWiFi,
kButtonId_StartThread,
kButtonId_StartBleAdv
} ButtonId;
Expand All @@ -102,9 +103,12 @@ class AppTaskCommon
static void StartBleAdvButtonEventHandler(void);
static void StartBleAdvHandler(AppEvent * aEvent);

#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
static void StartThreadButtonEventHandler(void);
static void StartThreadHandler(AppEvent * aEvent);
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
static void StartWiFiButtonEventHandler(void);
static void StartWiFiHandler(AppEvent * aEvent);
#endif

static void ExampleActionButtonEventHandler(void);
Expand Down
70 changes: 58 additions & 12 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
#include "LEDManager.h"
#include "PWMManager.h"

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
#include "ThreadUtil.h"
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
#include <platform/Zephyr/InetUtils.h>
#include <platform/telink/wifi/TelinkWiFiDriver.h>
#endif

#include <DeviceInfoProviderImpl.h>
#include <app/clusters/identify-server/identify-server.h>
Expand Down Expand Up @@ -74,7 +79,7 @@ uint8_t sFactoryResetCntr = 0;
bool sIsCommissioningFailed = false;
bool sIsNetworkProvisioned = false;
bool sIsNetworkEnabled = false;
bool sIsThreadAttached = false;
bool sIsNetworkAttached = false;
bool sHaveBLEConnections = false;

#if APP_SET_DEVICE_INFO_PROVIDER
Expand Down Expand Up @@ -213,13 +218,16 @@ CHIP_ERROR AppTaskCommon::StartApp(void)

AppEvent event = {};

#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
StartThreadButtonEventHandler();
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
StartWiFiButtonEventHandler();
#endif
#endif /* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE */

#ifdef CONFIG_BOOTLOADER_MCUBOOT
if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() &&
!chip::DeviceLayer::ConnectivityMgr().IsWiFiStationProvisioned())
if (!sIsNetworkProvisioned)
{
LOG_INF("Confirm image.");
OtaConfirmNewImage();
Expand Down Expand Up @@ -359,10 +367,14 @@ void AppTaskCommon::ButtonEventHandler(ButtonId_t btnId, bool btnPressed)
case kButtonId_FactoryReset:
FactoryResetButtonEventHandler();
break;
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
case kButtonId_StartThread:
StartThreadButtonEventHandler();
break;
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
case kButtonId_StartWiFi:
StartWiFiButtonEventHandler();
break;
#endif
case kButtonId_StartBleAdv:
StartBleAdvButtonEventHandler();
Expand Down Expand Up @@ -433,16 +445,18 @@ void AppTaskCommon::LinkButtons(ButtonManager & buttonManager)
buttonManager.addCallback(FactoryResetButtonEventHandler, 0, true);
buttonManager.addCallback(ExampleActionButtonEventHandler, 1, true);
buttonManager.addCallback(StartBleAdvButtonEventHandler, 2, true);
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
buttonManager.addCallback(StartThreadButtonEventHandler, 3, true);
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
buttonManager.addCallback(StartWiFiButtonEventHandler, 3, true);
#endif
}

void AppTaskCommon::UpdateStatusLED()
{
if (sIsNetworkProvisioned && sIsNetworkEnabled)
{
if (sIsThreadAttached)
if (sIsNetworkAttached)
{
LedManager::getInstance().setLed(LedManager::EAppLed_Status, 950, 50);
}
Expand Down Expand Up @@ -506,8 +520,8 @@ void AppTaskCommon::StartBleAdvHandler(AppEvent * aEvent)
{
LOG_INF("StartBleAdvHandler");

// Don't allow on starting Matter service BLE advertising after Thread provisioning.
if (ConnectivityMgr().IsThreadProvisioned())
// Disable manual Matter service BLE advertising after device provisioning.
if (sIsNetworkProvisioned)
{
LOG_INF("Device already commissioned");
return;
Expand Down Expand Up @@ -578,7 +592,7 @@ void AppTaskCommon::FactoryResetTimerEventHandler(AppEvent * aEvent)
LOG_INF("Factory Reset Trigger Counter is cleared");
}

#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
void AppTaskCommon::StartThreadButtonEventHandler(void)
{
AppEvent event;
Expand All @@ -592,7 +606,7 @@ void AppTaskCommon::StartThreadButtonEventHandler(void)
void AppTaskCommon::StartThreadHandler(AppEvent * aEvent)
{
LOG_INF("StartThreadHandler");
if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
if (!sIsNetworkProvisioned)
{
// Switch context from BLE to Thread
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Expand All @@ -609,6 +623,37 @@ void AppTaskCommon::StartThreadHandler(AppEvent * aEvent)
LOG_INF("Device already commissioned");
}
}

#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
void AppTaskCommon::StartWiFiButtonEventHandler(void)
{
AppEvent event;

event.Type = AppEvent::kEventType_Button;
event.ButtonEvent.Action = kButtonPushEvent;
event.Handler = StartWiFiHandler;
GetAppTask().PostEvent(&event);
}

void AppTaskCommon::StartWiFiHandler(AppEvent * aEvent)
{
LOG_INF("StartWiFiHandler");

if (!strlen(CONFIG_DEFAULT_WIFI_SSID) || !strlen(CONFIG_DEFAULT_WIFI_PASSWORD))
{
LOG_ERR("default WiFi SSID/Password are not set");
}

if (!sIsNetworkProvisioned)
{
net_if_up(InetUtils::GetWiFiInterface());
NetworkCommissioning::TelinkWiFiDriver().StartDefaultWiFiNetwork();
}
else
{
LOG_INF("Device already commissioned");
}
}
#endif

void AppTaskCommon::ExampleActionButtonEventHandler(void)
Expand Down Expand Up @@ -673,11 +718,12 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /*
case DeviceEventType::kThreadStateChange:
sIsNetworkProvisioned = ConnectivityMgr().IsThreadProvisioned();
sIsNetworkEnabled = ConnectivityMgr().IsThreadEnabled();
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
sIsNetworkAttached = ConnectivityMgr().IsThreadAttached();
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
case DeviceEventType::kWiFiConnectivityChange:
sIsNetworkProvisioned = ConnectivityMgr().IsWiFiStationProvisioned();
sIsNetworkEnabled = ConnectivityMgr().IsWiFiStationEnabled();
sIsNetworkAttached = ConnectivityMgr().IsWiFiStationConnected();
#if CONFIG_CHIP_OTA_REQUESTOR
if (event->WiFiConnectivityChange.Result == kConnectivity_Established)
{
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/telink/common/src/mainCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ int main(void)
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
sWiFiCommissioningInstance.Init();
#else
return CHIP_ERROR_INTERNAL;
err = CHIP_ERROR_INTERNAL;
goto exit;
#endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */

err = GetAppTask().StartApp();
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/util/include/ThreadUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

#include "AppConfig.h"

#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
void StartDefaultThreadNetwork(void);
#endif
Loading

0 comments on commit 21fce36

Please sign in to comment.