diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 980d020a3c7bc6..0b06dc6c070101 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -234,6 +234,17 @@ CHIP_ERROR CommissioningWindowManager::OpenCommissioningWindow(Seconds16 commiss mCommissioningTimeoutTimerArmed = true; +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_THREAD_FTD + // Block device role changing into Router if commissioning window opened and device not yet Router. + // AdvertiseAndListenForPASE fails doesn't matter, because if it does the callers of OpenCommissioningWindow + // will end up calling ResetState, which will reset the boolean. + if (ConnectivityManagerImpl().GetThreadDeviceType() == ConnectivityManager::kThreadDeviceType_Router) + { + ThreadStackMgr().SetRouterPromotion(false); + mRecoverRouterDeviceRole = true; + } +#endif + return AdvertiseAndListenForPASE(); } @@ -470,15 +481,6 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement() // reset all advertising, switching to our new commissioning mode. app::DnssdServer::Instance().StartServer(); -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && CHIP_DEVICE_CONFIG_THREAD_FTD - // Block device role changing into Router if commissioning window opened and device not yet Router. - if (ConnectivityManagerImpl().GetThreadDeviceType() == ConnectivityManager::kThreadDeviceType_Router) - { - ThreadStackMgr().SetRouterPromotion(false); - mRecoverRouterDeviceRole = true; - } -#endif - return CHIP_NO_ERROR; }