From 89601c4c38552d67bcd42e7f3ee7bc314539502c Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 18 Jan 2021 16:29:52 +0100 Subject: [PATCH] Update ZCL reporting code to be compatible with a client ZAP application #### Problem In #3608, many reporting specific callbacks has been moved from `gen/callback-stub.cpp` to `src/app/reporting/`. The PR has been a bit overzealous since all the `*ReportingResponseCallback` declarations and definitions has been moved while those still needs to be part of the `gen/` content if one wants to override them. Also, the server specific stack status callbacks are called for both the client and the server, while those only needs to be called by the reporter. Those issues prevents to write a client application that consumes a `.zap` configuration file. #### Summary of changes * Move back `*ReportingResponseCallback` to the `gen/` folder * Update the `#ifdef` in `src/app/server/DataModelHandler.cpp` to only call the stack status callbacks for the server side * Update `HandleDataModelMessage` signature by only passing a `NodeId` for the first argument and remove the last one which is unused. --- .../all-clusters-common/gen/callback-stub.cpp | 34 ++++++++++ .../all-clusters-common/gen/callback.h | 28 ++++++++ .../bridge-common/gen/callback-stub.cpp | 34 ++++++++++ .../bridge-app/bridge-common/gen/callback.h | 28 ++++++++ .../lighting-common/gen/callback-stub.cpp | 34 ++++++++++ .../lighting-common/gen/callback.h | 28 ++++++++ .../lock-common/gen/callback-stub.cpp | 34 ++++++++++ examples/lock-app/lock-common/gen/callback.h | 28 ++++++++ .../esp32/main/gen/callback-stub.cpp | 34 ++++++++++ .../esp32/main/gen/callback.h | 28 ++++++++ src/app/reporting/reporting.cpp | 10 --- src/app/reporting/reporting.h | 28 -------- src/app/server/DataModelHandler.cpp | 67 ++++++++----------- src/app/server/DataModelHandler.h | 14 ++-- src/app/server/Server.cpp | 2 +- .../templates/app/callback-stub-src.zapt | 36 ++++++++++ .../zap-templates/templates/app/callback.zapt | 28 ++++++++ 17 files changed, 413 insertions(+), 82 deletions(-) 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 69d496a19af455..583f2ff9d005c8 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 @@ -248,6 +248,40 @@ bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, Em return false; } +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover 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 59bcc061e46bb5..e885a3f9c2b62f 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -2504,6 +2504,34 @@ bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::Cluste */ bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status); +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/bridge-app/bridge-common/gen/callback-stub.cpp b/examples/bridge-app/bridge-common/gen/callback-stub.cpp index 978a5d23d3179f..4f8e8b8af5980c 100644 --- a/examples/bridge-app/bridge-common/gen/callback-stub.cpp +++ b/examples/bridge-app/bridge-common/gen/callback-stub.cpp @@ -168,6 +168,40 @@ bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, Em return false; } +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/bridge-app/bridge-common/gen/callback.h b/examples/bridge-app/bridge-common/gen/callback.h index bfbafdc793af0f..f47be8e66e88e0 100644 --- a/examples/bridge-app/bridge-common/gen/callback.h +++ b/examples/bridge-app/bridge-common/gen/callback.h @@ -414,6 +414,34 @@ bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::Cluste */ bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status); +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/lighting-app/lighting-common/gen/callback-stub.cpp b/examples/lighting-app/lighting-common/gen/callback-stub.cpp index 2fdef872d8c4c4..e0c625c7dd643d 100644 --- a/examples/lighting-app/lighting-common/gen/callback-stub.cpp +++ b/examples/lighting-app/lighting-common/gen/callback-stub.cpp @@ -163,6 +163,40 @@ bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, Em return false; } +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/lighting-app/lighting-common/gen/callback.h b/examples/lighting-app/lighting-common/gen/callback.h index d9a7391fb52899..fe48cdccae1ae2 100644 --- a/examples/lighting-app/lighting-common/gen/callback.h +++ b/examples/lighting-app/lighting-common/gen/callback.h @@ -391,6 +391,34 @@ bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::Cluste */ bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status); +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/lock-app/lock-common/gen/callback-stub.cpp b/examples/lock-app/lock-common/gen/callback-stub.cpp index 38608e2ee7d29b..f4332d5f7f135f 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -154,6 +154,40 @@ bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, Em return false; } +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/lock-app/lock-common/gen/callback.h b/examples/lock-app/lock-common/gen/callback.h index 3bc4bcaacaf8a2..05a577de34f869 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -241,6 +241,34 @@ bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::Cluste */ bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status); +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp index ac3b13aacbb381..b3385aeb929af6 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp @@ -168,6 +168,40 @@ bool emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, Em return false; } +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback.h b/examples/temperature-measurement-app/esp32/main/gen/callback.h index 7829b19e66d717..7f1cb533714303 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback.h +++ b/examples/temperature-measurement-app/esp32/main/gen/callback.h @@ -308,6 +308,34 @@ bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::Cluste */ bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status); +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/src/app/reporting/reporting.cpp b/src/app/reporting/reporting.cpp index 4d2e5dbefedca5..1186539b5d18d3 100644 --- a/src/app/reporting/reporting.cpp +++ b/src/app/reporting/reporting.cpp @@ -1078,13 +1078,3 @@ uint8_t emAfPluginReportingConditionallyAddReportingEntry(EmberAfPluginReporting } return 0; } - -bool emberAfConfigureReportingResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - -bool emberAfReadReportingConfigurationResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} diff --git a/src/app/reporting/reporting.h b/src/app/reporting/reporting.h index 21ed3d30c87ca9..2ab9de71710283 100644 --- a/src/app/reporting/reporting.h +++ b/src/app/reporting/reporting.h @@ -112,34 +112,6 @@ bool emberAfReadReportingConfigurationCommandCallback(const EmberAfClusterComman */ EmberStatus emberAfClearReportTableCallback(void); -/** @brief Configure Reporting Response - * - * This function is called by the application framework when a Configure - * Reporting Response command is received from an external device. The - * application should return true if the message was processed or false if it - * was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of attribute status records. Ver.: - * always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - -/** @brief Read Reporting Configuration Response - * - * This function is called by the application framework when a Read Reporting - * Configuration Response command is received from an external device. The - * application should return true if the message was processed or false if it - * was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of attribute reporting configuration - * records. Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); - /** @brief Reporting Attribute Change * * This function is called by the framework when an attribute managed by the diff --git a/src/app/server/DataModelHandler.cpp b/src/app/server/DataModelHandler.cpp index 937d712809b708..9aa97327d58f93 100644 --- a/src/app/server/DataModelHandler.cpp +++ b/src/app/server/DataModelHandler.cpp @@ -22,15 +22,11 @@ #include -#include -#include #include #include -#include #include -#include -#ifdef EMBER_AF_PLUGIN_REPORTING +#ifdef EMBER_AF_PLUGIN_REPORTING_SERVER void emberAfPluginReportingStackStatusCallback(EmberStatus status); #endif #ifdef EMBER_AF_PLUGIN_TEMPERATURE_MEASUREMENT_SERVER @@ -42,24 +38,38 @@ void emberAfPluginIasZoneServerStackStatusCallback(EmberStatus status); using namespace ::chip; -/** - * Handle a message that should be processed via our data model processing - * codepath. This function will free the packet buffer. - * - * @param [in] buffer The buffer holding the message. This function guarantees - * that it will free the buffer before returning. - */ -void HandleDataModelMessage(const PacketHeader & header, System::PacketBufferHandle buffer, SecureSessionMgr * mgr) +void InitDataModelHandler() +{ + emberAfEndpointConfigure(); + emberAfInit(); + +#if defined(EMBER_AF_PLUGIN_REPORTING_SERVER) || defined(EMBER_AF_PLUGIN_TEMPERATURE_MEASUREMENT_SERVER) || \ + defined(EMBER_AF_PLUGIN_IAS_ZONE_SERVER) + EmberStatus status = EMBER_NETWORK_UP; +#endif + +#ifdef EMBER_AF_PLUGIN_REPORTING_SERVER + emberAfPluginReportingStackStatusCallback(status); +#endif +#ifdef EMBER_AF_PLUGIN_TEMPERATURE_MEASUREMENT_SERVER + emberAfPluginTemperatureMeasurementServerStackStatusCallback(status); +#endif +#ifdef EMBER_AF_PLUGIN_IAS_ZONE_SERVER + emberAfPluginIasZoneServerStackStatusCallback(status); +#endif +} + +void HandleDataModelMessage(NodeId nodeId, System::PacketBufferHandle buffer) { EmberApsFrame frame; bool ok = extractApsFrame(buffer->Start(), buffer->DataLength(), &frame) > 0; if (ok) { - ChipLogProgress(Zcl, "APS frame processing success!"); + ChipLogDetail(Zcl, "APS frame processing success!"); } else { - ChipLogProgress(Zcl, "APS frame processing failure!"); + ChipLogDetail(Zcl, "APS frame processing failure!"); return; } @@ -68,36 +78,15 @@ void HandleDataModelMessage(const PacketHeader & header, System::PacketBufferHan ok = emberAfProcessMessage(&frame, 0, // type message, messageLen, - header.GetSourceNodeId().Value(), // source identifier + nodeId, // source identifier NULL); if (ok) { - ChipLogProgress(Zcl, "Data model processing success!"); + ChipLogDetail(Zcl, "Data model processing success!"); } else { - ChipLogProgress(Zcl, "Data model processing failure!"); + ChipLogDetail(Zcl, "Data model processing failure!"); } } - -void InitDataModelHandler() -{ - emberAfEndpointConfigure(); - emberAfInit(); - -#if defined(EMBER_AF_PLUGIN_REPORTING) || defined(EMBER_AF_PLUGIN_TEMPERATURE_MEASUREMENT_SERVER) || \ - defined(EMBER_AF_PLUGIN_IAS_ZONE_SERVER) - EmberStatus status = EMBER_NETWORK_UP; -#endif - -#ifdef EMBER_AF_PLUGIN_REPORTING - emberAfPluginReportingStackStatusCallback(status); -#endif -#ifdef EMBER_AF_PLUGIN_TEMPERATURE_MEASUREMENT_SERVER - emberAfPluginTemperatureMeasurementServerStackStatusCallback(status); -#endif -#ifdef EMBER_AF_PLUGIN_IAS_ZONE_SERVER - emberAfPluginIasZoneServerStackStatusCallback(status); -#endif -} diff --git a/src/app/server/DataModelHandler.h b/src/app/server/DataModelHandler.h index 39854b8d55606f..b6085e80ab45c5 100644 --- a/src/app/server/DataModelHandler.h +++ b/src/app/server/DataModelHandler.h @@ -23,16 +23,22 @@ #pragma once #include -#include #include +/** + * Initialize the data model internal code to be ready to send and receive + * data model messages. + * + */ +void InitDataModelHandler(); + /** * Handle a message that should be processed via our data model processing * codepath. * + * @param [in] nodeId The source node id of the message * @param [in] buffer The buffer holding the message. This function guarantees * that it will free the buffer before returning. + * */ -void HandleDataModelMessage(const chip::PacketHeader & header, chip::System::PacketBufferHandle buffer, - chip::SecureSessionMgr * mgr); -void InitDataModelHandler(); +void HandleDataModelMessage(chip::NodeId nodeId, chip::System::PacketBufferHandle buffer); diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 9510ceed882747..7a7f13f4b958ce 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -88,7 +88,7 @@ class ServerCallback : public SecureSessionMgrDelegate ChipLogProgress(AppServer, "Packet received from %s: %zu bytes", src_addr, static_cast(data_len)); - HandleDataModelMessage(header, std::move(buffer), mgr); + HandleDataModelMessage(header.GetSourceNodeId().Value(), std::move(buffer)); exit:; } diff --git a/src/app/zap-templates/templates/app/callback-stub-src.zapt b/src/app/zap-templates/templates/app/callback-stub-src.zapt index 16bb4498ae8ed6..cefb074bdb985b 100644 --- a/src/app/zap-templates/templates/app/callback-stub-src.zapt +++ b/src/app/zap-templates/templates/app/callback-stub-src.zapt @@ -153,6 +153,42 @@ bool __attribute__((weak)) emberAfDefaultResponseCallback( return false; } +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfConfigureReportingResponseCallback( + ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool __attribute__((weak)) emberAfReadReportingConfigurationResponseCallback( + ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) +{ + return false; +} + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover diff --git a/src/app/zap-templates/templates/app/callback.zapt b/src/app/zap-templates/templates/app/callback.zapt index bd0bd8b2539c13..5b294d6feeb1ca 100644 --- a/src/app/zap-templates/templates/app/callback.zapt +++ b/src/app/zap-templates/templates/app/callback.zapt @@ -233,6 +233,34 @@ bool emberAfAttributeWriteAccessCallback(chip::EndpointId endpoint, chip::Cluste */ bool emberAfDefaultResponseCallback(chip::ClusterId clusterId, chip::CommandId commandId, EmberAfStatus status); +/** @brief Configure Reporting Response + * + * This function is called by the application framework when a Configure + * Reporting Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute status records. Ver.: + * always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfConfigureReportingResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +/** @brief Read Reporting Configuration Response + * + * This function is called by the application framework when a Read Reporting + * Configuration Response command is received from an external device. The + * application should return true if the message was processed or false if it + * was not. + * + * @param clusterId The cluster identifier of this response. Ver.: always + * @param buffer Buffer containing the list of attribute reporting configuration + * records. Ver.: always + * @param bufLen The length in bytes of the list. Ver.: always + */ +bool emberAfReadReportingConfigurationResponseCallback(chip::ClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + /** @brief Discover Attributes Response * * This function is called by the application framework when a Discover