Skip to content

Commit

Permalink
Add Diagnostic Logs template
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Jun 24, 2021
1 parent f209caf commit f70d00e
Show file tree
Hide file tree
Showing 19 changed files with 439 additions and 6 deletions.
26 changes: 26 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,32 @@
}
]
},
{
"name": "Diagnostic Logs",
"code": 50,
"mfgCode": null,
"define": "DIAGNOSTIC_LOGS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "RetrieveLogsRequest",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "RetrieveLogsResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
]
},
{
"name": "General Diagnostics",
"code": 51,
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-server"
Expand Down
28 changes: 27 additions & 1 deletion examples/bridge-app/bridge-common/bridge-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,32 @@
}
]
},
{
"name": "Diagnostic Logs",
"code": 50,
"mfgCode": null,
"define": "DIAGNOSTIC_LOGS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "RetrieveLogsRequest",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "RetrieveLogsResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
]
},
{
"name": "General Diagnostics",
"code": 51,
Expand Down Expand Up @@ -3256,4 +3282,4 @@
}
],
"log": []
}
}
92 changes: 92 additions & 0 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ static void OnThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeRespon
| ColorControl | 0x0300 |
| ContentLauncher | 0x050A |
| Descriptor | 0x001D |
| DiagnosticLogs | 0x0032 |
| DoorLock | 0x0101 |
| EthernetNetworkDiagnostics | 0x0037 |
| FixedLabel | 0x0040 |
Expand Down Expand Up @@ -1146,6 +1147,7 @@ constexpr chip::ClusterId kBridgedDeviceBasicClusterId = 0x0039;
constexpr chip::ClusterId kColorControlClusterId = 0x0300;
constexpr chip::ClusterId kContentLauncherClusterId = 0x050A;
constexpr chip::ClusterId kDescriptorClusterId = 0x001D;
constexpr chip::ClusterId kDiagnosticLogsClusterId = 0x0032;
constexpr chip::ClusterId kDoorLockClusterId = 0x0101;
constexpr chip::ClusterId kEthernetNetworkDiagnosticsClusterId = 0x0037;
constexpr chip::ClusterId kFixedLabelClusterId = 0x0040;
Expand Down Expand Up @@ -7749,6 +7751,84 @@ class ReadDescriptorClusterRevision : public ModelCommand
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*----------------------------------------------------------------------------*\
| Cluster DiagnosticLogs | 0x0032 |
|------------------------------------------------------------------------------|
| Commands: | |
| * RetrieveLogsRequest | 0x00 |
|------------------------------------------------------------------------------|
| Attributes: | |
\*----------------------------------------------------------------------------*/

/*
* Command RetrieveLogsRequest
*/
class DiagnosticLogsRetrieveLogsRequest : public ModelCommand
{
public:
DiagnosticLogsRetrieveLogsRequest() : ModelCommand("retrieve-logs-request")
{
AddArgument("intent", 0, UINT8_MAX, &mIntent);
AddArgument("requestedProtocol", 0, UINT8_MAX, &mRequestedProtocol);
AddArgument("transferFileDesignator", &mTransferFileDesignator);
ModelCommand::AddArguments();
}
~DiagnosticLogsRetrieveLogsRequest()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0032) command (0x00) on endpoint %" PRIu16, endpointId);

chip::Controller::DiagnosticLogsCluster cluster;
cluster.Associate(device, endpointId);
return cluster.RetrieveLogsRequest(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mIntent, mRequestedProtocol,
mTransferFileDesignator);
}

private:
chip::Callback::Callback<DefaultSuccessCallback> * onSuccessCallback =
new chip::Callback::Callback<DefaultSuccessCallback>(OnDefaultSuccessResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
uint8_t mIntent;
uint8_t mRequestedProtocol;
chip::ByteSpan mTransferFileDesignator;
};

/*
* Discover Attributes
*/
class DiscoverDiagnosticLogsAttributes : public ModelCommand
{
public:
DiscoverDiagnosticLogsAttributes() : ModelCommand("discover") { ModelCommand::AddArguments(); }

~DiscoverDiagnosticLogsAttributes()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x0C) on endpoint %" PRIu16, endpointId);

chip::Controller::DiagnosticLogsCluster cluster;
cluster.Associate(device, endpointId);
return cluster.DiscoverAttributes(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<DefaultSuccessCallback> * onSuccessCallback =
new chip::Callback::Callback<DefaultSuccessCallback>(OnDefaultSuccessResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*----------------------------------------------------------------------------*\
| Cluster DoorLock | 0x0101 |
|------------------------------------------------------------------------------|
Expand Down Expand Up @@ -21144,6 +21224,17 @@ void registerClusterDescriptor(Commands & commands)

commands.Register(clusterName, clusterCommands);
}
void registerClusterDiagnosticLogs(Commands & commands)
{
const char * clusterName = "DiagnosticLogs";

commands_list clusterCommands = {
make_unique<DiagnosticLogsRetrieveLogsRequest>(),
make_unique<DiscoverDiagnosticLogsAttributes>(),
};

commands.Register(clusterName, clusterCommands);
}
void registerClusterDoorLock(Commands & commands)
{
const char * clusterName = "DoorLock";
Expand Down Expand Up @@ -21756,6 +21847,7 @@ void registerClusters(Commands & commands)
registerClusterColorControl(commands);
registerClusterContentLauncher(commands);
registerClusterDescriptor(commands);
registerClusterDiagnosticLogs(commands);
registerClusterDoorLock(commands);
registerClusterEthernetNetworkDiagnostics(commands);
registerClusterFixedLabel(commands);
Expand Down
28 changes: 27 additions & 1 deletion examples/lighting-app/lighting-common/lighting-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,32 @@
}
]
},
{
"name": "Diagnostic Logs",
"code": 50,
"mfgCode": null,
"define": "DIAGNOSTIC_LOGS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "RetrieveLogsRequest",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "RetrieveLogsResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
]
},
{
"name": "General Diagnostics",
"code": 51,
Expand Down Expand Up @@ -4521,4 +4547,4 @@
}
],
"log": []
}
}
1 change: 1 addition & 0 deletions examples/lighting-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/StorablePeerConnection.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp
${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/StorablePeerConnection.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp
${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp
Expand Down
28 changes: 27 additions & 1 deletion examples/lock-app/lock-common/lock-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,32 @@
}
]
},
{
"name": "Diagnostic Logs",
"code": 50,
"mfgCode": null,
"define": "DIAGNOSTIC_LOGS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "RetrieveLogsRequest",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "RetrieveLogsResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
]
},
{
"name": "General Diagnostics",
"code": 51,
Expand Down Expand Up @@ -5162,4 +5188,4 @@
}
],
"log": []
}
}
1 change: 1 addition & 0 deletions examples/lock-app/nrfconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ target_sources(app PRIVATE
${CHIP_ROOT}/src/app/server/StorablePeerConnection.cpp
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp
${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp
Expand Down
28 changes: 27 additions & 1 deletion examples/pump-app/pump-common/pump-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,32 @@
}
]
},
{
"name": "Diagnostic Logs",
"code": 50,
"mfgCode": null,
"define": "DIAGNOSTIC_LOGS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "RetrieveLogsRequest",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "RetrieveLogsResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
]
},
{
"name": "General Diagnostics",
"code": 51,
Expand Down Expand Up @@ -4905,4 +4931,4 @@
}
],
"log": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,32 @@
}
]
},
{
"name": "Diagnostic Logs",
"code": 50,
"mfgCode": null,
"define": "DIAGNOSTIC_LOGS_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [
{
"name": "RetrieveLogsRequest",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "RetrieveLogsResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 0,
"outgoing": 1
}
]
},
{
"name": "General Diagnostics",
"code": 51,
Expand Down Expand Up @@ -4905,4 +4931,4 @@
}
],
"log": []
}
}
Loading

0 comments on commit f70d00e

Please sign in to comment.