diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 98f59cbb2ae1bd..63528b8aaceb4f 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -354,7 +354,15 @@ CHIP_ERROR CommissioningWindowManager::StartAdvertisement() #if CONFIG_NETWORK_LAYER_BLE if (mIsBLE) { - ReturnErrorOnFailure(chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true)); + CHIP_ERROR err = chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true); + // BLE advertising may just not be supported. That should not prevent + // us from opening a commissioning window and advertising over IP. + if (err == CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE) + { + ChipLogProgress(AppServer, "BLE networking available but BLE advertising is not supported"); + err = CHIP_NO_ERROR; + } + ReturnErrorOnFailure(err); } #endif // CONFIG_NETWORK_LAYER_BLE @@ -405,7 +413,10 @@ CHIP_ERROR CommissioningWindowManager::StopAdvertisement(bool aShuttingDown) #if CONFIG_NETWORK_LAYER_BLE if (mIsBLE) { - ReturnErrorOnFailure(chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(false)); + // Ignore errors from SetBLEAdvertisingEnabled (which could be due to + // BLE advertising not being supported at all). Our commissioning + // window is now closed and we need to notify our delegate of that. + (void) chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(false); } #endif // CONFIG_NETWORK_LAYER_BLE diff --git a/src/include/platform/ConnectivityManager.h b/src/include/platform/ConnectivityManager.h index 105f70a74ee506..a44b1c53321a96 100644 --- a/src/include/platform/ConnectivityManager.h +++ b/src/include/platform/ConnectivityManager.h @@ -221,6 +221,12 @@ class ConnectivityManager CHIPoBLEServiceMode GetCHIPoBLEServiceMode(); CHIP_ERROR SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val); bool IsBLEAdvertisingEnabled(); + /** + * Enable or disable BLE advertising. + * + * @return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE if BLE advertising is not + * supported or other error on other failures. + */ CHIP_ERROR SetBLEAdvertisingEnabled(bool val); bool IsBLEAdvertising(); CHIP_ERROR SetBLEAdvertisingMode(BLEAdvertisingMode mode);