Skip to content

Commit

Permalink
[chip-tool] Use chip::EndpointId instead of uint8_t and relax the res…
Browse files Browse the repository at this point in the history
…triction from old ZCL endpoint constraints (#13692)

* [chip-tool] Use chip::EndpointId instead of uint8_t and relax the restriction from old ZCL endpoint constraints

* Update generated code
  • Loading branch information
vivien-apple authored and pull[bot] committed Feb 14, 2024
1 parent 5d7997e commit 1548758
Show file tree
Hide file tree
Showing 4 changed files with 3,239 additions and 3,244 deletions.
7 changes: 3 additions & 4 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "../../config/PersistentStorage.h"
#include "../common/CHIPCommand.h"
#include <app/chip-zcl-zpro-codec.h>
#include <lib/core/CHIPEncoding.h>

class ModelCommand : public CHIPCommand
Expand All @@ -36,22 +35,22 @@ class ModelCommand : public CHIPCommand
void AddArguments()
{
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
AddArgument("endpoint-id", CHIP_ZCL_ENDPOINT_MIN, CHIP_ZCL_ENDPOINT_MAX, &mEndPointId);
AddArgument("endpoint-id", 0, UINT16_MAX, &mEndPointId);
AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs);
}

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); }

virtual CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endPointId) = 0;
virtual CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endPointId) = 0;

protected:
chip::Optional<uint16_t> mTimedInteractionTimeoutMs;

private:
chip::NodeId mNodeId;
uint8_t mEndPointId;
chip::EndpointId mEndPointId;

static void OnDeviceConnectedFn(void * context, ChipDevice * device);
static void OnDeviceConnectionFailureFn(void * context, PeerId peerId, CHIP_ERROR error);
Expand Down
4 changes: 0 additions & 4 deletions examples/chip-tool/commands/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@

class Command;

// Limits on endpoint values.
#define CHIP_ZCL_ENDPOINT_MIN 0x00
#define CHIP_ZCL_ENDPOINT_MAX 0xF0

template <typename T, typename... Args>
std::unique_ptr<Command> make_unique(Args &&... args)
{
Expand Down
24 changes: 12 additions & 12 deletions examples/chip-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ public:
ModelCommand::AddArguments();
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) command ({{asHex code 8}}) on endpoint %" PRIu8, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) command ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);

{{#chip_cluster_command_non_expanded_arguments}}
{{#if isArray}}
Expand Down Expand Up @@ -315,9 +315,9 @@ public:
{
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReadEvent on endpoint %" PRIu8, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReadEvent ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);

chip::Controller::{{asUpperCamelCase parent.name}}Cluster cluster;
cluster.Associate(device, endpointId);
Expand Down Expand Up @@ -348,9 +348,9 @@ public:
{
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReportEvent on endpoint %" PRIu8, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReportEvent ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);

chip::Controller::{{asUpperCamelCase parent.name}}Cluster cluster;
cluster.Associate(device, endpointId);
Expand Down Expand Up @@ -400,9 +400,9 @@ public:
{
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReadAttribute on endpoint %" PRIu8, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReadAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);

chip::Controller::{{asUpperCamelCase parent.name}}Cluster cluster;
cluster.Associate(device, endpointId);
Expand Down Expand Up @@ -443,9 +443,9 @@ public:
{
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) WriteAttribute on endpoint %" PRIu8, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) WriteAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);

chip::Controller::{{asUpperCamelCase parent.name}}Cluster cluster;
cluster.Associate(device, endpointId);
Expand Down Expand Up @@ -475,9 +475,9 @@ public:
{
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReportAttribute on endpoint %" PRIu8, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReportAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);

chip::Controller::{{asUpperCamelCase parent.name}}Cluster cluster;
cluster.Associate(device, endpointId);
Expand Down
Loading

0 comments on commit 1548758

Please sign in to comment.