Skip to content

Commit

Permalink
Convert 'echo' command to a manufacturer specific 'ping' command
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Dec 11, 2020
1 parent 27d3ea8 commit d1054f3
Show file tree
Hide file tree
Showing 26 changed files with 612 additions and 783 deletions.
78 changes: 43 additions & 35 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"writeTime": "Wed Nov 18 2020 10:23:41 GMT+0100 (Central European Standard Time)",
"featureLevel": 4,
"writeTime": "Tue Dec 08 2020 13:12:25 GMT+0100 (Central European Standard Time)",
"featureLevel": 5,
"creator": "zap",
"keyValuePairs": [
{
Expand Down Expand Up @@ -33,9 +33,9 @@
"endpointTypes": [
{
"name": "Anonymous Endpoint Type",
"deviceTypeName": null,
"deviceTypeCode": null,
"deviceTypeProfileId": null,
"deviceTypeName": "CHIP-All-Clusters-Server",
"deviceTypeCode": "0x0000",
"deviceTypeProfileId": "0x0103",
"clusters": [
{
"name": "Basic",
Expand All @@ -52,6 +52,14 @@
"source": "client",
"incoming": 1,
"outgoing": 1
},
{
"name": "MfgSpecificPing",
"code": 0,
"mfgCode": "0x1002",
"source": "client",
"incoming": 1,
"outgoing": 1
}
],
"attributes": [
Expand Down Expand Up @@ -79,6 +87,7 @@
"define": "BASIC_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "cluster revision",
Expand Down Expand Up @@ -125,8 +134,7 @@
"maxInterval": 65344,
"reportableChange": 0
}
],
"commands": []
]
},
{
"name": "Identify",
Expand All @@ -135,6 +143,23 @@
"define": "IDENTIFY_CLUSTER",
"side": "client",
"enabled": 1,
"attributes": [
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "client",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
],
"commands": [
{
"name": "Identify",
Expand All @@ -152,23 +177,6 @@
"incoming": 1,
"outgoing": 1
}
],
"attributes": [
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "client",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
Expand All @@ -178,16 +186,6 @@
"define": "IDENTIFY_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "IdentifyQueryResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 1,
"outgoing": 1
}
],
"attributes": [
{
"name": "cluster revision",
Expand Down Expand Up @@ -219,6 +217,16 @@
"maxInterval": 65344,
"reportableChange": 0
}
],
"commands": [
{
"name": "IdentifyQueryResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 1,
"outgoing": 1
}
]
},
{
Expand Down Expand Up @@ -2822,4 +2830,4 @@
"networkId": 1
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,14 @@ EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd)
{
bool wasHandled = false;

if (!cmd->mfgSpecific)
if (cmd->mfgSpecific)
{
if (cmd->mfgCode == 0x1002 && cmd->commandId == ZCL_MFG_SPECIFIC_PING_COMMAND_ID)
{
wasHandled = emberAfBasicClusterMfgSpecificPingCallback();
}
}
else
{
switch (cmd->commandId)
{
Expand Down
6 changes: 6 additions & 0 deletions examples/all-clusters-app/all-clusters-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,12 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(uint8_t perce

bool emberAfBarrierControlClusterBarrierControlStopCallback();

/**
* @brief Basic Cluster MfgSpecificPing Command callback
*/

bool emberAfBasicClusterMfgSpecificPingCallback();

/**
* @brief Basic Cluster ResetToFactoryDefaults Command callback
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

// Commands for cluster: Basic
#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00)
#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00)

// Commands for cluster: Identify
#define ZCL_IDENTIFY_COMMAND_ID (0x00)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@
// Generated data for the command discovery
#define GENERATED_COMMANDS \
{ \
{ 0x0000, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Basic / ResetToFactoryDefaults */ \
{ 0x0003, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Identify / Identify */ \
{ 0x0000, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Basic / ResetToFactoryDefaults */ \
{ 0x0000, 0x00, COMMAND_MASK_INCOMING_SERVER | COMMAND_MASK_MANUFACTURER_SPECIFIC }, /* Basic / MfgSpecificPing */ \
{ 0x0003, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Identify / Identify */ \
{ 0x0003, 0x00, COMMAND_MASK_OUTGOING_SERVER | COMMAND_MASK_INCOMING_CLIENT }, /* Identify / IdentifyQueryResponse */ \
{ 0x0003, 0x01, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Identify / IdentifyQuery */ \
{ 0x0004, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Groups / AddGroup */ \
Expand Down Expand Up @@ -592,16 +593,16 @@
{ 0x0B03, 0x02, COMMAND_MASK_INCOMING_CLIENT }, /* Appliance Statistics / LogQueueResponse */ \
{ 0x0B03, 0x03, COMMAND_MASK_INCOMING_CLIENT }, /* Appliance Statistics / StatisticsAvailable */ \
}
#define EMBER_AF_GENERATED_COMMAND_COUNT (160)
#define EMBER_AF_GENERATED_COMMAND_COUNT (161)

// Command manufacturer codes
#define GENERATED_COMMAND_MANUFACTURER_CODES \
{ \
{ \
0x00, 0x00 \
0x01, 0x1002 \
} \
}
#define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (0)
#define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (1)

// Generated reporting configuration defaults
#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS \
Expand Down
7 changes: 7 additions & 0 deletions examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "gen/attribute-id.h"
#include "gen/cluster-id.h"
#include <app/util/basic-types.h>
#include <app/util/util.h>
#include <lib/mdns/Advertiser.h>
#include <support/CodeUtils.h>

Expand Down Expand Up @@ -167,3 +168,9 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI
exit:
return;
}

bool emberAfBasicClusterMfgSpecificPingCallback(void)
{
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
return true;
}
6 changes: 6 additions & 0 deletions examples/all-clusters-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId
uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value)
{}

bool emberAfBasicClusterMfgSpecificPingCallback(void)
{
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
return true;
}

int main(int argc, char * argv[])
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down
2 changes: 0 additions & 2 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ executable("chip-tool") {
"commands/clusters/ModelCommand.cpp",
"commands/common/Command.cpp",
"commands/common/Commands.cpp",
"commands/common/NetworkCommand.cpp",
"commands/echo/EchoCommand.cpp",
"commands/pairing/PairingCommand.cpp",
"commands/payload/ParseCommand.cpp",
"config/PersistentStorage.cpp",
Expand Down
9 changes: 0 additions & 9 deletions examples/chip-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ the ESP32 all-clusters-app:

$ chip-tool pairing unpair

## Using the Client to Request an Echo

### Ping a device

$ chip-tool echo ip

If valid values are supplied, it will send a message to the paired device and
verify that the incoming echo from the server matches what was sent out.

## Using the Client to Send CHIP Commands

To use the Client to send a CHIP commands, run the built executable and pass it
Expand Down
28 changes: 24 additions & 4 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ class ReadBarrierControlBarrierPosition : public ModelCommand
|------------------------------------------------------------------------------|
| Commands: | |
| * ResetToFactoryDefaults | 0x00 |
| * MfgSpecificPing | 0x00 |
|------------------------------------------------------------------------------|
| Attributes: | |
| * ZclVersion | 0x0000 |
Expand Down Expand Up @@ -1128,6 +1129,27 @@ class BasicResetToFactoryDefaults : public ModelCommand
}
};

/*
* Command MfgSpecificPing
*/
class BasicMfgSpecificPing : public ModelCommand
{
public:
BasicMfgSpecificPing() : ModelCommand("ping", kBasicClusterId, 0x00) { ModelCommand::AddArguments(); }

uint16_t EncodeCommand(const PacketBufferHandle & buffer, uint16_t bufferSize, uint8_t endPointId) override
{
return encodeBasicClusterMfgSpecificPingCommand(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);
}
};

/*
* Discover attributes
*/
Expand Down Expand Up @@ -6457,10 +6479,8 @@ void registerClusterBasic(Commands & commands)
const char * clusterName = "Basic";

commands_list clusterCommands = {
make_unique<BasicResetToFactoryDefaults>(),
make_unique<DiscoverBasicAttributes>(),
make_unique<ReadBasicZclVersion>(),
make_unique<ReadBasicPowerSource>(),
make_unique<BasicResetToFactoryDefaults>(), make_unique<BasicMfgSpecificPing>(), make_unique<DiscoverBasicAttributes>(),
make_unique<ReadBasicZclVersion>(), make_unique<ReadBasicPowerSource>(),
};

commands.Register(clusterName, clusterCommands);
Expand Down
Loading

0 comments on commit d1054f3

Please sign in to comment.