Skip to content

Commit be26a8f

Browse files
s07641069serhiiSalamakharestyled-commits
authored
[Telink] W91 BLE/WiFi updates & Update build to docker version 57 (#34027)
* [Telink] Enable IPv4 * [Telink] Logs for WiFi debug * [Telink] Get NetIf interface instead of static * [Telink] Add GetSupportedWiFiBandsMask * [Telink] Use ssid for OnNetworkingStatusChange * [Telink] Add join default WiFi network for debug * [Telink] Use key matrix * [Telink] Enable temporarry IPv4 & DHCPV4 Issue with IPv6 UDP bind & CHIP_IPV4 config * [Telink] Fixes to enable and test BLE * [Telink] Alignment with NRF/Zephyr platform * [Telink] Fix minimal mDNS init issue * [Telink] Add DNS server refresh after adding new IPv6 address * [Telink] Move NFCManagerImpl.cpp under chip_enable_nfc * [Telink] Add basic switch context from BLE to WiFi * [Telink] Enable Thread/WiFi start buttons with enabled BLE * [Telink] Places for SwitchToWiFi on finish BLE commisioning part * [Telink] Enable BLE for W91 * [Telink] fix CI error * [Telink] Use BLE/WiFi concurrent mode for W91 * [Telink] Use BLE/WiFi concurrent mode for W91 * [Telink] Remove unused includes * [Telink] Update set ble mac address for w91 and b9x * [Telink] Update to docker version 57 * Restyled by clang-format --------- Co-authored-by: Serhii Salamakha <serhii.salamakha@gmail.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent f170ae0 commit be26a8f

22 files changed

+321
-145
lines changed

.github/workflows/chef.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
if: github.actor != 'restyled-io[bot]'
9999

100100
container:
101-
image: ghcr.io/project-chip/chip-build-telink:54
101+
image: ghcr.io/project-chip/chip-build-telink:57
102102
options: --user root
103103

104104
steps:
@@ -110,7 +110,7 @@ jobs:
110110
platform: telink
111111
# - name: Update Zephyr to specific revision (for developers purpose)
112112
# shell: bash
113-
# run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py 0e8032dfef7e02498f34ba0b5d5d2df71a62adb1"
113+
# run: scripts/run_in_build_env.sh "python3 scripts/tools/telink/update_zephyr.py ab81a585fca6a83b30e1f4e58a021113d6a3acb8"
114114
- name: CI Examples Telink
115115
shell: bash
116116
run: |

.github/workflows/examples-telink.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
if: github.actor != 'restyled-io[bot]'
3939

4040
container:
41-
image: ghcr.io/project-chip/chip-build-telink:54
41+
image: ghcr.io/project-chip/chip-build-telink:57
4242
volumes:
4343
- "/tmp/bloat_reports:/tmp/bloat_reports"
4444

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

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

6262
- name: Build example Telink (B92 retention) Air Quality Sensor App
6363
run: |

config/telink/chip-module/CMakeLists.txt

+16-15
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,40 @@ matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG)
9595
matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
9696
matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)
9797
matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT)
98-
matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4)
98+
matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4)
9999
matter_add_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING)
100100
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)
101-
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
101+
matter_add_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" FALSE)
102102
matter_add_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 1)
103103
matter_add_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
104104
matter_add_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
105105
matter_add_gn_arg_bool ("chip_automation_logging" FALSE)
106106
matter_add_gn_arg_bool ("chip_enable_wifi" CONFIG_WIFI_W91)
107107
matter_add_gn_arg_bool ("chip_enable_icd_server" CONFIG_CHIP_ENABLE_ICD_SUPPORT)
108+
matter_add_gn_arg_bool ("chip_enable_factory_data" CONFIG_CHIP_FACTORY_DATA)
109+
matter_add_gn_arg_bool ("chip_mdns_minimal" CONFIG_WIFI_W91)
110+
matter_add_gn_arg_bool ("chip_mdns_platform" CONFIG_NET_L2_OPENTHREAD)
108111

109112
if (CONFIG_CHIP_ENABLE_ICD_SUPPORT)
110-
matter_add_gn_arg_bool ("chip_enable_icd_lit" CONFIG_CHIP_ICD_LIT_SUPPORT)
111-
matter_add_gn_arg_bool ("chip_enable_icd_checkin" CONFIG_CHIP_ICD_CHECK_IN_SUPPORT)
112-
matter_add_gn_arg_bool ("chip_enable_icd_user_active_mode_trigger" CONFIG_CHIP_ICD_UAT_SUPPORT)
113+
matter_add_gn_arg_bool ("chip_enable_icd_lit" CONFIG_CHIP_ICD_LIT_SUPPORT)
114+
matter_add_gn_arg_bool ("chip_enable_icd_checkin" CONFIG_CHIP_ICD_CHECK_IN_SUPPORT)
115+
matter_add_gn_arg_bool ("chip_enable_icd_user_active_mode_trigger" CONFIG_CHIP_ICD_UAT_SUPPORT)
113116
endif()
114117

115-
if (CONFIG_CHIP_FACTORY_DATA)
116-
matter_add_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
117-
matter_add_gn_arg_bool ("chip_enable_factory_data" "true")
118-
elseif (CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND)
119-
matter_add_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false")
118+
if (CONFIG_CHIP_FACTORY_DATA OR CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND)
119+
matter_add_gn_arg_bool("chip_use_transitional_commissionable_data_provider" FALSE)
120+
matter_add_gn_arg_bool("chip_use_transitional_device_instance_info_provider" FALSE)
120121
endif()
121122

122123
if (CONFIG_CHIP_ROTATING_DEVICE_ID)
123-
matter_add_gn_arg_bool("chip_enable_rotating_device_id" "true")
124-
matter_add_gn_arg_bool("chip_enable_additional_data_advertising" "true")
124+
matter_add_gn_arg_bool("chip_enable_rotating_device_id" TRUE)
125+
matter_add_gn_arg_bool("chip_enable_additional_data_advertising" TRUE)
125126
endif()
126127

127-
if (CONFIG_NET_L2_OPENTHREAD)
128-
matter_add_gn_arg_string("chip_mdns" "platform")
129-
elseif(CONFIG_WIFI_W91)
128+
if(CONFIG_WIFI_W91)
130129
matter_add_gn_arg_string("chip_mdns" "minimal")
130+
elseif (CONFIG_NET_L2_OPENTHREAD)
131+
matter_add_gn_arg_string("chip_mdns" "platform")
131132
else()
132133
matter_add_gn_arg_string("chip_mdns" "none")
133134
endif()

config/telink/chip-module/Kconfig

+10-1
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,18 @@ config CHIP_LOG_SIZE_OPTIMIZATION
178178
full configuration enabled by this option in the
179179
platform/telink/CHIPPlatformConfig.h file.
180180

181+
config CHIP_IPV4
182+
bool "IPv4 support for Matter"
183+
default n
184+
depends on NET_IPV4
185+
help
186+
If disabled, it allows to build Telink SDK application
187+
with IPv4 support independently of the Matter stack still
188+
running over IPv6.
189+
181190
config CHIP_BUTTON_MANAGER_IRQ_MODE
182191
bool "Use GPIO in an IRQ mode instead of polling the GPIO"
183-
default PM || BOARD_TLSR9118BDK40D
192+
default PM
184193
help
185194
Use GPIO in an IRQ mode to avoid button polling loop and extend the battery lifetime by waking up by GPIO event.
186195
GPIO events are working only with GPIO IRQ. This option changes button matrix configuration.

config/telink/chip-module/Kconfig.defaults

+26-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ choice LOG_MODE
3434
endchoice
3535

3636
choice MATTER_LOG_LEVEL_CHOICE
37-
default MATTER_LOG_LEVEL_INF
37+
default MATTER_LOG_LEVEL_DBG
3838
endchoice
3939

4040
config CHIP_APP_LOG_LEVEL
41-
default 3 # info
41+
default 4 # debug
4242

4343
config LOG_DEFAULT_LEVEL
4444
default 1 # error
@@ -108,7 +108,6 @@ config GPIO
108108
# Bluetooth Low Energy configs
109109

110110
config BT
111-
default n if BOARD_TLSR9118BDK40D
112111
default y
113112

114113
if BT
@@ -138,10 +137,12 @@ config BT_BUF_ACL_TX_SIZE
138137
default 251
139138

140139
config BT_RX_STACK_SIZE
141-
default 810
140+
default 810 if BT_B9X
141+
default 2048 if BT_W91
142142

143143
config BT_HCI_TX_STACK_SIZE
144-
default 640
144+
default 640 if BT_B9X
145+
default 2048 if BT_W91
145146

146147
config BT_DEVICE_NAME_GATT_WRITABLE
147148
bool
@@ -300,13 +301,32 @@ config CHIP_WIFI
300301
select WIFI_W91
301302
select WIFI
302303
select NET_STATISTICS
303-
select NET_L2_ETHERNET
304304
select NET_IPV6_ND # enable Neighbor Discovery to handle Router Advertisements
305305
select NET_IPV6_NBR_CACHE
306306
select NET_STATISTICS_USER_API
307+
# select NET_IPV4 # TODO: remove IPv4 when IPv6 will be ready (see CHIP_IPV4)
308+
# select NET_CONFIG_NEED_IPV4
309+
# select NET_DHCPV4
307310

308311
if CHIP_WIFI
309312

313+
config DEFAULT_WIFI_SSID
314+
string "Default WiFi SSID"
315+
depends on CHIP_WIFI
316+
default ""
317+
help
318+
The SSID of network to connect to if no WiFi station configuration exists in NV storage
319+
at the time the device boots.
320+
This option is for testing only and should be disabled in production releases
321+
322+
config DEFAULT_WIFI_PASSWORD
323+
string "Default WiFi Password"
324+
depends on CHIP_WIFI
325+
default ""
326+
help
327+
The password for the default WiFi network.
328+
This option is for testing only and should be disabled in production releases.
329+
310330
config CHIP_WIFI_CONNECTION_RECOVERY_MINIMUM_INTERVAL
311331
int "Define the minimum connection recovery time interval in milliseconds"
312332
depends on CHIP_WIFI

examples/platform/telink/common/include/AppTaskCommon.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class AppTaskCommon
7676
{
7777
kButtonId_ExampleAction = 1,
7878
kButtonId_FactoryReset,
79+
kButtonId_StartWiFi,
7980
kButtonId_StartThread,
8081
kButtonId_StartBleAdv
8182
} ButtonId;
@@ -102,9 +103,12 @@ class AppTaskCommon
102103
static void StartBleAdvButtonEventHandler(void);
103104
static void StartBleAdvHandler(AppEvent * aEvent);
104105

105-
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
106+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
106107
static void StartThreadButtonEventHandler(void);
107108
static void StartThreadHandler(AppEvent * aEvent);
109+
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
110+
static void StartWiFiButtonEventHandler(void);
111+
static void StartWiFiHandler(AppEvent * aEvent);
108112
#endif
109113

110114
static void ExampleActionButtonEventHandler(void);

examples/platform/telink/common/src/AppTaskCommon.cpp

+58-12
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
#include "LEDManager.h"
2525
#include "PWMManager.h"
2626

27+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
2728
#include "ThreadUtil.h"
29+
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
30+
#include <platform/Zephyr/InetUtils.h>
31+
#include <platform/telink/wifi/TelinkWiFiDriver.h>
32+
#endif
2833

2934
#include <DeviceInfoProviderImpl.h>
3035
#include <app/clusters/identify-server/identify-server.h>
@@ -74,7 +79,7 @@ uint8_t sFactoryResetCntr = 0;
7479
bool sIsCommissioningFailed = false;
7580
bool sIsNetworkProvisioned = false;
7681
bool sIsNetworkEnabled = false;
77-
bool sIsThreadAttached = false;
82+
bool sIsNetworkAttached = false;
7883
bool sHaveBLEConnections = false;
7984

8085
#if APP_SET_DEVICE_INFO_PROVIDER
@@ -213,13 +218,16 @@ CHIP_ERROR AppTaskCommon::StartApp(void)
213218

214219
AppEvent event = {};
215220

216-
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
221+
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
222+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
217223
StartThreadButtonEventHandler();
224+
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
225+
StartWiFiButtonEventHandler();
218226
#endif
227+
#endif /* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE */
219228

220229
#ifdef CONFIG_BOOTLOADER_MCUBOOT
221-
if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() &&
222-
!chip::DeviceLayer::ConnectivityMgr().IsWiFiStationProvisioned())
230+
if (!sIsNetworkProvisioned)
223231
{
224232
LOG_INF("Confirm image.");
225233
OtaConfirmNewImage();
@@ -359,10 +367,14 @@ void AppTaskCommon::ButtonEventHandler(ButtonId_t btnId, bool btnPressed)
359367
case kButtonId_FactoryReset:
360368
FactoryResetButtonEventHandler();
361369
break;
362-
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
370+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
363371
case kButtonId_StartThread:
364372
StartThreadButtonEventHandler();
365373
break;
374+
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
375+
case kButtonId_StartWiFi:
376+
StartWiFiButtonEventHandler();
377+
break;
366378
#endif
367379
case kButtonId_StartBleAdv:
368380
StartBleAdvButtonEventHandler();
@@ -433,16 +445,18 @@ void AppTaskCommon::LinkButtons(ButtonManager & buttonManager)
433445
buttonManager.addCallback(FactoryResetButtonEventHandler, 0, true);
434446
buttonManager.addCallback(ExampleActionButtonEventHandler, 1, true);
435447
buttonManager.addCallback(StartBleAdvButtonEventHandler, 2, true);
436-
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
448+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
437449
buttonManager.addCallback(StartThreadButtonEventHandler, 3, true);
450+
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
451+
buttonManager.addCallback(StartWiFiButtonEventHandler, 3, true);
438452
#endif
439453
}
440454

441455
void AppTaskCommon::UpdateStatusLED()
442456
{
443457
if (sIsNetworkProvisioned && sIsNetworkEnabled)
444458
{
445-
if (sIsThreadAttached)
459+
if (sIsNetworkAttached)
446460
{
447461
LedManager::getInstance().setLed(LedManager::EAppLed_Status, 950, 50);
448462
}
@@ -506,8 +520,8 @@ void AppTaskCommon::StartBleAdvHandler(AppEvent * aEvent)
506520
{
507521
LOG_INF("StartBleAdvHandler");
508522

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

581-
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
595+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
582596
void AppTaskCommon::StartThreadButtonEventHandler(void)
583597
{
584598
AppEvent event;
@@ -592,7 +606,7 @@ void AppTaskCommon::StartThreadButtonEventHandler(void)
592606
void AppTaskCommon::StartThreadHandler(AppEvent * aEvent)
593607
{
594608
LOG_INF("StartThreadHandler");
595-
if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
609+
if (!sIsNetworkProvisioned)
596610
{
597611
// Switch context from BLE to Thread
598612
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
@@ -609,6 +623,37 @@ void AppTaskCommon::StartThreadHandler(AppEvent * aEvent)
609623
LOG_INF("Device already commissioned");
610624
}
611625
}
626+
627+
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
628+
void AppTaskCommon::StartWiFiButtonEventHandler(void)
629+
{
630+
AppEvent event;
631+
632+
event.Type = AppEvent::kEventType_Button;
633+
event.ButtonEvent.Action = kButtonPushEvent;
634+
event.Handler = StartWiFiHandler;
635+
GetAppTask().PostEvent(&event);
636+
}
637+
638+
void AppTaskCommon::StartWiFiHandler(AppEvent * aEvent)
639+
{
640+
LOG_INF("StartWiFiHandler");
641+
642+
if (!strlen(CONFIG_DEFAULT_WIFI_SSID) || !strlen(CONFIG_DEFAULT_WIFI_PASSWORD))
643+
{
644+
LOG_ERR("default WiFi SSID/Password are not set");
645+
}
646+
647+
if (!sIsNetworkProvisioned)
648+
{
649+
net_if_up(InetUtils::GetWiFiInterface());
650+
NetworkCommissioning::TelinkWiFiDriver().StartDefaultWiFiNetwork();
651+
}
652+
else
653+
{
654+
LOG_INF("Device already commissioned");
655+
}
656+
}
612657
#endif
613658

614659
void AppTaskCommon::ExampleActionButtonEventHandler(void)
@@ -673,11 +718,12 @@ void AppTaskCommon::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /*
673718
case DeviceEventType::kThreadStateChange:
674719
sIsNetworkProvisioned = ConnectivityMgr().IsThreadProvisioned();
675720
sIsNetworkEnabled = ConnectivityMgr().IsThreadEnabled();
676-
sIsThreadAttached = ConnectivityMgr().IsThreadAttached();
721+
sIsNetworkAttached = ConnectivityMgr().IsThreadAttached();
677722
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
678723
case DeviceEventType::kWiFiConnectivityChange:
679724
sIsNetworkProvisioned = ConnectivityMgr().IsWiFiStationProvisioned();
680725
sIsNetworkEnabled = ConnectivityMgr().IsWiFiStationEnabled();
726+
sIsNetworkAttached = ConnectivityMgr().IsWiFiStationConnected();
681727
#if CONFIG_CHIP_OTA_REQUESTOR
682728
if (event->WiFiConnectivityChange.Result == kConnectivity_Established)
683729
{

examples/platform/telink/common/src/mainCommon.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ int main(void)
167167
#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI
168168
sWiFiCommissioningInstance.Init();
169169
#else
170-
return CHIP_ERROR_INTERNAL;
170+
err = CHIP_ERROR_INTERNAL;
171+
goto exit;
171172
#endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */
172173

173174
err = GetAppTask().StartApp();

examples/platform/telink/util/include/ThreadUtil.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919

2020
#include "AppConfig.h"
2121

22-
#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_ENABLE_THREAD
22+
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
2323
void StartDefaultThreadNetwork(void);
2424
#endif

0 commit comments

Comments
 (0)