Skip to content

Commit

Permalink
chip-tool arguments order is reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Oct 29, 2020
1 parent bd7042e commit 07e2fa1
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 63 deletions.
10 changes: 5 additions & 5 deletions examples/chip-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ pass it the discriminator and pairing code of the remote device. The command
below uses the default values hard-coded into the debug versions of the ESP32
wifi-echo app:

$ chip-tool echo ble 3840 12345678
$ chip-tool echo ble 12345678 3840

### Ping a device over IP

To start the Client in echo mode, run the built executable and pass it the IP
address and port of the server to talk to, as well as the command "echo".

$ chip-tool echo ip 192.168.0.30 8000
$ chip-tool echo ip 192.168.0.30 11095

If valid values are supplied, it will begin to periodically send messages to the
server address provided.
Expand All @@ -56,11 +56,11 @@ Stop the Client at any time with `Ctrl + C`.
## Using the Client to Send CHIP Commands

To use the Client to send a CHIP commands, run the built executable and pass it
the target cluster name, the target command name, an endpoint id as well as the
IP address and port of the server to talk to. The endpoint id must be between 1
the target cluster name, the target command name, the ip address and port of the
server to talk to as well as an endpoint id. The endpoint id must be between 1
and 240.

$ chip-tool onoff on 1 192.168.0.30 11095
$ chip-tool onoff on 192.168.0.30 11095 1

The client will send a single command packet and then exit.

Expand Down
321 changes: 276 additions & 45 deletions examples/chip-tool/commands/clusters/Commands.h

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ size_t Command::AddArgument(const char * name, const char * value)
arg.name = name;
arg.value = const_cast<void *>(reinterpret_cast<const void *>(value));

mArgs.emplace(mArgs.begin(), arg);
mArgs.emplace_back(arg);
return mArgs.size();
}

Expand All @@ -190,7 +190,7 @@ size_t Command::AddArgument(const char * name, char ** value)
arg.name = name;
arg.value = reinterpret_cast<void *>(value);

mArgs.emplace(mArgs.begin(), arg);
mArgs.emplace_back(arg);
return mArgs.size();
}

Expand All @@ -201,7 +201,7 @@ size_t Command::AddArgument(const char * name, AddressWithInterface * out)
arg.name = name;
arg.value = reinterpret_cast<void *>(out);

mArgs.emplace(mArgs.begin(), arg);
mArgs.emplace_back(arg);
return mArgs.size();
}

Expand All @@ -214,7 +214,7 @@ size_t Command::AddArgument(const char * name, int64_t min, int64_t max, void *
arg.min = min;
arg.max = max;

mArgs.emplace(mArgs.begin(), arg);
mArgs.emplace_back(arg);
return mArgs.size();
}

Expand All @@ -227,7 +227,7 @@ size_t Command::AddArgument(const char * name, int64_t min, int64_t max, void *
arg.min = min;
arg.max = max;

mArgs.emplace(mArgs.begin(), arg);
mArgs.emplace_back(arg);
return mArgs.size();
}

Expand Down
4 changes: 4 additions & 0 deletions examples/chip-tool/commands/common/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class ModelCommand : public NetworkCommand
public:
ModelCommand(const char * commandName, uint16_t clusterId, uint8_t commandId) :
NetworkCommand(commandName, NetworkType::UDP), mClusterId(clusterId), mCommandId(commandId)
{}

void AddArguments()
{
NetworkCommand::AddArguments();
AddArgument("endpoint-id", CHIP_ZCL_ENDPOINT_MIN, CHIP_ZCL_ENDPOINT_MAX, &mEndPointId);
}

Expand Down
10 changes: 6 additions & 4 deletions examples/chip-tool/commands/common/NetworkCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ enum NetworkType
class NetworkCommand : public Command
{
public:
NetworkCommand(const char * commandName, NetworkType type) : Command(commandName), mNetworkType(type)
NetworkCommand(const char * commandName, NetworkType type) : Command(commandName), mNetworkType(type) {}

void AddArguments()
{
if (type == NetworkType::UDP || type == NetworkType::ALL)
if (mNetworkType == NetworkType::UDP || mNetworkType == NetworkType::ALL)
{
AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort);
AddArgument("device-remote-ip", &mRemoteAddr);
AddArgument("device-remote-port", 0, UINT16_MAX, &mRemotePort);
}

if (type == NetworkType::BLE || type == NetworkType::ALL)
if (mNetworkType == NetworkType::BLE || mNetworkType == NetworkType::ALL)
{
AddArgument("setup-pin-code", 0, 134217727, &mSetupPINCode);
AddArgument("discriminator", 0, 4096, &mDiscriminator);
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/echo/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
class Echo : public EchoCommand
{
public:
Echo() : EchoCommand("ip", NetworkType::UDP) {}
Echo() : EchoCommand("ip", NetworkType::UDP) { NetworkCommand::AddArguments(); }
};

class EchoBle : public EchoCommand
{
public:
EchoBle() : EchoCommand("ble", NetworkType::BLE) {}
EchoBle() : EchoCommand("ble", NetworkType::BLE) { NetworkCommand::AddArguments(); }
};

void registerCommandsEcho(Commands & commands)
Expand Down
4 changes: 2 additions & 2 deletions src/test_driver/linux-cirque/test-on-off-cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def run_data_model_test(self):

for ip in server_ip_address:
output = self.execute_device_cmd(
tool_device_id, "chip-tool onoff on 1 {} {}".format(ip, CHIP_PORT))
tool_device_id, "chip-tool onoff on {} {} 1".format(ip, CHIP_PORT))
self.logger.info(
'checking output does not contain "No response from device"')
self.assertFalse(self.sequenceMatch(
output['output'], ["No response from device."]))
time.sleep(1)
for ip in server_ip_address:
output = self.execute_device_cmd(
tool_device_id, "chip-tool onoff off 1 {} {}".format(ip, CHIP_PORT))
tool_device_id, "chip-tool onoff off {} {} 1".format(ip, CHIP_PORT))
self.logger.info(
'checking output does not contain "No response from device"')
self.assertFalse(self.sequenceMatch(
Expand Down

0 comments on commit 07e2fa1

Please sign in to comment.