Skip to content

Commit

Permalink
[Telink]: Added Thread-only mode
Browse files Browse the repository at this point in the history
Added Thread-only mode for testing

Signed-off-by: Misha Tkachenko <[email protected]>
  • Loading branch information
mishadesh committed Oct 12, 2023
1 parent 74fb3b1 commit 724e5fa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ endchoice
if BOARD_TLSR9528A_RETENTION || BOARD_TLSR9518ADK80D_RETENTION
config BOARD_TLSR9X_NON_RETENTION_RAM_CODE
default y if PM

config TELINK_B9x_MATTER_RETENTION_LAYOUT
default y if PM
endif

# Config dynamic interrupts to have posibility to switch between BLE/Thread radio drivers
Expand Down
6 changes: 0 additions & 6 deletions examples/light-switch-app/telink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,3 @@ CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n

# Enable Power Management
CONFIG_PM=y
CONFIG_TELINK_B9x_MATTER_RETENTION_LAYOUT=y
CONFIG_CHIP_ICD_SLOW_POLL_INTERVAL=10000
CONFIG_CHIP_ICD_FAST_POLLING_INTERVAL=2000
CONFIG_CHIP_ICD_IDLE_MODE_INTERVAL=2000
CONFIG_CHIP_ICD_ACTIVE_MODE_INTERVAL=2001
CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD=2000
2 changes: 1 addition & 1 deletion examples/platform/telink/common/include/AppTaskCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AppTaskCommon
static void StartBleAdvHandler(AppEvent * aEvent);
#endif

#if APP_USE_THREAD_START_BUTTON
#if APP_USE_THREAD_START_BUTTON || !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
static void StartThreadButtonEventHandler(void);
static void StartThreadHandler(AppEvent * aEvent);
#endif
Expand Down
15 changes: 13 additions & 2 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const struct gpio_dt_spec sBleStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_
#if APP_USE_THREAD_START_BUTTON
const struct gpio_dt_spec sThreadStartButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_3), gpios);
#endif
#if APP_USE_EXAMPLE_START_BUTTON
#if APP_USE_EXAMPLE_START_BUTTON
const struct gpio_dt_spec sExampleActionButtonDt = GPIO_DT_SPEC_GET(DT_NODELABEL(key_4), gpios);
#endif
#else
Expand Down Expand Up @@ -145,11 +145,13 @@ class AppCallbacks : public AppDelegate
void OnCommissioningSessionStarted() override { isComissioningStarted = true; }
void OnCommissioningSessionStopped() override { isComissioningStarted = false; }
void OnCommissioningSessionEstablishmentError(CHIP_ERROR err) override { sIsCommissioningFailed = true; }
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
void OnCommissioningWindowClosed() override
{
if (!isComissioningStarted)
chip::DeviceLayer::Internal::BLEMgr().Shutdown();
}
#endif
};

AppCallbacks sCallbacks;
Expand Down Expand Up @@ -245,6 +247,10 @@ CHIP_ERROR AppTaskCommon::StartApp(void)

AppEvent event = {};

#if !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
StartThreadButtonEventHandler();
#endif

while (true)
{
GetEvent(&event);
Expand Down Expand Up @@ -634,7 +640,7 @@ void AppTaskCommon::FactoryResetTimerEventHandler(AppEvent * aEvent)
LOG_INF("Factory Reset Trigger Counter is cleared");
}

#if APP_USE_THREAD_START_BUTTON
#if APP_USE_THREAD_START_BUTTON || !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
void AppTaskCommon::StartThreadButtonEventHandler(void)
{
AppEvent event;
Expand All @@ -651,8 +657,13 @@ void AppTaskCommon::StartThreadHandler(AppEvent * aEvent)
if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
{
// Switch context from BLE to Thread
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
Internal::BLEManagerImpl sInstance;
sInstance.SwitchToIeee802154();
#else
ThreadStackMgrImpl().SetRadioBlocked(false);
ThreadStackMgrImpl().SetThreadEnabled(true);
#endif
StartDefaultThreadNetwork();
}
else
Expand Down

0 comments on commit 724e5fa

Please sign in to comment.