Skip to content

Commit

Permalink
Add 'Stop' command for BarrierControl (#3472)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored and pull[bot] committed Nov 10, 2020
1 parent 061849a commit 1795668
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
28 changes: 25 additions & 3 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ constexpr uint16_t kTempMeasurementClusterId = 0x0402;
|------------------------------------------------------------------------------|
| Commands: | |
| * GoToPercent | 0x00 |
| * Stop | 0x01 |
|------------------------------------------------------------------------------|
| Attributes: | |
| * MovingState | 0x0001 |
Expand Down Expand Up @@ -460,6 +461,27 @@ class BarrierControlGoToPercent : public ModelCommand
uint8_t mPercentOpen;
};

/*
* Command Stop
*/
class BarrierControlStop : public ModelCommand
{
public:
BarrierControlStop() : ModelCommand("stop", kBarrierControlClusterId, 0x01) {}

uint16_t EncodeCommand(PacketBuffer * buffer, uint16_t bufferSize, uint8_t endPointId) override
{
return encodeBarrierControlClusterStopCommand(buffer->Start(), bufferSize, endPointId);
}

// Global Response: DefaultResponse
bool HandleGlobalResponse(uint8_t commandId, uint8_t * message, uint16_t messageLen) const override
{
DefaultResponse response;
return response.HandleCommandResponse(commandId, message, messageLen);
}
};

/*
* Attribute MovingState
*/
Expand Down Expand Up @@ -5062,9 +5084,9 @@ void registerClusterBarrierControl(Commands & commands)
const char * clusterName = "BarrierControl";

commands_list clusterCommands = {
make_unique<BarrierControlGoToPercent>(), make_unique<ReadBarrierControlMovingState>(),
make_unique<ReadBarrierControlSafetyStatus>(), make_unique<ReadBarrierControlCapabilities>(),
make_unique<ReadBarrierControlBarrierPosition>(),
make_unique<BarrierControlGoToPercent>(), make_unique<BarrierControlStop>(),
make_unique<ReadBarrierControlMovingState>(), make_unique<ReadBarrierControlSafetyStatus>(),
make_unique<ReadBarrierControlCapabilities>(), make_unique<ReadBarrierControlBarrierPosition>(),
};

commands.Register(clusterName, clusterCommands);
Expand Down
7 changes: 7 additions & 0 deletions src/app/chip-zcl-zpro-codec-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" {
|------------------------------------------------------------------------------|
| Commands: | |
| * GoToPercent | 0x00 |
| * Stop | 0x01 |
|------------------------------------------------------------------------------|
| Attributes: | |
| * MovingState | 0x0001 |
Expand All @@ -65,6 +66,12 @@ extern "C" {
uint16_t encodeBarrierControlClusterGoToPercentCommand(uint8_t * buffer, uint16_t buf_length, uint8_t destination_endpoint,
uint8_t percentOpen);

/**
* @brief
* Encode an stop command for BarrierControl server into buffer including the APS frame
*/
uint16_t encodeBarrierControlClusterStopCommand(uint8_t * buffer, uint16_t buf_length, uint8_t destination_endpoint);

/**
* @brief
* Encode a read command for the moving-state attribute for server into buffer including the APS frame
Expand Down
11 changes: 11 additions & 0 deletions src/app/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ uint16_t encodeReadAttributesCommand(uint8_t * buffer, uint16_t buf_length, uint
|------------------------------------------------------------------------------|
| Commands: | |
| * GoToPercent | 0x00 |
| * Stop | 0x01 |
|------------------------------------------------------------------------------|
| Attributes: | |
| * MovingState | 0x0001 |
Expand All @@ -231,6 +232,16 @@ uint16_t encodeBarrierControlClusterGoToPercentCommand(uint8_t * buffer, uint16_
COMMAND_FOOTER(kName);
}

/*
* Command Stop
*/
uint16_t encodeBarrierControlClusterStopCommand(uint8_t * buffer, uint16_t buf_length, uint8_t destination_endpoint)
{
const char * kName = "BarrierControlStop";
COMMAND_HEADER(kName, BARRIER_CONTROL_CLUSTER_ID, 0x01);
COMMAND_FOOTER(kName);
}

/*
* Attribute MovingState
*/
Expand Down

0 comments on commit 1795668

Please sign in to comment.