-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the switch delegate APIs from platform layer to application …
…domain (#18742) * The application should register and call the delegate APIs for each switch event * Update src/app/clusters/switch-server/switch-server.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/clusters/switch-server/switch-server.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/clusters/switch-server/switch-server.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/clusters/switch-server/switch-server.h Co-authored-by: Boris Zbarsky <[email protected]> * Update src/app/clusters/switch-server/switch-server.h Co-authored-by: Boris Zbarsky <[email protected]> * Address review comments Co-authored-by: Boris Zbarsky <[email protected]>
- Loading branch information
Showing
5 changed files
with
188 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app/AttributeAccessInterface.h> | ||
#include <app/CommandResponseHelper.h> | ||
#include <app/util/af.h> | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
namespace Switch { | ||
|
||
/** | ||
* @brief switch-server class | ||
*/ | ||
class Server | ||
{ | ||
public: | ||
static Server & Instance(); | ||
|
||
/** | ||
* @brief | ||
* Called when the latching switch is moved to a new position. | ||
*/ | ||
void OnSwitchLatch(EndpointId endpoint, uint8_t newPosition); | ||
|
||
/** | ||
* @brief | ||
* Called when the momentary switch starts to be pressed. | ||
*/ | ||
void OnInitialPress(EndpointId endpoint, uint8_t newPosition); | ||
|
||
/** | ||
* @brief | ||
* Called when the momentary switch has been pressed for a "long" time. | ||
*/ | ||
void OnLongPress(EndpointId endpoint, uint8_t newPosition); | ||
|
||
/** | ||
* @brief | ||
* Called when the momentary switch has been released. | ||
*/ | ||
void OnShortRelease(EndpointId endpoint, uint8_t previousPosition); | ||
|
||
/** | ||
* @brief | ||
* Called when the momentary switch has been released (after debouncing) | ||
* after having been pressed for a long time. | ||
*/ | ||
void OnLongRelease(EndpointId endpoint, uint8_t previousPosition); | ||
|
||
/** | ||
* @brief | ||
* Called to indicate how many times the momentary switch has been pressed | ||
* in a multi-press sequence, during that sequence. | ||
*/ | ||
void OnMultiPressOngoing(EndpointId endpoint, uint8_t newPosition, uint8_t count); | ||
|
||
/** | ||
* @brief | ||
* Called to indicate how many times the momentary switch has been pressed | ||
* in a multi-press sequence, after it has been detected that the sequence has ended. | ||
*/ | ||
void OnMultiPressComplete(EndpointId endpoint, uint8_t newPosition, uint8_t count); | ||
|
||
private: | ||
static Server instance; | ||
}; | ||
|
||
} // namespace Switch | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
Oops, something went wrong.