diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index 4ace2fb3510baa..83d6abc102701f 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -85,8 +85,9 @@ namespace { class AppCallbacks : public AppDelegate { public: + void OnCommissioningSessionEstablishmentStarted() {} void OnCommissioningSessionStarted() override { bluetoothLED.Set(true); } - void OnCommissioningSessionStopped() override + void OnCommissioningSessionStopped(CHIP_ERROR err) override { bluetoothLED.Set(false); pairingWindowLED.Set(false); diff --git a/examples/all-clusters-minimal-app/esp32/main/main.cpp b/examples/all-clusters-minimal-app/esp32/main/main.cpp index f62a30a71d7a96..43c6faa51a2972 100644 --- a/examples/all-clusters-minimal-app/esp32/main/main.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/main.cpp @@ -84,8 +84,9 @@ namespace { class AppCallbacks : public AppDelegate { public: + void OnCommissioningSessionEstablishmentStarted() {} void OnCommissioningSessionStarted() override { bluetoothLED.Set(true); } - void OnCommissioningSessionStopped() override + void OnCommissioningSessionStopped(CHIP_ERROR err) override { bluetoothLED.Set(false); pairingWindowLED.Set(false); diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 263f094b440ab4..cd9fe12a60a0bc 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -138,8 +138,9 @@ class AppCallbacks : public AppDelegate bool isComissioningStarted; public: + void OnCommissioningSessionEstablishmentStarted() {} void OnCommissioningSessionStarted() override { isComissioningStarted = true; } - void OnCommissioningSessionStopped() override { isComissioningStarted = false; } + void OnCommissioningSessionStopped(CHIP_ERROR err) override { isComissioningStarted = false; } void OnCommissioningWindowClosed() override { if (!isComissioningStarted) diff --git a/src/app/server/AppDelegate.h b/src/app/server/AppDelegate.h index dbd1d42c7a4828..24dcf2e3a92ec5 100644 --- a/src/app/server/AppDelegate.h +++ b/src/app/server/AppDelegate.h @@ -22,12 +22,18 @@ #pragma once +#include + class AppDelegate { public: virtual ~AppDelegate() {} + /** + * This is called on start of session establishment process + */ + virtual void OnCommissioningSessionEstablishmentStarted() {} virtual void OnCommissioningSessionStarted() {} - virtual void OnCommissioningSessionStopped() {} + virtual void OnCommissioningSessionStopped(CHIP_ERROR err) {} /* * This is called anytime a basic or enhanced commissioning window is opened. diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index ea5ab150556bf1..b8fb6a54e6e629 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -165,7 +165,7 @@ void CommissioningWindowManager::HandleFailedAttempt(CHIP_ERROR err) if (mAppDelegate != nullptr) { - mAppDelegate->OnCommissioningSessionStopped(); + mAppDelegate->OnCommissioningSessionStopped(err); } } } @@ -175,6 +175,12 @@ void CommissioningWindowManager::OnSessionEstablishmentStarted() // As per specifications, section 5.5: Commissioning Flows constexpr System::Clock::Timeout kPASESessionEstablishmentTimeout = System::Clock::Seconds16(60); DeviceLayer::SystemLayer().StartTimer(kPASESessionEstablishmentTimeout, HandleSessionEstablishmentTimeout, this); + + ChipLogProgress(AppServer, "Commissioning session establishment step started"); + if (mAppDelegate != nullptr) + { + mAppDelegate->OnCommissioningSessionEstablishmentStarted(); + } } void CommissioningWindowManager::OnSessionEstablished(const SessionHandle & session)