From 3d9fc15e2e766e37d0eb510bd2d8a5b080057844 Mon Sep 17 00:00:00 2001 From: eve-cxrp <80681009+eve-cxrp@users.noreply.github.com> Date: Sat, 3 Jul 2021 04:16:15 +0200 Subject: [PATCH] support for electrical measurement cluster (#7953) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add electrical measurement cluster to controller-clusters.zap Only a selection of the optional clusters is enabled. mandatory: - measurement type optional: - total active power - rms voltage - rms voltage min - rms voltage max - rms current - rms current min - rms current max - active power - active power min - active power max * add electrical measurement cluster to zap_cluster_list.py * add electrical measurement cluster to all-clusters-app * add electrical measurement cluster to all-cluster-app/esp32 * add app helpers for electrical measurement cluster * fix all cluster app build * regen all * Regenerating * Restyled by whitespace * Restyled by clang-format * Regenerating * Restyled by whitespace * Restyled by google-java-format * [fix] Wrong callback passed to WriteAttribute in Python[TE4] (#8019) * Fix callback typr * Run codegen * Mdns: _chip* -> _matter*, remove 0's on subtypes (#7805) * Mdns: _chip* i-> _matter*, remove 0's on subtypes The second ballot changed the format of the subtypes as well as fixed the service name prefix from _chip* to _matter*. NOTE FOR DEVs: Updating past this change will require updating the devices and controllers as otherwise they will be unable to find each other. * Darwin - use local kLocalDomain var. It includes a . and the one in the ServiceNaming doesn't. * Trying again for Darwin. * Fix host name. * Fix small error on merge * Use a dedicated chip-types.xml file into src/app/zap-templates/zcl (#7873) * Update chip-types.xml * Update gen/ folders * Revert "Mark UDP socket as ready for write in send msg. (#7927)" (#8027) Turns out the code causes that subsequent select()-s never wait so another solution for the original issue must be prepared. This reverts commit 8c555239212ca31160df633fa1e68c5a3c46852b. * [ZAP] Add isAnalog instead of isDiscreteType to account for string types (#7821) * Mdns: separate query responders for advertisers (#7615) * Mdns: separate query responders for advertisers The current setup uses a single query responder for commissionable and operational and all the records are cleared together and added in a large group. This makes it challenging to run commissionable and operational at the same time since they can't be cleared individually and because there are duplicate records between operational and commissionable. This commit changes the code to use one query responder per advertisement type and gets the ResponseSender to loop through the query responders to filter for answers. * Apply suggestions from code review Co-authored-by: chrisdecenzo <61757564+chrisdecenzo@users.noreply.github.com> * Restyled by clang-format * Fix tests - they were not testing right. * Restyled by clang-format * Update number of responders Represents 5 multi-admin fabrics for operational, commissionable and commissioner. * Whoops - broke a test with my last "minor" change. * Lighten the stack load for the failing test. Co-authored-by: chrisdecenzo <61757564+chrisdecenzo@users.noreply.github.com> Co-authored-by: Restyled.io * [nrfconnect] Stop using cooperative threads (#8025) nRF Connect platform used cooperative threads, that is threads that cannot be preempted, to workaround some synchronization issues in the past, but it's no longer needed and is risky. The latter was revealed by #7927, which caused that `select()` never waits (needs to be fixed in another PR). Signed-off-by: Damian Krolik * IPV6-only test app for esp32 (examples/ipv6only-app) (#7289) Adds RPCs that conform to NDM/GDM WiFi capabilities. Disables IPV4 DHCP client. Assigns link-local IPV6 address. Starts a UDP echo server on an IPV6 UDP socket. Test: Ran on M5Stack and verified it scanned and connected to wifi, after connected verified it echoed UDP messages. * [ESP32] fix compile error for persistent-storage app (#7940) * [ESP32] fix compile error for persistent-storage app * add CI for all ESP examples * Consolidate error types (#7916) * Consolidate error types #### Problem CHIP currently has `CHIP_ERROR`, `INET_ERROR`, `BLE_ERROR`, `ASN1_ERROR`, `System::Error`. Since they're all integers underneath, there is no type checking, and existing code routinely treats them as interchangeable. There is also existing code that uses `int` and `int32_t`. Each also has a `…_NO_ERROR` code which is independently configurable, but existing code assumes they are equal, and there is exising code that assumes the C convention that the value is 0. #### Change overview Fixes #7688 Unify chip errors This change is largely a mechanical replacement of type and some error code names, with a few cleanups of weak typing. Consolidated error types to one, `CHIP_ERROR`. Removed configurability of `CHIP_NO_ERROR`; it must be 0. Added `CHIP_ERROR_FORMAT` to replace hardcoded `PRI…32` in `printf()` format strings. Added `CHIP_ERROR_SENTINEL` to replace the use of `CHIP_ERROR_MAX` as a sentinel. Renamed or consolidated the following errors, which have the same meaning. Merely similar codes are left alone. This change contains compatibility defintitions to avoid breaking PRs in flight, which will be removed in a followup. | before | after | |:---------------------------------------|:------------------------------------| | ASN1_ERROR | CHIP_ERROR | | ASN1_NO_ERROR | CHIP_NO_ERROR | | BLE_ERROR | CHIP_ERROR | | BLE_NO_ERROR | CHIP_NO_ERROR | | BLE_ERROR_BAD_ARGS | CHIP_ERROR_INVALID_ARGUMENT | | BLE_ERROR_INCORRECT_STATE | CHIP_ERROR_INCORRECT_STATE | | BLE_ERROR_MESSAGE_INCOMPLETE | CHIP_ERROR_MESSAGE_INCOMPLETE | | BLE_ERROR_NOT_IMPLEMENTED | CHIP_ERROR_NOT_IMPLEMENTED | | BLE_ERROR_NO_ENDPOINTS | CHIP_ERROR_ENDPOINT_POOL_FULL | | BLE_ERROR_NO_MEMORY | CHIP_ERROR_NO_MEMORY | | BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG | CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG | | BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG | | CHIP_SYSTEM_NO_ERROR | CHIP_NO_ERROR | | CHIP_SYSTEM_ERROR_ACCESS_DENIED | CHIP_ERROR_ACCESS_DENIED | | CHIP_SYSTEM_ERROR_BAD_ARGS | CHIP_ERROR_INVALID_ARGUMENT | | CHIP_SYSTEM_ERROR_NOT_SUPPORTED | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE | | CHIP_SYSTEM_ERROR_NO_MEMORY | CHIP_ERROR_NO_MEMORY | | CHIP_SYSTEM_ERROR_REAL_TIME_NOT_SYNCED | CHIP_ERROR_REAL_TIME_NOT_SYNCED | | CHIP_SYSTEM_ERROR_UNEXPECTED_EVENT | CHIP_ERROR_UNEXPECTED_EVENT | | CHIP_SYSTEM_ERROR_UNEXPECTED_STATE | CHIP_ERROR_INCORRECT_STATE | | INET_ERROR | CHIP_ERROR | | INET_NO_ERROR | CHIP_NO_ERROR | | INET_ERROR_BAD_ARGS | CHIP_ERROR_INVALID_ARGUMENT | | INET_ERROR_INBOUND_MESSAGE_TOO_BIG | CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG | | INET_ERROR_INCORRECT_STATE | CHIP_ERROR_INCORRECT_STATE | | INET_ERROR_MESSAGE_TOO_LONG | CHIP_ERROR_MESSAGE_TOO_LONG | | INET_ERROR_NO_CONNECTION_HANDLER | CHIP_ERROR_NO_CONNECTION_HANDLER | | INET_ERROR_NO_ENDPOINTS | CHIP_ERROR_ENDPOINT_POOL_FULL | | INET_ERROR_NOT_IMPLEMENTED | CHIP_ERROR_NOT_IMPLEMENTED | | INET_ERROR_NOT_SUPPORTED | CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE | | INET_ERROR_NO_MEMORY | CHIP_ERROR_NO_MEMORY | | INET_ERROR_CONNECTION_ABORTED | CHIP_ERROR_CONNECTION_ABORTED | #### Testing Modified some unit tests to account for consolidated error codes. Built locally with `CHIP_ERROR` hardcoded to `int32_t`, `uint32_t`, `int16_t`, and `uint16_t` to shake out mistaken type assumptions. * Build fixes * Darwin * Doxygen * Fixes * Change default CHIP_CONFIG_ERROR_TYPE back to `int32_t`. * Fix CHIP_ERROR_INBOUND_MESSAGE_TOO_BIG message text. * C++-style casts. * fix: CHIPError.h uses stdint.h * zap * fix for Mbed merge * Throw exception instead of return 0 for get-fabricid in case of error (#7884) * Implement User Directed Commissioning - Phase 1 (#8034) * Updated CHIP Certs Implementation to Use Spans instaed of Pointer/Len Pairs. (#7599) Specifically, added the following FixedSpan types: - CertificateKeyId - P256ECDSASignatureSpan - P256PublicKeySpan Also redefined mString member in the ChipRDN structure to be ByteSpan. * Zap use const expr for clusters commands attributes (#7946) * Remove duplicated command ids and attribute ids definitions from the encoder-src.zapt template Add ids/Commands.zapt template Update template to use Commands.h and Clusters.h * Fix XML definitions typos for attributes name * Add ids/Commands.h to the gen folder of src/app/common * Update log messages for session expiry (#8017) * Update log messages for session expiry * update format specifier * Remove client-command-macro.h-aa80d825 from examples/bridge-app/bridge-common/gen (#8026) * Fix Ble endpoint pool FULL on macOS controller (#7806) * * Move naming qpg6100 to qpg (#7936) * Removal Env overrides sdk root and target IC * fix build error in TCP.cpp (#8072) Include to satisfy the proper use of std::numeric_limits. * Add lighting example for Mbed OS (#8048) * Add back structs, bitmaps and enums of the Messaging cluster into ami… (#8061) * Add back structs, bitmaps and enums of the Messaging cluster into ami.xml * Update gen/ folders * Deprecated ASN1Writer::Finalize() Method. (#8056) * Split KeyValueStoreManager.java into interface and impl, and add Set() in JNI. (#8046) * [Test] Add Test_TC_DM_3_1 (#8067) * Add Test_TC_DM_3_1 to src/app/tests/suites with all tests disabled since the attributes are not present into commissioning.xml * Update generated tests * Followup #7873 - Replace emberAfPutInt8uInResp(ZCL_DEFAULT_RESPONSE_COMMAND_ID) by emberAfPutInt32uInResp(ZCL_DEFAULT_RESPONSE_COMMAND_ID) in src/app/util/util.cpp (#8060) * Remove call-command-handler.cpp from src/controller/data_model/gen/ and from src/darwin/Framework/CHIP.xcodeproj/project.pbxproj (#8021) * Add PID to Darwin/Linux Log Lines (#7657) * Add PID to Darwin/Linux Log Lines Problem: - Debugging test failures that involve multiple instances of applications is difficult when the log lines don't indicate which process/application they're coming from. Solution: - Added PID to the log lines on Darwin & Linux minimally to aid in debugging. Testing: - Ran chip-tool on both platforms. * Restyled by clang-format Co-authored-by: Restyled.io * Update Darwin framework to use GetConnectedDevice (#8011) * Update Darwin framework to use GetConnectedDevice * address review comments * Add a string circular buffer. (#7475) * Add a string circular buffer. * Update src/lib/support/StringCircularBuffer.cpp Co-authored-by: Boris Zbarsky * Update src/lib/support/StringCircularBuffer.cpp Co-authored-by: Boris Zbarsky * Update src/lib/support/StringCircularBuffer.cpp Co-authored-by: Boris Zbarsky * Resolve comments * Resolve comments * Resolve comments * Resolve comments Co-authored-by: Justin Wood Co-authored-by: Boris Zbarsky * [lighting-app] Enable optional Basic Cluster attributes (#8083) * [lighting-app] Enable optional Basic Cluster attributes Enable optional Basic Cluster attributes as requested by Chaintanya, to verify a proper behaviour of the Python controller. * Re-gen code * Add GenerateEventPathList and test (#8014) Summary of Changes: -- Add GenerateEventPathList function in ReadClinet -- Add one event path test and two event path test -- Fix im e2e cirque test in chip_im_responder from PR 7634 since cirque test is not enabled * Have a single loopback transport implementation for tests. (#8045) We have multiple, some with different bells and whistles. Should have one shared thing. Unfortunately, some consumers want to drive things off the loopback (like resending reliable messages) that other consumers can't know about because they are at lower layers of the stack. We just use a virtual hook for that for now. * Don't treat a resolve as done in chip-device-ctrl until we have a CASE connection. (#8012) This ensures that following commands will work instead of racing the CASE connection setup. * Regenerating * Restyled by whitespace * Restyled by google-java-format * Regenerating Co-authored-by: Justin Wood Co-authored-by: Restyled.io Co-authored-by: Song Guo Co-authored-by: C Freeman Co-authored-by: Vivien Nicolas Co-authored-by: Damian Królik <66667989+Damian-Nordic@users.noreply.github.com> Co-authored-by: chrisdecenzo <61757564+chrisdecenzo@users.noreply.github.com> Co-authored-by: rgoliver Co-authored-by: Wang Qixiang <43193572+wqx6@users.noreply.github.com> Co-authored-by: Kevin Schoedel <67607049+kpschoedel@users.noreply.github.com> Co-authored-by: Yufeng Wang Co-authored-by: Evgeny Margolis Co-authored-by: Pankaj Garg Co-authored-by: krypton36 Co-authored-by: Timothy Maes Co-authored-by: CodeChronos <1197535+CodeChronos928@users.noreply.github.com> Co-authored-by: Vincent Coubard Co-authored-by: Austin Hsieh <77706079+austinh0@users.noreply.github.com> Co-authored-by: Jerry Johns Co-authored-by: Zang MingJie Co-authored-by: Boris Zbarsky Co-authored-by: yunhanw-google --- .../all-clusters-common/all-clusters-app.zap | 217 ++++++++ .../all-clusters-common/gen/callback-stub.cpp | 8 + .../all-clusters-common/gen/callback.h | 79 +++ .../all-clusters-common/gen/endpoint_config.h | 49 +- .../all-clusters-common/gen/gen_config.h | 6 + .../esp32/main/CMakeLists.txt | 1 + .../chip-tool/commands/clusters/Commands.h | 477 ++++++++++++++++++ .../electrical-measurement-server.cpp | 138 +++++ .../electrical-measurement-server.h | 44 ++ src/app/zap_cluster_list.py | 2 + .../data_model/controller-clusters.zap | 217 ++++++++ .../data_model/gen/CHIPClusters.cpp | 153 ++++++ src/controller/data_model/gen/CHIPClusters.h | 23 + .../data_model/gen/callback-stub.cpp | 8 + src/controller/data_model/gen/callback.h | 79 +++ .../data_model/gen/chip-zcl-zpro-codec-api.h | 112 ++++ src/controller/data_model/gen/encoder.cpp | 184 +++++++ .../data_model/gen/endpoint_config.h | 18 +- src/controller/data_model/gen/gen_config.h | 5 + src/controller/java/gen/CHIPClusters-JNI.cpp | 9 + src/controller/java/gen/ChipClusters.java | 9 + .../python/chip/clusters/CHIPClusters.cpp | 120 +++++ .../python/chip/clusters/CHIPClusters.py | 113 +++++ .../Framework/CHIP/gen/CHIPClustersObjc.h | 21 + .../Framework/CHIP/gen/CHIPClustersObjc.mm | 337 +++++++++++++ .../Framework/CHIPTests/CHIPClustersTests.m | 228 +++++++++ 26 files changed, 2643 insertions(+), 14 deletions(-) create mode 100644 src/app/clusters/electrical-measurement-server/electrical-measurement-server.cpp create mode 100644 src/app/clusters/electrical-measurement-server/electrical-measurement-server.h diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 2c30d594e95359..9c66167340e9de 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -12886,6 +12886,223 @@ } ] }, + { + "name": "Electrical Measurement", + "code": 2820, + "mfgCode": null, + "define": "ELECTRICAL_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Electrical Measurement", + "code": 2820, + "mfgCode": null, + "define": "ELECTRICAL_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "measurement type", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "total active power", + "code": 772, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms voltage", + "code": 1285, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms voltage min", + "code": 1286, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x8000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms voltage max", + "code": 1287, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x8000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms current", + "code": 1288, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms current min", + "code": 1289, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms current max", + "code": 1290, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "active power", + "code": 1291, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "active power min", + "code": 1292, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "active power max", + "code": 1293, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "Binding", "code": 61440, diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp index 535dd2782e5849..6af3f34bcfc839 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp @@ -71,6 +71,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_DOOR_LOCK_CLUSTER_ID: emberAfDoorLockClusterInitCallback(endpoint); break; + case ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID: + emberAfElectricalMeasurementClusterInitCallback(endpoint); + break; case ZCL_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_ID: emberAfEthernetNetworkDiagnosticsClusterInitCallback(endpoint); break; @@ -249,6 +252,11 @@ void __attribute__((weak)) emberAfDoorLockClusterInitCallback(EndpointId endpoin // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfElectricalMeasurementClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfEthernetNetworkDiagnosticsClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index b2749f5a762a4f..201780d7570322 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -152,6 +152,14 @@ void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint); */ void emberAfDoorLockClusterInitCallback(chip::EndpointId endpoint); +/** @brief Electrical Measurement Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalMeasurementClusterInitCallback(chip::EndpointId endpoint); + /** @brief Ethernet Network Diagnostics Cluster Init * * Cluster Init @@ -1405,6 +1413,77 @@ EmberAfStatus emberAfDoorLockClusterServerPreAttributeChangedCallback(chip::Endp */ void emberAfDoorLockClusterServerTickCallback(chip::EndpointId endpoint); +// +// Electrical Measurement Cluster server +// + +/** @brief Electrical Measurement Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalMeasurementClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Electrical Measurement Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfElectricalMeasurementClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Electrical Measurement Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfElectricalMeasurementClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Electrical Measurement Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param destination The destination to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfElectricalMeasurementClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Electrical Measurement Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfElectricalMeasurementClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, + uint16_t size, uint8_t * value); + +/** @brief Electrical Measurement Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfElectricalMeasurementClusterServerTickCallback(chip::EndpointId endpoint); + // // Ethernet Network Diagnostics Cluster server // diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 438b4de31f81ab..74329f223db2cd 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -891,6 +891,14 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 1, Cluster: Electrical Measurement (server), big-endian */ \ + \ + /* 9400 - measurement type, */ \ + 0x00, 0x00, 0x00, 0x00, \ + \ + /* 9404 - total active power, */ \ + 0x00, 0x00, 0x00, 0x00, \ } #else // !BIGENDIAN_CPU @@ -1761,11 +1769,19 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 1, Cluster: Electrical Measurement (server), little-endian */ \ + \ + /* 9400 - measurement type, */ \ + 0x00, 0x00, 0x00, 0x00, \ + \ + /* 9404 - total active power, */ \ + 0x00, 0x00, 0x00, 0x00, \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (122) +#define GENERATED_DEFAULTS_COUNT (124) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -1793,7 +1809,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 344 +#define GENERATED_ATTRIBUTE_COUNT 356 #define GENERATED_ATTRIBUTES \ { \ \ @@ -2250,6 +2266,20 @@ ZAP_LONG_DEFAULTS_INDEX(8400) }, /* long_octet_string */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Electrical Measurement (server) */ \ + { 0x0000, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(9400) }, /* measurement type */ \ + { 0x0304, ZAP_TYPE(INT32S), 4, 0, ZAP_LONG_DEFAULTS_INDEX(9404) }, /* total active power */ \ + { 0x0505, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* rms voltage */ \ + { 0x0506, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x8000) }, /* rms voltage min */ \ + { 0x0507, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x8000) }, /* rms voltage max */ \ + { 0x0508, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* rms current */ \ + { 0x0509, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* rms current min */ \ + { 0x050A, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* rms current max */ \ + { 0x050B, ZAP_TYPE(INT16S), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* active power */ \ + { 0x050C, ZAP_TYPE(INT16S), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* active power min */ \ + { 0x050D, ZAP_TYPE(INT16S), 2, 0, ZAP_SIMPLE_DEFAULT(0xffff) }, /* active power max */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: Binding (server) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ @@ -2308,7 +2338,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 52 +#define GENERATED_CLUSTER_COUNT 53 #define GENERATED_CLUSTERS \ { \ { \ @@ -2492,16 +2522,19 @@ 0x050F, ZAP_ATTRIBUTE_INDEX(316), 21, 1579, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (server) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(337), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0B04, ZAP_ATTRIBUTE_INDEX(337), 12, 28, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Electrical Measurement (server) */ \ + { \ + 0xF000, ZAP_ATTRIBUTE_INDEX(349), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binding (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(338), \ + ZAP_ATTRIBUTE_INDEX(350), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ { 0x0406, \ - ZAP_ATTRIBUTE_INDEX(340), \ + ZAP_ATTRIBUTE_INDEX(352), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -2513,7 +2546,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 15, 3560 }, { ZAP_CLUSTER_INDEX(15), 35, 6201 }, { ZAP_CLUSTER_INDEX(50), 2, 8 }, \ + { ZAP_CLUSTER_INDEX(0), 15, 3560 }, { ZAP_CLUSTER_INDEX(15), 36, 6229 }, { ZAP_CLUSTER_INDEX(51), 2, 8 }, \ } // Largest attribute size is needed for various buffers @@ -2523,7 +2556,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (1497) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (9769) +#define ATTRIBUTE_MAX_SIZE (9797) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (3) diff --git a/examples/all-clusters-app/all-clusters-common/gen/gen_config.h b/examples/all-clusters-app/all-clusters-common/gen/gen_config.h index 4da835d338f5e4..cdac200c3f6a09 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/gen_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/gen_config.h @@ -43,6 +43,7 @@ #define EMBER_AF_DESCRIPTOR_CLUSTER_SERVER_ENDPOINT_COUNT (2) #define EMBER_AF_DIAGNOSTIC_LOGS_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_DOOR_LOCK_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_ELECTRICAL_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_FIXED_LABEL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_FLOW_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -154,6 +155,11 @@ #define EMBER_AF_PLUGIN_DOOR_LOCK_SERVER #define EMBER_AF_PLUGIN_DOOR_LOCK +// Use this macro to check if the server side of the Electrical Measurement cluster is included +#define ZCL_USING_ELECTRICAL_MEASUREMENT_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ELECTRICAL_MEASUREMENT_SERVER +#define EMBER_AF_PLUGIN_ELECTRICAL_MEASUREMENT + // Use this macro to check if the server side of the Ethernet Network Diagnostics cluster is included #define ZCL_USING_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ETHERNET_NETWORK_DIAGNOSTICS_SERVER diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index c50bf6e7b06cef..1124c7077833e1 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -63,6 +63,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/relative-humidity-measurement-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-measurement-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/pump-configuration-and-control-server" #${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ias-zone-client ) diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index 88032120ce9dfa..d95f83e4e87274 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -1103,6 +1103,7 @@ static void OnThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeRespon | Descriptor | 0x001D | | DiagnosticLogs | 0x0032 | | DoorLock | 0x0101 | +| ElectricalMeasurement | 0x0B04 | | EthernetNetworkDiagnostics | 0x0037 | | FixedLabel | 0x0040 | | FlowMeasurement | 0x0404 | @@ -1151,6 +1152,7 @@ constexpr chip::ClusterId kContentLauncherClusterId = 0x050A; constexpr chip::ClusterId kDescriptorClusterId = 0x001D; constexpr chip::ClusterId kDiagnosticLogsClusterId = 0x0032; constexpr chip::ClusterId kDoorLockClusterId = 0x0101; +constexpr chip::ClusterId kElectricalMeasurementClusterId = 0x0B04; constexpr chip::ClusterId kEthernetNetworkDiagnosticsClusterId = 0x0037; constexpr chip::ClusterId kFixedLabelClusterId = 0x0040; constexpr chip::ClusterId kFlowMeasurementClusterId = 0x0404; @@ -8918,6 +8920,464 @@ class ReadDoorLockClusterRevision : public ModelCommand new chip::Callback::Callback(OnDefaultFailureResponse, this); }; +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalMeasurement | 0x0B04 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * MeasurementType | 0x0000 | +| * TotalActivePower | 0x0304 | +| * RmsVoltage | 0x0505 | +| * RmsVoltageMin | 0x0506 | +| * RmsVoltageMax | 0x0507 | +| * RmsCurrent | 0x0508 | +| * RmsCurrentMin | 0x0509 | +| * RmsCurrentMax | 0x050A | +| * ActivePower | 0x050B | +| * ActivePowerMin | 0x050C | +| * ActivePowerMax | 0x050D | +| * ClusterRevision | 0xFFFD | +\*----------------------------------------------------------------------------*/ + +/* + * Discover Attributes + */ +class DiscoverElectricalMeasurementAttributes : public ModelCommand +{ +public: + DiscoverElectricalMeasurementAttributes() : ModelCommand("discover") { ModelCommand::AddArguments(); } + + ~DiscoverElectricalMeasurementAttributes() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x0C) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.DiscoverAttributes(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnDefaultSuccessResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute MeasurementType + */ +class ReadElectricalMeasurementMeasurementType : public ModelCommand +{ +public: + ReadElectricalMeasurementMeasurementType() : ModelCommand("read") + { + AddArgument("attr-name", "measurement-type"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementMeasurementType() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeMeasurementType(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt32uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute TotalActivePower + */ +class ReadElectricalMeasurementTotalActivePower : public ModelCommand +{ +public: + ReadElectricalMeasurementTotalActivePower() : ModelCommand("read") + { + AddArgument("attr-name", "total-active-power"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementTotalActivePower() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeTotalActivePower(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt32sAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute RmsVoltage + */ +class ReadElectricalMeasurementRmsVoltage : public ModelCommand +{ +public: + ReadElectricalMeasurementRmsVoltage() : ModelCommand("read") + { + AddArgument("attr-name", "rms-voltage"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementRmsVoltage() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeRmsVoltage(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute RmsVoltageMin + */ +class ReadElectricalMeasurementRmsVoltageMin : public ModelCommand +{ +public: + ReadElectricalMeasurementRmsVoltageMin() : ModelCommand("read") + { + AddArgument("attr-name", "rms-voltage-min"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementRmsVoltageMin() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeRmsVoltageMin(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute RmsVoltageMax + */ +class ReadElectricalMeasurementRmsVoltageMax : public ModelCommand +{ +public: + ReadElectricalMeasurementRmsVoltageMax() : ModelCommand("read") + { + AddArgument("attr-name", "rms-voltage-max"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementRmsVoltageMax() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeRmsVoltageMax(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute RmsCurrent + */ +class ReadElectricalMeasurementRmsCurrent : public ModelCommand +{ +public: + ReadElectricalMeasurementRmsCurrent() : ModelCommand("read") + { + AddArgument("attr-name", "rms-current"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementRmsCurrent() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeRmsCurrent(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute RmsCurrentMin + */ +class ReadElectricalMeasurementRmsCurrentMin : public ModelCommand +{ +public: + ReadElectricalMeasurementRmsCurrentMin() : ModelCommand("read") + { + AddArgument("attr-name", "rms-current-min"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementRmsCurrentMin() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeRmsCurrentMin(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute RmsCurrentMax + */ +class ReadElectricalMeasurementRmsCurrentMax : public ModelCommand +{ +public: + ReadElectricalMeasurementRmsCurrentMax() : ModelCommand("read") + { + AddArgument("attr-name", "rms-current-max"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementRmsCurrentMax() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeRmsCurrentMax(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute ActivePower + */ +class ReadElectricalMeasurementActivePower : public ModelCommand +{ +public: + ReadElectricalMeasurementActivePower() : ModelCommand("read") + { + AddArgument("attr-name", "active-power"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementActivePower() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeActivePower(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16sAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute ActivePowerMin + */ +class ReadElectricalMeasurementActivePowerMin : public ModelCommand +{ +public: + ReadElectricalMeasurementActivePowerMin() : ModelCommand("read") + { + AddArgument("attr-name", "active-power-min"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementActivePowerMin() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeActivePowerMin(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16sAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute ActivePowerMax + */ +class ReadElectricalMeasurementActivePowerMax : public ModelCommand +{ +public: + ReadElectricalMeasurementActivePowerMax() : ModelCommand("read") + { + AddArgument("attr-name", "active-power-max"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementActivePowerMax() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeActivePowerMax(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16sAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute ClusterRevision + */ +class ReadElectricalMeasurementClusterRevision : public ModelCommand +{ +public: + ReadElectricalMeasurementClusterRevision() : ModelCommand("read") + { + AddArgument("attr-name", "cluster-revision"); + ModelCommand::AddArguments(); + } + + ~ReadElectricalMeasurementClusterRevision() + { + delete onSuccessCallback; + delete onFailureCallback; + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0B04) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeClusterRevision(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + /*----------------------------------------------------------------------------*\ | Cluster EthernetNetworkDiagnostics | 0x0037 | |------------------------------------------------------------------------------| @@ -22214,6 +22674,22 @@ void registerClusterDoorLock(Commands & commands) commands.Register(clusterName, clusterCommands); } +void registerClusterElectricalMeasurement(Commands & commands) +{ + const char * clusterName = "ElectricalMeasurement"; + + commands_list clusterCommands = { + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), + }; + + commands.Register(clusterName, clusterCommands); +} void registerClusterEthernetNetworkDiagnostics(Commands & commands) { const char * clusterName = "EthernetNetworkDiagnostics"; @@ -22828,6 +23304,7 @@ void registerClusters(Commands & commands) registerClusterDescriptor(commands); registerClusterDiagnosticLogs(commands); registerClusterDoorLock(commands); + registerClusterElectricalMeasurement(commands); registerClusterEthernetNetworkDiagnostics(commands); registerClusterFixedLabel(commands); registerClusterFlowMeasurement(commands); diff --git a/src/app/clusters/electrical-measurement-server/electrical-measurement-server.cpp b/src/app/clusters/electrical-measurement-server/electrical-measurement-server.cpp new file mode 100644 index 00000000000000..b1c8b47e9cba42 --- /dev/null +++ b/src/app/clusters/electrical-measurement-server/electrical-measurement-server.cpp @@ -0,0 +1,138 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "electrical-measurement-server.h" + +#include + +#include +#include +#include +#include +#include + +EmberAfStatus emberAfElectricalMeasurementClusterGetMeasurementType(chip::EndpointId endpoint, uint32_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_MEASUREMENT_TYPE_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetTotalActivePower(chip::EndpointId endpoint, int32_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_TOTAL_ACTIVE_POWER_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsVoltage(chip::EndpointId endpoint, uint16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_VOLTAGE_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsVoltageMin(chip::EndpointId endpoint, uint16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_VOLTAGE_MIN_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsVoltageMax(chip::EndpointId endpoint, uint16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_VOLTAGE_MAX_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsCurrent(chip::EndpointId endpoint, uint16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_CURRENT_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsCurrentMin(chip::EndpointId endpoint, uint16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_CURRENT_MIN_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsCurrentMax(chip::EndpointId endpoint, uint16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_CURRENT_MAX_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetActivePower(chip::EndpointId endpoint, int16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_ACTIVE_POWER_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetActivePowerMin(chip::EndpointId endpoint, int16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_ACTIVE_POWER_MIN_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} +EmberAfStatus emberAfElectricalMeasurementClusterGetActivePowerMax(chip::EndpointId endpoint, int16_t * value) +{ + return emberAfReadServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_ACTIVE_POWER_MAX_ATTRIBUTE_ID, + (uint8_t *) value, sizeof(*value)); +} + +EmberAfStatus emberAfElectricalMeasurementClusterSetMeasurementType(chip::EndpointId endpoint, uint32_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_MEASUREMENT_TYPE_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_BITMAP32_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetTotalActivePower(chip::EndpointId endpoint, int32_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_TOTAL_ACTIVE_POWER_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT32S_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsVoltage(chip::EndpointId endpoint, uint16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_VOLTAGE_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsVoltageMin(chip::EndpointId endpoint, uint16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_VOLTAGE_MIN_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsVoltageMax(chip::EndpointId endpoint, uint16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_VOLTAGE_MAX_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsCurrent(chip::EndpointId endpoint, uint16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_CURRENT_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsCurrentMin(chip::EndpointId endpoint, uint16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_CURRENT_MIN_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsCurrentMax(chip::EndpointId endpoint, uint16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_RMS_CURRENT_MAX_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16U_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetActivePower(chip::EndpointId endpoint, int16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_ACTIVE_POWER_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetActivePowerMin(chip::EndpointId endpoint, int16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_ACTIVE_POWER_MIN_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); +} +EmberAfStatus emberAfElectricalMeasurementClusterSetActivePowerMax(chip::EndpointId endpoint, int16_t value) +{ + return emberAfWriteServerAttribute(endpoint, ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID, ZCL_ACTIVE_POWER_MAX_ATTRIBUTE_ID, + (uint8_t *) &value, ZCL_INT16S_ATTRIBUTE_TYPE); +} diff --git a/src/app/clusters/electrical-measurement-server/electrical-measurement-server.h b/src/app/clusters/electrical-measurement-server/electrical-measurement-server.h new file mode 100644 index 00000000000000..2f257968d2b4ad --- /dev/null +++ b/src/app/clusters/electrical-measurement-server/electrical-measurement-server.h @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +EmberAfStatus emberAfElectricalMeasurementClusterGetMeasurementType(chip::EndpointId endpoint, uint32_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetTotalActivePower(chip::EndpointId endpoint, int32_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsVoltage(chip::EndpointId endpoint, uint16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsVoltageMin(chip::EndpointId endpoint, uint16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsVoltageMax(chip::EndpointId endpoint, uint16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsCurrent(chip::EndpointId endpoint, uint16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsCurrentMin(chip::EndpointId endpoint, uint16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetRmsCurrentMax(chip::EndpointId endpoint, uint16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetActivePower(chip::EndpointId endpoint, int16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetActivePowerMin(chip::EndpointId endpoint, int16_t * value); +EmberAfStatus emberAfElectricalMeasurementClusterGetActivePowerMax(chip::EndpointId endpoint, int16_t * value); + +EmberAfStatus emberAfElectricalMeasurementClusterSetMeasurementType(chip::EndpointId endpoint, uint32_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetTotalActivePower(chip::EndpointId endpoint, int32_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsVoltage(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsVoltageMin(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsVoltageMax(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsCurrent(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsCurrentMin(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetRmsCurrentMax(chip::EndpointId endpoint, uint16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetActivePower(chip::EndpointId endpoint, int16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetActivePowerMin(chip::EndpointId endpoint, int16_t value); +EmberAfStatus emberAfElectricalMeasurementClusterSetActivePowerMax(chip::EndpointId endpoint, int16_t value); diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index cd58d0e72d0a79..d11456c6d4f934 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -51,6 +51,7 @@ 'PRESSURE_MEASUREMENT_CLUSTER': [], 'PUMP_CONFIG_CONTROL_CLUSTER': ['pump-configuration-and-control-server'], 'RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER': ['relative-humidity-measurement-server'], + 'ELECTRICAL_MEASUREMENT_CLUSTER': ['electrical-measurement-server'], 'SCENES_CLUSTER': ['scenes'], 'SOFTWARE_DIAGNOSTICS_CLUSTER': [], 'SWITCH_CLUSTER': [], @@ -110,6 +111,7 @@ 'PRESSURE_MEASUREMENT_CLUSTER': [], 'PUMP_CONFIG_CONTROL_CLUSTER': ['pump-configuration-and-control-client'], 'RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER': [], + 'ELECTRICAL_MEASUREMENT_CLUSTER': [], 'SCENES_CLUSTER': [], 'SOFTWARE_DIAGNOSTICS_CLUSTER': [], 'SWITCH_CLUSTER': [], diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 732bf948626c54..33ef9372d93fad 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -8774,6 +8774,223 @@ } ] }, + { + "name": "Electrical Measurement", + "code": 2820, + "mfgCode": null, + "define": "ELECTRICAL_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Electrical Measurement", + "code": 2820, + "mfgCode": null, + "define": "ELECTRICAL_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "measurement type", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "total active power", + "code": 772, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms voltage", + "code": 1285, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms voltage min", + "code": 1286, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x8000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms voltage max", + "code": 1287, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x8000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms current", + "code": 1288, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms current min", + "code": 1289, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rms current max", + "code": 1290, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "active power", + "code": 1291, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "active power min", + "code": 1292, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "active power max", + "code": 1293, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xffff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "Binding", "code": 61440, diff --git a/src/controller/data_model/gen/CHIPClusters.cpp b/src/controller/data_model/gen/CHIPClusters.cpp index 87cd9388317640..edf4d4e578de71 100644 --- a/src/controller/data_model/gen/CHIPClusters.cpp +++ b/src/controller/data_model/gen/CHIPClusters.cpp @@ -4138,6 +4138,159 @@ CHIP_ERROR DoorLockCluster::ReadAttributeClusterRevision(Callback::Cancelable * BasicAttributeFilter); } +// ElectricalMeasurement Cluster Commands +// ElectricalMeasurement Cluster Attributes +CHIP_ERROR ElectricalMeasurementCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeElectricalMeasurementClusterDiscoverAttributes(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeMeasurementType(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0000; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeTotalActivePower(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0304; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeRmsVoltage(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0505; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeRmsVoltageMin(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0506; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeRmsVoltageMax(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0507; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeRmsCurrent(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0508; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeRmsCurrentMin(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x0509; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeRmsCurrentMax(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x050A; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeActivePower(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x050B; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeActivePowerMin(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x050C; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeActivePowerMax(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0x050D; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + +CHIP_ERROR ElectricalMeasurementCluster::ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::AttributePathParams attributePath; + attributePath.mEndpointId = mEndpoint; + attributePath.mClusterId = mClusterId; + attributePath.mFieldId = 0xFFFD; + attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); + return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, + BasicAttributeFilter); +} + // EthernetNetworkDiagnostics Cluster Commands CHIP_ERROR EthernetNetworkDiagnosticsCluster::ResetCounts(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) diff --git a/src/controller/data_model/gen/CHIPClusters.h b/src/controller/data_model/gen/CHIPClusters.h index 64ede9e12396b8..9915ac64d1a3f7 100644 --- a/src/controller/data_model/gen/CHIPClusters.h +++ b/src/controller/data_model/gen/CHIPClusters.h @@ -41,6 +41,7 @@ constexpr ClusterId kContentLauncherClusterId = 0x050A; constexpr ClusterId kDescriptorClusterId = 0x001D; constexpr ClusterId kDiagnosticLogsClusterId = 0x0032; constexpr ClusterId kDoorLockClusterId = 0x0101; +constexpr ClusterId kElectricalMeasurementClusterId = 0x0B04; constexpr ClusterId kEthernetNetworkDiagnosticsClusterId = 0x0037; constexpr ClusterId kFixedLabelClusterId = 0x0040; constexpr ClusterId kFlowMeasurementClusterId = 0x0404; @@ -601,6 +602,28 @@ class DLL_EXPORT DoorLockCluster : public ClusterBase static constexpr CommandId kUnlockWithTimeoutCommandId = 0x03; }; +class DLL_EXPORT ElectricalMeasurementCluster : public ClusterBase +{ +public: + ElectricalMeasurementCluster() : ClusterBase(kElectricalMeasurementClusterId) {} + ~ElectricalMeasurementCluster() {} + + // Cluster Attributes + CHIP_ERROR DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeMeasurementType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeTotalActivePower(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeRmsVoltage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeRmsVoltageMin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeRmsVoltageMax(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeRmsCurrent(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeRmsCurrentMin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeRmsCurrentMax(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeActivePower(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeActivePowerMin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeActivePowerMax(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); +}; + class DLL_EXPORT EthernetNetworkDiagnosticsCluster : public ClusterBase { public: diff --git a/src/controller/data_model/gen/callback-stub.cpp b/src/controller/data_model/gen/callback-stub.cpp index b73219c6e231b7..3677b36b6af119 100644 --- a/src/controller/data_model/gen/callback-stub.cpp +++ b/src/controller/data_model/gen/callback-stub.cpp @@ -71,6 +71,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_DOOR_LOCK_CLUSTER_ID: emberAfDoorLockClusterInitCallback(endpoint); break; + case ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID: + emberAfElectricalMeasurementClusterInitCallback(endpoint); + break; case ZCL_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_ID: emberAfEthernetNetworkDiagnosticsClusterInitCallback(endpoint); break; @@ -243,6 +246,11 @@ void __attribute__((weak)) emberAfDoorLockClusterInitCallback(EndpointId endpoin // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfElectricalMeasurementClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfEthernetNetworkDiagnosticsClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/src/controller/data_model/gen/callback.h b/src/controller/data_model/gen/callback.h index 63a34a4fd7b393..cde7d97fb4de4b 100644 --- a/src/controller/data_model/gen/callback.h +++ b/src/controller/data_model/gen/callback.h @@ -152,6 +152,14 @@ void emberAfDiagnosticLogsClusterInitCallback(chip::EndpointId endpoint); */ void emberAfDoorLockClusterInitCallback(chip::EndpointId endpoint); +/** @brief Electrical Measurement Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalMeasurementClusterInitCallback(chip::EndpointId endpoint); + /** @brief Ethernet Network Diagnostics Cluster Init * * Cluster Init @@ -1389,6 +1397,77 @@ EmberAfStatus emberAfDoorLockClusterClientPreAttributeChangedCallback(chip::Endp */ void emberAfDoorLockClusterClientTickCallback(chip::EndpointId endpoint); +// +// Electrical Measurement Cluster client +// + +/** @brief Electrical Measurement Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfElectricalMeasurementClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Electrical Measurement Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfElectricalMeasurementClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Electrical Measurement Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfElectricalMeasurementClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Electrical Measurement Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param destination The destination to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfElectricalMeasurementClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Electrical Measurement Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfElectricalMeasurementClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, + uint16_t size, uint8_t * value); + +/** @brief Electrical Measurement Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfElectricalMeasurementClusterClientTickCallback(chip::EndpointId endpoint); + // // Ethernet Network Diagnostics Cluster client // diff --git a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h index c7e8d2ac5c5665..7c9cdabd82ff7f 100644 --- a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h +++ b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h @@ -42,6 +42,7 @@ | Descriptor | 0x001D | | DiagnosticLogs | 0x0032 | | DoorLock | 0x0101 | +| ElectricalMeasurement | 0x0B04 | | EthernetNetworkDiagnostics | 0x0037 | | FixedLabel | 0x0040 | | FlowMeasurement | 0x0404 | @@ -1495,6 +1496,117 @@ chip::System::PacketBufferHandle encodeDoorLockClusterReadActuatorEnabledAttribu chip::System::PacketBufferHandle encodeDoorLockClusterReadClusterRevisionAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalMeasurement | 0x0B04 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * MeasurementType | 0x0000 | +| * TotalActivePower | 0x0304 | +| * RmsVoltage | 0x0505 | +| * RmsVoltageMin | 0x0506 | +| * RmsVoltageMax | 0x0507 | +| * RmsCurrent | 0x0508 | +| * RmsCurrentMin | 0x0509 | +| * RmsCurrentMax | 0x050A | +| * ActivePower | 0x050B | +| * ActivePowerMin | 0x050C | +| * ActivePowerMax | 0x050D | +| * ClusterRevision | 0xFFFD | +\*----------------------------------------------------------------------------*/ + +/** + * @brief + * Encode a Electrical Measurement server discover command into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterDiscoverAttributes(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the measurement type attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeElectricalMeasurementClusterReadMeasurementTypeAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the total active power attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeElectricalMeasurementClusterReadTotalActivePowerAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the rms voltage attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadRmsVoltageAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the rms voltage min attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadRmsVoltageMinAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the rms voltage max attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadRmsVoltageMaxAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the rms current attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadRmsCurrentAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the rms current min attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadRmsCurrentMinAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the rms current max attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadRmsCurrentMaxAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the active power attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeElectricalMeasurementClusterReadActivePowerAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the active power min attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeElectricalMeasurementClusterReadActivePowerMinAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the active power max attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeElectricalMeasurementClusterReadActivePowerMaxAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Electrical Measurement server read command for the cluster revision attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle +encodeElectricalMeasurementClusterReadClusterRevisionAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + /*----------------------------------------------------------------------------*\ | Cluster EthernetNetworkDiagnostics | 0x0037 | |------------------------------------------------------------------------------| diff --git a/src/controller/data_model/gen/encoder.cpp b/src/controller/data_model/gen/encoder.cpp index 8a545578f1ed44..8fbea087925aff 100644 --- a/src/controller/data_model/gen/encoder.cpp +++ b/src/controller/data_model/gen/encoder.cpp @@ -72,6 +72,7 @@ using namespace chip::Encoding::LittleEndian; | Descriptor | 0x001D | | DiagnosticLogs | 0x0032 | | DoorLock | 0x0101 | +| ElectricalMeasurement | 0x0B04 | | EthernetNetworkDiagnostics | 0x0037 | | FixedLabel | 0x0040 | | FlowMeasurement | 0x0404 | @@ -2462,6 +2463,189 @@ PacketBufferHandle encodeDoorLockClusterReadClusterRevisionAttribute(uint8_t seq COMMAND_FOOTER(); } +/*----------------------------------------------------------------------------*\ +| Cluster ElectricalMeasurement | 0x0B04 | +|------------------------------------------------------------------------------| +| Commands: | | +|------------------------------------------------------------------------------| +| Attributes: | | +| * MeasurementType | 0x0000 | +| * TotalActivePower | 0x0304 | +| * RmsVoltage | 0x0505 | +| * RmsVoltageMin | 0x0506 | +| * RmsVoltageMax | 0x0507 | +| * RmsCurrent | 0x0508 | +| * RmsCurrentMin | 0x0509 | +| * RmsCurrentMax | 0x050A | +| * ActivePower | 0x050B | +| * ActivePowerMin | 0x050C | +| * ActivePowerMax | 0x050D | +| * ClusterRevision | 0xFFFD | +\*----------------------------------------------------------------------------*/ + +PacketBufferHandle encodeElectricalMeasurementClusterDiscoverAttributes(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("DiscoverElectricalMeasurementAttributes", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put32(Globals::Commands::Ids::DiscoverAttributes).Put32(0x0000).Put8(0xFF); + COMMAND_FOOTER(); +} + +/* + * Attribute MeasurementType + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadMeasurementTypeAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementMeasurementType", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::MeasurementType); + COMMAND_FOOTER(); +} + +/* + * Attribute TotalActivePower + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadTotalActivePowerAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementTotalActivePower", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::TotalActivePower); + COMMAND_FOOTER(); +} + +/* + * Attribute RmsVoltage + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadRmsVoltageAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementRmsVoltage", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::RmsVoltage); + COMMAND_FOOTER(); +} + +/* + * Attribute RmsVoltageMin + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadRmsVoltageMinAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementRmsVoltageMin", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::RmsVoltageMin); + COMMAND_FOOTER(); +} + +/* + * Attribute RmsVoltageMax + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadRmsVoltageMaxAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementRmsVoltageMax", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::RmsVoltageMax); + COMMAND_FOOTER(); +} + +/* + * Attribute RmsCurrent + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadRmsCurrentAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementRmsCurrent", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::RmsCurrent); + COMMAND_FOOTER(); +} + +/* + * Attribute RmsCurrentMin + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadRmsCurrentMinAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementRmsCurrentMin", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::RmsCurrentMin); + COMMAND_FOOTER(); +} + +/* + * Attribute RmsCurrentMax + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadRmsCurrentMaxAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementRmsCurrentMax", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::RmsCurrentMax); + COMMAND_FOOTER(); +} + +/* + * Attribute ActivePower + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadActivePowerAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementActivePower", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::ActivePower); + COMMAND_FOOTER(); +} + +/* + * Attribute ActivePowerMin + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadActivePowerMinAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementActivePowerMin", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::ActivePowerMin); + COMMAND_FOOTER(); +} + +/* + * Attribute ActivePowerMax + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadActivePowerMaxAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementActivePowerMax", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(ElectricalMeasurement::Attributes::Ids::ActivePowerMax); + COMMAND_FOOTER(); +} + +/* + * Attribute ClusterRevision + */ +PacketBufferHandle encodeElectricalMeasurementClusterReadClusterRevisionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadElectricalMeasurementClusterRevision", ElectricalMeasurement::Id); + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put32(Globals::Commands::Ids::ReadAttributes) + .Put32(Globals::Attributes::Ids::ClusterRevision); + COMMAND_FOOTER(); +} + /*----------------------------------------------------------------------------*\ | Cluster EthernetNetworkDiagnostics | 0x0037 | |------------------------------------------------------------------------------| diff --git a/src/controller/data_model/gen/endpoint_config.h b/src/controller/data_model/gen/endpoint_config.h index 93ecdf2ac369ee..1e279851b76503 100644 --- a/src/controller/data_model/gen/endpoint_config.h +++ b/src/controller/data_model/gen/endpoint_config.h @@ -63,7 +63,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 45 +#define GENERATED_ATTRIBUTE_COUNT 46 #define GENERATED_ATTRIBUTES \ { \ \ @@ -198,6 +198,9 @@ /* Endpoint: 1, Cluster: Test Cluster (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Electrical Measurement (client) */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: Binding (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ @@ -212,7 +215,7 @@ #define GENERATED_FUNCTION_ARRAYS #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 46 +#define GENERATED_CLUSTER_COUNT 47 #define GENERATED_CLUSTERS \ { \ { 0x0003, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Identify (client) */ \ @@ -336,10 +339,13 @@ 0x050F, ZAP_ATTRIBUTE_INDEX(42), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (client) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(43), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0B04, ZAP_ATTRIBUTE_INDEX(43), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Electrical Measurement (client) */ \ + { \ + 0xF000, ZAP_ATTRIBUTE_INDEX(44), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Binding (client) */ \ { \ - 0xF004, ZAP_ATTRIBUTE_INDEX(44), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0xF004, ZAP_ATTRIBUTE_INDEX(45), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Group Key Management (client) */ \ } @@ -348,7 +354,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 46, 90 }, \ + { ZAP_CLUSTER_INDEX(0), 47, 92 }, \ } // Largest attribute size is needed for various buffers @@ -358,7 +364,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (4) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (90) +#define ATTRIBUTE_MAX_SIZE (92) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) diff --git a/src/controller/data_model/gen/gen_config.h b/src/controller/data_model/gen/gen_config.h index 30ccfde324ce26..c3bc21e597314a 100644 --- a/src/controller/data_model/gen/gen_config.h +++ b/src/controller/data_model/gen/gen_config.h @@ -43,6 +43,7 @@ #define EMBER_AF_DESCRIPTOR_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_DIAGNOSTIC_LOGS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_DOOR_LOCK_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_ELECTRICAL_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_FIXED_LABEL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_FLOW_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) @@ -134,6 +135,10 @@ #define ZCL_USING_DOOR_LOCK_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_DOOR_LOCK_CLIENT +// Use this macro to check if the client side of the Electrical Measurement cluster is included +#define ZCL_USING_ELECTRICAL_MEASUREMENT_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_ELECTRICAL_MEASUREMENT_CLIENT + // Use this macro to check if the client side of the Ethernet Network Diagnostics cluster is included #define ZCL_USING_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_ETHERNET_NETWORK_DIAGNOSTICS_CLIENT diff --git a/src/controller/java/gen/CHIPClusters-JNI.cpp b/src/controller/java/gen/CHIPClusters-JNI.cpp index 82f6d4d55ab2f4..27456848d8aa30 100644 --- a/src/controller/java/gen/CHIPClusters-JNI.cpp +++ b/src/controller/java/gen/CHIPClusters-JNI.cpp @@ -7636,6 +7636,15 @@ JNI_METHOD(void, DoorLockCluster, unlockWithTimeout) env->CallVoidMethod(callback, method, exception); } } +JNI_METHOD(jlong, ElectricalMeasurementCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) +{ + StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); + ElectricalMeasurementCluster * cppCluster = new ElectricalMeasurementCluster(); + + cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + return reinterpret_cast(cppCluster); +} + JNI_METHOD(jlong, EthernetNetworkDiagnosticsCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); diff --git a/src/controller/java/gen/ChipClusters.java b/src/controller/java/gen/ChipClusters.java index 7f195c1d13f847..96e1723ca466f5 100644 --- a/src/controller/java/gen/ChipClusters.java +++ b/src/controller/java/gen/ChipClusters.java @@ -1017,6 +1017,15 @@ public interface UnlockWithTimeoutResponseCallback { } } + public static class ElectricalMeasurementCluster extends BaseChipCluster { + public ElectricalMeasurementCluster(long devicePtr, int endpointId) { + super(devicePtr, endpointId); + } + + @Override + public native long initWithDevice(long devicePtr, int endpointId); + } + public static class EthernetNetworkDiagnosticsCluster extends BaseChipCluster { public EthernetNetworkDiagnosticsCluster(long devicePtr, int endpointId) { super(devicePtr, endpointId); diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 15e24d4cd005fa..6061073508e780 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -2175,6 +2175,126 @@ CHIP_ERROR chip_ime_ReadAttribute_DoorLock_ClusterRevision(chip::Controller::Dev } // End of Cluster DoorLock +// Cluster ElectricalMeasurement + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_MeasurementType(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeMeasurementType(gInt32uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_TotalActivePower(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeTotalActivePower(gInt32sAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltage(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeRmsVoltage(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMin(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeRmsVoltageMin(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMax(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeRmsVoltageMax(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrent(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeRmsCurrent(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMin(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeRmsCurrentMin(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMax(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeRmsCurrentMax(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_ActivePower(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeActivePower(gInt16sAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMin(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeActivePowerMin(gInt16sAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMax(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeActivePowerMax(gInt16sAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +CHIP_ERROR chip_ime_ReadAttribute_ElectricalMeasurement_ClusterRevision(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, + chip::GroupId /* ZCLgroupId */) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::ElectricalMeasurementCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.ReadAttributeClusterRevision(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); +} + +// End of Cluster ElectricalMeasurement // Cluster EthernetNetworkDiagnostics CHIP_ERROR chip_ime_AppendCommand_EthernetNetworkDiagnostics_ResetCounts(chip::Controller::Device * device, diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 893ec3462086a7..82ad2f08492748 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -304,6 +304,8 @@ def ListClusterCommands(self): "pin": "str", }, }, + "ElectricalMeasurement": { + }, "EthernetNetworkDiagnostics": { "ResetCounts": { }, @@ -1220,6 +1222,56 @@ def ListClusterAttributes(self): "type": "int", }, }, + "ElectricalMeasurement": { + "MeasurementType": { + "attributeId": 0x0000, + "type": "int", + }, + "TotalActivePower": { + "attributeId": 0x0304, + "type": "int", + }, + "RmsVoltage": { + "attributeId": 0x0505, + "type": "int", + }, + "RmsVoltageMin": { + "attributeId": 0x0506, + "type": "int", + }, + "RmsVoltageMax": { + "attributeId": 0x0507, + "type": "int", + }, + "RmsCurrent": { + "attributeId": 0x0508, + "type": "int", + }, + "RmsCurrentMin": { + "attributeId": 0x0509, + "type": "int", + }, + "RmsCurrentMax": { + "attributeId": 0x050A, + "type": "int", + }, + "ActivePower": { + "attributeId": 0x050B, + "type": "int", + }, + "ActivePowerMin": { + "attributeId": 0x050C, + "type": "int", + }, + "ActivePowerMax": { + "attributeId": 0x050D, + "type": "int", + }, + "ClusterRevision": { + "attributeId": 0xFFFD, + "type": "int", + }, + }, "EthernetNetworkDiagnostics": { "PacketRxCount": { "attributeId": 0x0002, @@ -3030,6 +3082,30 @@ def ClusterDoorLock_ReadAttributeActuatorEnabled(self, device: ctypes.c_void_p, return self._chipLib.chip_ime_ReadAttribute_DoorLock_ActuatorEnabled(device, ZCLendpoint, ZCLgroupid) def ClusterDoorLock_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_DoorLock_ClusterRevision(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeMeasurementType(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_MeasurementType(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeTotalActivePower(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_TotalActivePower(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeRmsVoltage(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltage(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeRmsVoltageMin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMin(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeRmsVoltageMax(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMax(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeRmsCurrent(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrent(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeRmsCurrentMin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMin(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeRmsCurrentMax(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMax(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeActivePower(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePower(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeActivePowerMin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMin(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeActivePowerMax(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMax(device, ZCLendpoint, ZCLgroupid) + def ClusterElectricalMeasurement_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ClusterRevision(device, ZCLendpoint, ZCLgroupid) def ClusterEthernetNetworkDiagnostics_ReadAttributePacketRxCount(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_EthernetNetworkDiagnostics_PacketRxCount(device, ZCLendpoint, ZCLgroupid) def ClusterEthernetNetworkDiagnostics_ReadAttributePacketTxCount(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): @@ -4130,6 +4206,43 @@ def InitLib(self, chipLib): # Cluster DoorLock ReadAttribute ClusterRevision self._chipLib.chip_ime_ReadAttribute_DoorLock_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_DoorLock_ClusterRevision.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement + # Cluster ElectricalMeasurement ReadAttribute MeasurementType + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_MeasurementType.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_MeasurementType.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute TotalActivePower + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_TotalActivePower.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_TotalActivePower.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute RmsVoltage + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltage.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltage.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute RmsVoltageMin + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMin.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute RmsVoltageMax + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMax.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsVoltageMax.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute RmsCurrent + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrent.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrent.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute RmsCurrentMin + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMin.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute RmsCurrentMax + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMax.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_RmsCurrentMax.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute ActivePower + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePower.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePower.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute ActivePowerMin + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMin.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute ActivePowerMax + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMax.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ActivePowerMax.restype = ctypes.c_uint32 + # Cluster ElectricalMeasurement ReadAttribute ClusterRevision + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ElectricalMeasurement_ClusterRevision.restype = ctypes.c_uint32 # Cluster EthernetNetworkDiagnostics # Cluster EthernetNetworkDiagnostics Command ResetCounts self._chipLib.chip_ime_AppendCommand_EthernetNetworkDiagnostics_ResetCounts.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h index 7af6ffc79acb76..f30ba7a1a511c5 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h @@ -505,6 +505,27 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Electrical Measurement + * + */ +@interface CHIPElectricalMeasurement : CHIPCluster + +- (void)readAttributeMeasurementTypeWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeTotalActivePowerWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeRmsVoltageWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeRmsVoltageMinWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeRmsVoltageMaxWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeRmsCurrentWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeRmsCurrentMinWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeRmsCurrentMaxWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeActivePowerWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeActivePowerMinWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeActivePowerMaxWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler; + +@end + /** * Cluster Ethernet Network Diagnostics * diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index 7618ceb45757c7..227f21df0b2307 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -9509,6 +9509,343 @@ - (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)respons @end +@interface CHIPElectricalMeasurement () +@property (readonly) Controller::ElectricalMeasurementCluster cppCluster; +@end + +@implementation CHIPElectricalMeasurement + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)readAttributeMeasurementTypeWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeMeasurementType(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeTotalActivePowerWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt32sAttributeCallbackBridge * onSuccess = new CHIPInt32sAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeTotalActivePower(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRmsVoltageWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRmsVoltage(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRmsVoltageMinWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRmsVoltageMin(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRmsVoltageMaxWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRmsVoltageMax(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRmsCurrentWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRmsCurrent(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRmsCurrentMinWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRmsCurrentMin(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRmsCurrentMaxWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeRmsCurrentMax(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeActivePowerWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeActivePower(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeActivePowerMinWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeActivePowerMin(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeActivePowerMaxWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeActivePowerMax(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); + if (!onSuccess) { + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + __block CHIP_ERROR err; + dispatch_sync([self chipWorkQueue], ^{ + err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + }); + + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + responseHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPEthernetNetworkDiagnostics () @property (readonly) Controller::EthernetNetworkDiagnosticsCluster cppCluster; @end diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index a5acc3a71004b1..10348d2f72c20d 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -5130,6 +5130,234 @@ - (void)testSendClusterDoorLockReadAttributeClusterRevisionWithResponseHandler [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterElectricalMeasurementReadAttributeMeasurementTypeWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeMeasurementTypeWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeMeasurementTypeWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement MeasurementType Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeTotalActivePowerWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeTotalActivePowerWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeTotalActivePowerWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement TotalActivePower Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeRmsVoltageWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeRmsVoltageWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeRmsVoltageWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement RmsVoltage Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeRmsVoltageMinWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeRmsVoltageMinWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeRmsVoltageMinWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement RmsVoltageMin Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeRmsVoltageMaxWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeRmsVoltageMaxWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeRmsVoltageMaxWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement RmsVoltageMax Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeRmsCurrentWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeRmsCurrentWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeRmsCurrentWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement RmsCurrent Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeRmsCurrentMinWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeRmsCurrentMinWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeRmsCurrentMinWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement RmsCurrentMin Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeRmsCurrentMaxWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeRmsCurrentMaxWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeRmsCurrentMaxWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement RmsCurrentMax Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeActivePowerWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeActivePowerWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeActivePowerWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement ActivePower Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeActivePowerMinWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeActivePowerMinWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeActivePowerMinWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement ActivePowerMin Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeActivePowerMaxWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeActivePowerMaxWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeActivePowerMaxWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement ActivePowerMax Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterElectricalMeasurementReadAttributeClusterRevisionWithResponseHandler +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"ElectricalMeasurementReadAttributeClusterRevisionWithResponseHandler"]; + + CHIPDevice * device = GetPairedDevice(kDeviceId); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPElectricalMeasurement * cluster = [[CHIPElectricalMeasurement alloc] initWithDevice:device endpoint:1 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeClusterRevisionWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ElectricalMeasurement ClusterRevision Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterEthernetNetworkDiagnosticsReadAttributePacketRxCountWithResponseHandler { XCTestExpectation * expectation =