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

Remove BarrierControlBarrierPosition and BarrierControlMovingState #30523

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
54 changes: 39 additions & 15 deletions src/app/clusters/barrier-control-server/barrier-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,33 @@ using namespace chip::app::Clusters;
using namespace chip::app::Clusters::BarrierControl;
using chip::Protocols::InteractionModel::Status;

// this is NOT in any spec (CHIP spec does not currently have BarrierControl)
// and XMLs do not attach these enums to clusters.
//
// This directly defines some constants. These could be replaced with real
// constants if we ever have some BarrierControl in the matter specification.
namespace chip {
namespace app {
namespace Clusters {
namespace BarrierControl {

namespace Position {
static constexpr uint8_t kClosed = 0;
static constexpr uint8_t kOpen = 100;
static constexpr uint8_t kUnknown = 255;
} // namespace Position

namespace MovingState {
static constexpr uint8_t kStopped = 0;
static constexpr uint8_t kClosing = 1;
static constexpr uint8_t kOpening = 2;
} // namespace MovingState

} // namespace BarrierControl
} // namespace Clusters
} // namespace app
} // namespace chip

typedef struct
{
uint8_t currentPosition;
Expand Down Expand Up @@ -220,9 +247,8 @@ static uint8_t getCurrentPosition(EndpointId endpoint)
// way of knowing the position of the barrier. Let's guess that the barrier is
// open so that we don't leave the barrier open when it should be closed.
uint8_t currentPositionFromAttribute = emAfPluginBarrierControlServerGetBarrierPosition(endpoint);
return ((currentPositionFromAttribute == EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_UNKNOWN)
? static_cast<uint8_t>(EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_OPEN)
: currentPositionFromAttribute);
return ((currentPositionFromAttribute == BarrierControl::Position::kUnknown) ? BarrierControl::Position::kOpen
: currentPositionFromAttribute);
}

static uint32_t calculateDelayMs(EndpointId endpoint, uint8_t targetPosition, bool * opening)
Expand All @@ -249,7 +275,7 @@ void emberAfBarrierControlClusterServerTickCallback(EndpointId endpoint)
if (state.currentPosition == state.targetPosition)
{
emAfPluginBarrierControlServerSetBarrierPosition(endpoint, state.currentPosition);
setMovingState(endpoint, EMBER_ZCL_BARRIER_CONTROL_MOVING_STATE_STOPPED);
setMovingState(endpoint, BarrierControl::MovingState::kStopped);
cancelEndpointTimerCallback(endpoint);
}
else
Expand All @@ -270,14 +296,13 @@ void emberAfBarrierControlClusterServerTickCallback(EndpointId endpoint)
emAfPluginBarrierControlServerIncrementEvents(endpoint, false, false);
}
}
emAfPluginBarrierControlServerSetBarrierPosition(
endpoint,
(emAfPluginBarrierControlServerIsPartialBarrierSupported(endpoint)
? state.currentPosition
: static_cast<uint8_t>(EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_UNKNOWN)));
setMovingState(
endpoint,
(state.increasing ? EMBER_ZCL_BARRIER_CONTROL_MOVING_STATE_OPENING : EMBER_ZCL_BARRIER_CONTROL_MOVING_STATE_CLOSING));
emAfPluginBarrierControlServerSetBarrierPosition(endpoint,
(emAfPluginBarrierControlServerIsPartialBarrierSupported(endpoint)
? state.currentPosition
: BarrierControl::Position::kUnknown));
setMovingState(endpoint,
(state.increasing ? BarrierControl::MovingState::kOpening : BarrierControl::MovingState::kClosing));

scheduleTimerCallbackMs(endpoint, state.delayMs);
}
}
Expand Down Expand Up @@ -307,8 +332,7 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(
}
else if (percentOpen > 100 // "100" means "100%", so greater than that is invalid
|| (!emAfPluginBarrierControlServerIsPartialBarrierSupported(endpoint) &&
percentOpen != EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_CLOSED &&
percentOpen != EMBER_ZCL_BARRIER_CONTROL_BARRIER_POSITION_OPEN))
percentOpen != BarrierControl::Position::kClosed && percentOpen != BarrierControl::Position::kOpen))
{
status = Status::ConstraintError;
}
Expand Down Expand Up @@ -342,7 +366,7 @@ bool emberAfBarrierControlClusterBarrierControlStopCallback(app::CommandHandler
{
EndpointId endpoint = commandPath.mEndpointId;
cancelEndpointTimerCallback(endpoint);
setMovingState(endpoint, EMBER_ZCL_BARRIER_CONTROL_MOVING_STATE_STOPPED);
setMovingState(endpoint, BarrierControl::MovingState::kStopped);
sendDefaultResponse(commandObj, commandPath, Status::Success);
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ DarwinForceWritable:
WeakEnums:
# Allow-list of enums that we generate as enums, not enum classes.
# The goal is to drive this down to 0.
- BarrierControlBarrierPosition
- BarrierControlMovingState
- ColorControlOptions
- ColorMode
- EnhancedColorMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ limitations under the License.
<field name="positionFailure" mask="0x08"/>
</bitmap>

<enum name="BarrierControlBarrierPosition" type="int8u">
<item name="Closed" value="0"/>
<item name="Open" value="100"/>
<item name="Unknown" value="0xFF"/>
</enum>

<enum name="BarrierControlMovingState" type="enum8">
<item name="Stopped" value="0x00"/>
<item name="Closing" value="0x01"/>
<item name="Opening" value="0x02"/>
</enum>

<cluster>
<name>Barrier Control</name>
<domain>Closures</domain>
Expand Down
16 changes: 0 additions & 16 deletions zzz_generated/app-common/app-common/zap-generated/enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading