Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppDelegate updates: new callback and docs #28240

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AppCallbacks : public AppDelegate
public:
void OnCommissioningSessionEstablishmentStarted() {}
void OnCommissioningSessionStarted() override { bluetoothLED.Set(true); }
void OnCommissioningSessionStopped(CHIP_ERROR err) override
void OnCommissioningSessionStopped() override
{
bluetoothLED.Set(false);
pairingWindowLED.Set(false);
Expand Down
2 changes: 1 addition & 1 deletion examples/all-clusters-minimal-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AppCallbacks : public AppDelegate
public:
void OnCommissioningSessionEstablishmentStarted() {}
void OnCommissioningSessionStarted() override { bluetoothLED.Set(true); }
void OnCommissioningSessionStopped(CHIP_ERROR err) override
void OnCommissioningSessionStopped() override
{
bluetoothLED.Set(false);
pairingWindowLED.Set(false);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class AppCallbacks : public AppDelegate
public:
void OnCommissioningSessionEstablishmentStarted() {}
void OnCommissioningSessionStarted() override { isComissioningStarted = true; }
void OnCommissioningSessionStopped(CHIP_ERROR err) override { isComissioningStarted = false; }
void OnCommissioningSessionStopped() override { isComissioningStarted = false; }
void OnCommissioningWindowClosed() override
{
if (!isComissioningStarted)
Expand Down
28 changes: 25 additions & 3 deletions src/app/server/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,42 @@ class AppDelegate
public:
virtual ~AppDelegate() {}
/**
* This is called on start of session establishment process
* This is called when the PBKDFParamRequest is received and indicates the start of the session establishment process
*/
virtual void OnCommissioningSessionEstablishmentStarted() {}

/**
* This is called when the commissioning session has been established
*/
virtual void OnCommissioningSessionStarted() {}
virtual void OnCommissioningSessionStopped(CHIP_ERROR err) {}
cliffamzn marked this conversation as resolved.
Show resolved Hide resolved

/**
* This is called when the PASE establishment failed (such as, when an invalid passcode is provided) or PASE was established
* fine but then the fail-safe expired (including being expired by the commissioner)
*
* @param err CHIP_ERROR indicating the error that occurred during session establishment
sharadb-amazon marked this conversation as resolved.
Show resolved Hide resolved
*/
virtual void OnCommissioningSessionEstablishmentError(CHIP_ERROR err) {}
sharadb-amazon marked this conversation as resolved.
Show resolved Hide resolved

/**
* This is called when the PASE establishment failed or PASE was established fine but then the fail-safe expired (including
* being expired by the commissioner) AND the commissioning window is closed. The window may be closed because the commissioning
* attempts limit was reached or advertising/listening for PASE failed.
*/
virtual void OnCommissioningSessionStopped() {}
sharadb-amazon marked this conversation as resolved.
Show resolved Hide resolved

/*
* This is called anytime a basic or enhanced commissioning window is opened.
* This is called any time a basic or enhanced commissioning window is opened.
*
* The type of the window can be retrieved by calling
* CommissioningWindowManager::CommissioningWindowStatusForCluster(), but
* being careful about how to handle the None status when a window is in
* fact open.
*/
virtual void OnCommissioningWindowOpened() {}

/*
* This is called any time a basic or enhanced commissioning window is closed.
*/
virtual void OnCommissioningWindowClosed() {}
};
9 changes: 8 additions & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,20 @@ void CommissioningWindowManager::HandleFailedAttempt(CHIP_ERROR err)
#if CONFIG_NETWORK_LAYER_BLE
mServer->GetBleLayerObject()->CloseAllBleConnections();
#endif

CHIP_ERROR prevErr = err;
if (mFailedCommissioningAttempts < kMaxFailedCommissioningAttempts)
{
// If the number of commissioning attempts has not exceeded maximum
// retries, let's start listening for commissioning connections again.
err = AdvertiseAndListenForPASE();
}

if (mAppDelegate != nullptr)
{
mAppDelegate->OnCommissioningSessionEstablishmentError(prevErr);
}

if (err != CHIP_NO_ERROR)
{
// The commissioning attempts limit was exceeded, or listening for
Expand All @@ -165,7 +172,7 @@ void CommissioningWindowManager::HandleFailedAttempt(CHIP_ERROR err)

if (mAppDelegate != nullptr)
{
mAppDelegate->OnCommissioningSessionStopped(err);
mAppDelegate->OnCommissioningSessionStopped();
}
}
}
Expand Down