Skip to content

Commit

Permalink
Update AppDelegate to report error param and callback for when sessio…
Browse files Browse the repository at this point in the history
…n establishment starts (#28138)
  • Loading branch information
sharadb-amazon authored Jul 21, 2023
1 parent 2c06e6c commit 5897af2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion examples/all-clusters-minimal-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion src/app/server/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@

#pragma once

#include <lib/core/CHIPError.h>

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.
Expand Down
8 changes: 7 additions & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void CommissioningWindowManager::HandleFailedAttempt(CHIP_ERROR err)

if (mAppDelegate != nullptr)
{
mAppDelegate->OnCommissioningSessionStopped();
mAppDelegate->OnCommissioningSessionStopped(err);
}
}
}
Expand All @@ -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)
Expand Down

0 comments on commit 5897af2

Please sign in to comment.