Skip to content

Commit

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

This reverts commit d1f6619.
  • Loading branch information
mspang committed Jan 25, 2022
1 parent 270081a commit 45a8add
Show file tree
Hide file tree
Showing 4 changed files with 3,244 additions and 3,239 deletions.
7 changes: 4 additions & 3 deletions examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#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 @@ -35,22 +36,22 @@ class ModelCommand : public CHIPCommand
void AddArguments()
{
AddArgument("node-id", 0, UINT64_MAX, &mNodeId);
AddArgument("endpoint-id", 0, UINT16_MAX, &mEndPointId);
AddArgument("endpoint-id", CHIP_ZCL_ENDPOINT_MIN, CHIP_ZCL_ENDPOINT_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, chip::EndpointId endPointId) = 0;
virtual CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endPointId) = 0;

protected:
chip::Optional<uint16_t> mTimedInteractionTimeoutMs;

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

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

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

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

CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReadEvent ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReadEvent on endpoint %" PRIu8, 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, chip::EndpointId endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReportEvent ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReportEvent on endpoint %" PRIu8, 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, chip::EndpointId endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReadAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReadAttribute on endpoint %" PRIu8, 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, chip::EndpointId endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) WriteAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) WriteAttribute on endpoint %" PRIu8, 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, chip::EndpointId endpointId) override
CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReportAttribute ({{asHex code 8}}) on endpoint %" PRIu16, endpointId);
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 4}}) ReportAttribute on endpoint %" PRIu8, endpointId);

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

0 comments on commit 45a8add

Please sign in to comment.