Add OTA Requestor for light app and fix on-off command bug

This commit is contained in:
WanqQixiang
2021-12-16 19:05:08 +08:00
parent 4688b10e0c
commit 26a49b27cb
39 changed files with 12191 additions and 11966 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ esp_err_t light_driver_init(light_driver_config_t *config)
esp_err_t light_driver_set_power(bool power)
{
current_power = power;
return ESP_OK;
return light_driver_set_brightness(current_brightness);
}
esp_err_t light_driver_set_brightness(uint8_t brightness)
+1 -1
View File
@@ -140,7 +140,7 @@ esp_err_t light_driver_init(light_driver_config_t *config)
esp_err_t light_driver_set_power(bool power)
{
current_power = power;
return ESP_OK;
return light_driver_set_brightness(current_brightness);
}
esp_err_t light_driver_set_RGB()
{
@@ -53,7 +53,7 @@ esp_err_t light_driver_init(light_driver_config_t *config)
esp_err_t light_driver_set_power(bool power)
{
current_power = power;
return ESP_OK;
return light_driver_set_brightness(current_brightness);
}
esp_err_t light_driver_set_RGB()
+8 -5
View File
@@ -8,13 +8,16 @@ set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}"
"${MATTER_SDK_PATH}/src/app/clusters/administrator-commissioning-server"
"${MATTER_SDK_PATH}/src/app/clusters/application-basic-server"
"${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server"
"${MATTER_SDK_PATH}/src/app/clusters/general_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/general-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/fixed-label-server"
"${MATTER_SDK_PATH}/src/app/clusters/user-label-server"
"${MATTER_SDK_PATH}/src/app/clusters/identify-server"
"${MATTER_SDK_PATH}/src/app/clusters/ota-requestor"
"${MATTER_SDK_PATH}/src/app/clusters/network-commissioning"
"${MATTER_SDK_PATH}/src/app/clusters/diagnostic-logs-server"
"${MATTER_SDK_PATH}/src/app/clusters/software_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/thread_network_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/wifi_network_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/software-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/thread-network-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/wifi-network-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/on-off-server"
"${MATTER_SDK_PATH}/src/app/clusters/operational-credentials-server"
"${MATTER_SDK_PATH}/src/app/clusters/descriptor"
@@ -26,7 +29,7 @@ set(PRIV_INCLUDE_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}"
"${MATTER_SDK_PATH}/zzz_generated/app-common")
set(PRIV_REQUIRES_LIST
chip bt esp32_mbedtls esp_matter esp_matter_console app_driver app_qrcode app_openthread route_hook)
chip bt esp32_mbedtls esp_matter esp_matter_console app_driver app_qrcode app_openthread route_hook app_update)
if ("${IDF_TARGET}" STREQUAL "esp32h2")
list(APPEND PRIV_REQUIRES_LIST openthread)
+4
View File
@@ -9,6 +9,7 @@
#include "app_constants.h"
#include "app_driver.h"
#include "app_matter.h"
#include "app_ota.h"
#include "app_qrcode.h"
#include "esp_matter.h"
#include "esp_matter_console.h"
@@ -82,6 +83,9 @@ extern "C" void app_main()
#if CONFIG_ENABLE_CHIP_SHELL
esp_matter_console_diagnostics_register_commands();
#if CONFIG_ENABLE_OTA_REQUESTOR
esp_matter_console_ota_register_commands();
#endif
esp_matter_console_init();
#endif
}
+4 -1
View File
@@ -8,6 +8,7 @@
#include "app_matter.h"
#include "app_constants.h"
#include "app_ota.h"
#include "esp_matter.h"
#include "esp_matter_standard.h"
@@ -298,7 +299,9 @@ esp_err_t app_matter_init()
PlatformMgr().ScheduleWork(matter_init_task, reinterpret_cast<intptr_t>(xTaskGetCurrentTaskHandle()));
// Wait for the matter stack to be initialized
xTaskNotifyWait(0, 0, NULL, portMAX_DELAY);
#if CONFIG_ENABLE_OTA_REQUESTOR
matter_ota_requestor_init();
#endif
esp_matter_attribute_callback_add(APP_MATTER_NAME, app_matter_attribute_update, NULL);
return ESP_OK;
}
+65
View File
@@ -0,0 +1,65 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <string.h>
#include <esp_log.h>
#include <esp_matter_console.h>
#include "OTAImageProcessorImpl.h"
#include "OTARequestorDriverImpl.h"
#include "platform/OTARequestorInterface.h"
#include "app/clusters/ota-requestor/BDXDownloader.h"
#include "app/clusters/ota-requestor/OTARequestor.h"
using chip::Server;
using chip::OTARequestor;
using chip::BDXDownloader;
using chip::OTAImageProcessorImpl;
using chip::OTARequestorDriverImpl;
static const char *TAG = "esp_matter_ota";
OTARequestor gRequestorCore;
OTARequestorDriverImpl gRequestorUser;
BDXDownloader gDownloader;
OTAImageProcessorImpl gImageProcessor;
static esp_err_t apply_image_handler(int argc, char** argv) {
chip::OTARequestor * requestor = reinterpret_cast<chip::OTARequestor *>(chip::GetRequestorInstance());
requestor->ApplyUpdate();
return ESP_OK;
}
static esp_err_t esp_matter_console_ota_handler(int argc, char** argv)
{
if (argc == 1 && strncmp(argv[0], "apply", sizeof("apply")) == 0) {
return apply_image_handler(argc, argv);
} else {
ESP_LOGE(TAG, "Incorrect arguments");
return ESP_FAIL;
}
return ESP_OK;
}
void esp_matter_console_ota_register_commands()
{
esp_matter_console_command_t command = {
.name = "ota",
.description = "ota command. Usage matter esp ota <ota_command>. OTA command: apply",
.handler = esp_matter_console_ota_handler,
};
esp_matter_console_add_command(&command);
}
void matter_ota_requestor_init(void)
{
chip::SetRequestorInstance(&gRequestorCore);
Server * server = &(Server::GetInstance());
gRequestorCore.SetServerInstance(server);
gRequestorCore.SetOtaRequestorDriver(&gRequestorUser);
gImageProcessor.SetOTADownloader(&gDownloader);
gDownloader.SetImageProcessorDelegate(&gImageProcessor);
gRequestorCore.SetBDXDownloader(&gDownloader);
}
+21
View File
@@ -0,0 +1,21 @@
/*
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include "esp_err.h"
/** Initialize the matter OTA Requestor
*
*/
void matter_ota_requestor_init(void);
/** Register the matter OTA commands
*
*/
void esp_matter_console_ota_register_commands(void);
+3930 -2690
View File
File diff suppressed because it is too large Load Diff
@@ -17,3 +17,158 @@
// THIS FILE IS GENERATED BY ZAP
#include <zap-generated/CHIPClientCallbacks.h>
#include <cinttypes>
#include <app-common/zap-generated/enums.h>
#include <app/util/CHIPDeviceCallbacksMgr.h>
#include <app/util/af-enums.h>
#include <app/util/af.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPEncoding.h>
#include <lib/support/SafeInt.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/logging/CHIPLogging.h>
using namespace ::chip;
using namespace ::chip::app::DataModel;
namespace {
[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2;
} // namespace
#define CHECK_STATUS_WITH_RETVAL(error, retval) \
if (CHIP_NO_ERROR != error) \
{ \
ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \
if (onFailureCallback != nullptr) \
{ \
Callback::Callback<DefaultFailureCallback> * cb = \
Callback::Callback<DefaultFailureCallback>::FromCancelable(onFailureCallback); \
cb->mCall(cb->mContext, static_cast<uint8_t>(EMBER_ZCL_STATUS_INVALID_VALUE)); \
} \
return retval; \
}
#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true)
#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, )
#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \
if (!CanCastTo<uint16_t>(value)) \
{ \
ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \
if (onFailureCallback != nullptr) \
{ \
Callback::Callback<DefaultFailureCallback> * cb = \
Callback::Callback<DefaultFailureCallback>::FromCancelable(onFailureCallback); \
cb->mCall(cb->mContext, static_cast<uint8_t>(EMBER_ZCL_STATUS_INVALID_VALUE)); \
} \
return retval; \
} \
\
if (messageLen < value) \
{ \
ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \
if (onFailureCallback != nullptr) \
{ \
Callback::Callback<DefaultFailureCallback> * cb = \
Callback::Callback<DefaultFailureCallback>::FromCancelable(onFailureCallback); \
cb->mCall(cb->mContext, static_cast<uint8_t>(EMBER_ZCL_STATUS_INVALID_VALUE)); \
} \
return retval; \
} \
\
messageLen = static_cast<uint16_t>(messageLen - static_cast<uint16_t>(value));
#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true)
#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, )
#define GET_RESPONSE_CALLBACKS(name) \
Callback::Cancelable * onSuccessCallback = nullptr; \
Callback::Cancelable * onFailureCallback = nullptr; \
NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \
uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \
CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \
\
if (CHIP_NO_ERROR != err) \
{ \
if (onSuccessCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing success callback", name); \
} \
\
if (onFailureCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing failure callback", name); \
} \
\
return true; \
}
#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \
Callback::Cancelable * onSuccessCallback = nullptr; \
Callback::Cancelable * onFailureCallback = nullptr; \
NodeId sourceIdentifier = reinterpret_cast<NodeId>(commandObj); \
/* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \
CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \
\
if (CHIP_NO_ERROR != err) \
{ \
if (onSuccessCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing success callback", name); \
} \
\
if (onFailureCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing failure callback", name); \
} \
\
return true; \
}
// Singleton instance of the callbacks manager
app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance();
bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj,
uint8_t action, uint32_t delayedActionTime)
{
ChipLogProgress(Zcl, "ApplyUpdateResponse:");
ChipLogProgress(Zcl, " action: %" PRIu8 "", action);
ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime);
GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback");
Callback::Callback<OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback> * cb =
Callback::Callback<OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback>::FromCancelable(onSuccessCallback);
cb->mCall(cb->mContext, action, delayedActionTime);
return true;
}
bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj,
uint8_t status, uint32_t delayedActionTime,
chip::CharSpan imageURI, uint32_t softwareVersion,
chip::CharSpan softwareVersionString,
chip::ByteSpan updateToken, bool userConsentNeeded,
chip::ByteSpan metadataForRequestor)
{
ChipLogProgress(Zcl, "QueryImageResponse:");
ChipLogProgress(Zcl, " status: %" PRIu8 "", status);
ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime);
ChipLogProgress(Zcl, " imageURI: %.*s", static_cast<int>(imageURI.size()), imageURI.data());
ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion);
ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast<int>(softwareVersionString.size()),
softwareVersionString.data());
ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size());
ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded);
ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size());
GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback");
Callback::Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback> * cb =
Callback::Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback>::FromCancelable(onSuccessCallback);
cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken,
userConsentNeeded, metadataForRequestor);
return true;
}
@@ -17,5 +17,28 @@
// THIS FILE IS GENERATED BY ZAP
#pragma once
#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/InteractionModelEngine.h>
#include <app/data-model/DecodableList.h>
#include <app/util/af-enums.h>
#include <app/util/attribute-filter.h>
#include <app/util/im-client-callbacks.h>
#include <inttypes.h>
#include <lib/support/FunctionTraits.h>
#include <lib/support/Span.h>
// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus
// instead of IM status code.
// #6308 should handle IM error code on the application side, either modify this function or remove this.
// Cluster Specific Response Callbacks
typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action,
uint32_t delayedActionTime);
typedef void (*OtaSoftwareUpdateProviderClusterQueryImageResponseCallback)(
void * context, uint8_t status, uint32_t delayedActionTime, chip::CharSpan imageURI, uint32_t softwareVersion,
chip::CharSpan softwareVersionString, chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor);
// List specific responses
@@ -17,3 +17,172 @@
// THIS FILE IS GENERATED BY ZAP
#include "CHIPClusters.h"
#include <app-common/zap-generated/ids/Attributes.h>
#include <zap-generated/CHIPClientCallbacks.h>
namespace chip {
using namespace app::Clusters;
using namespace System;
using namespace Encoding::LittleEndian;
namespace Controller {
// TODO(#4502): onCompletion is not used by IM for now.
// TODO(#4503): length should be passed to commands when byte string is in argument list.
// TODO(#4503): Commands should take group id as an argument.
// OtaSoftwareUpdateProvider Cluster Commands
CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t newVersion)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId,
OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id,
(app::CommandPathFlags::kEndpointIdValid) };
CommandSenderHandle sender(
Platform::New<app::CommandSender>(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager()));
VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY);
SuccessOrExit(err = sender->PrepareCommand(cmdParams));
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
// updateToken: octetString
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken));
// newVersion: int32u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion));
SuccessOrExit(err = sender->FinishCommand());
// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback);
SuccessOrExit(err = mDevice->SendCommands(sender.get()));
// We have successfully sent the command, and the callback handler will be responsible to free the object, release the object
// now.
sender.release();
exit:
return err;
}
CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t softwareVersion)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId,
OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id,
(app::CommandPathFlags::kEndpointIdValid) };
CommandSenderHandle sender(
Platform::New<app::CommandSender>(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager()));
VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY);
SuccessOrExit(err = sender->PrepareCommand(cmdParams));
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
// updateToken: octetString
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken));
// softwareVersion: int32u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion));
SuccessOrExit(err = sender->FinishCommand());
// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback);
SuccessOrExit(err = mDevice->SendCommands(sender.get()));
// We have successfully sent the command, and the callback handler will be responsible to free the object, release the object
// now.
sender.release();
exit:
return err;
}
CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback, chip::VendorId vendorId,
uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent,
chip::ByteSpan metadataForProvider)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId,
OtaSoftwareUpdateProvider::Commands::QueryImage::Id,
(app::CommandPathFlags::kEndpointIdValid) };
CommandSenderHandle sender(
Platform::New<app::CommandSender>(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager()));
VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY);
SuccessOrExit(err = sender->PrepareCommand(cmdParams));
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
// vendorId: vendorId
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId));
// productId: int16u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId));
// softwareVersion: int32u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion));
// protocolsSupported: OTADownloadProtocol
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported));
// hardwareVersion: int16u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion));
// location: charString
SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location));
// requestorCanConsent: boolean
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent));
// metadataForProvider: octetString
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider));
SuccessOrExit(err = sender->FinishCommand());
// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback);
SuccessOrExit(err = mDevice->SendCommands(sender.get()));
// We have successfully sent the command, and the callback handler will be responsible to free the object, release the object
// now.
sender.release();
exit:
return err;
}
} // namespace Controller
} // namespace chip
@@ -17,3 +17,35 @@
// THIS FILE IS GENERATED BY ZAP
// Prevent multiple inclusion
#pragma once
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <controller/CHIPCluster.h>
#include <lib/core/CHIPCallback.h>
#include <lib/support/Span.h>
namespace chip {
namespace Controller {
class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase
{
public:
OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {}
~OtaSoftwareUpdateProviderCluster() {}
// Cluster Commands
CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t newVersion);
CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t softwareVersion);
CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent,
chip::ByteSpan metadataForProvider);
};
} // namespace Controller
} // namespace chip
File diff suppressed because it is too large Load Diff
@@ -21,5 +21,23 @@
#include <app-common/zap-generated/callbacks/PluginCallbacks.h>
#define MATTER_PLUGINS_INIT MatterAdministratorCommissioningPluginServerInitCallback(); MatterBasicPluginServerInitCallback(); MatterColorControlPluginServerInitCallback(); MatterDescriptorPluginServerInitCallback(); MatterDiagnosticLogsPluginServerInitCallback(); MatterGeneralCommissioningPluginServerInitCallback(); MatterGeneralDiagnosticsPluginServerInitCallback(); MatterIdentifyPluginServerInitCallback(); MatterLevelControlPluginServerInitCallback(); MatterNetworkCommissioningPluginServerInitCallback(); MatterOnOffPluginServerInitCallback(); MatterOperationalCredentialsPluginServerInitCallback(); MatterSoftwareDiagnosticsPluginServerInitCallback(); MatterThreadNetworkDiagnosticsPluginServerInitCallback(); MatterWiFiNetworkDiagnosticsPluginServerInitCallback();
#define MATTER_PLUGINS_INIT \
MatterAdministratorCommissioningPluginServerInitCallback(); \
MatterBasicPluginServerInitCallback(); \
MatterColorControlPluginServerInitCallback(); \
MatterDescriptorPluginServerInitCallback(); \
MatterDiagnosticLogsPluginServerInitCallback(); \
MatterFixedLabelPluginServerInitCallback(); \
MatterGeneralCommissioningPluginServerInitCallback(); \
MatterGeneralDiagnosticsPluginServerInitCallback(); \
MatterIdentifyPluginServerInitCallback(); \
MatterLevelControlPluginServerInitCallback(); \
MatterNetworkCommissioningPluginServerInitCallback(); \
MatterOtaSoftwareUpdateProviderPluginClientInitCallback(); \
MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(); \
MatterOnOffPluginServerInitCallback(); \
MatterOperationalCredentialsPluginServerInitCallback(); \
MatterSoftwareDiagnosticsPluginServerInitCallback(); \
MatterThreadNetworkDiagnosticsPluginServerInitCallback(); \
MatterUserLabelPluginServerInitCallback(); \
MatterWiFiNetworkDiagnosticsPluginServerInitCallback();
@@ -1,483 +0,0 @@
/*
*
* 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.
*/
// THIS FILE IS GENERATED BY ZAP
#include <app-common/zap-generated/af-structs.h>
#include <app/util/af.h>
#include <app/util/attribute-list-byte-span.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPSafeCasts.h>
#include <lib/support/SafeInt.h>
#include <lib/support/logging/CHIPLogging.h>
using namespace chip;
using namespace chip::app::List;
// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
constexpr uint16_t kSizeLengthInBytes = 2u;
void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length)
{
if (write)
{
memmove(dest + *offset, src, length);
}
else
{
memmove(dest, src + *offset, length);
}
*offset = static_cast<uint16_t>(*offset + length);
}
uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, int32_t index)
{
if (index == -1)
{
memmove(dest, src, am->size);
return am->size;
}
if (index == 0)
{
if (write)
{
// src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value
emberAfCopyInt16u(dest, 0, *reinterpret_cast<uint16_t*>(src));
}
else
{
// src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t
*reinterpret_cast<uint16_t*>(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes);
}
return kSizeLengthInBytes;
}
if (!CanCastTo<uint16_t>(index))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index);
return 0;
}
uint16_t entryLength = 0;
switch (clusterId)
{
case 0x001D: // Descriptor Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // device list
{
entryLength = 6;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _DeviceType
_DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->type, write ? (uint8_t *)&entry->type : src, write, &entryOffset, sizeof(entry->type)); // DEVTYPE_ID
copyListMember(write ? dest : (uint8_t *)&entry->revision, write ? (uint8_t *)&entry->revision : src, write, &entryOffset, sizeof(entry->revision)); // INT16U
break;
}
case 0x0001: // server list
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID
break;
}
case 0x0002: // client list
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID
break;
}
case 0x0003: // parts list
{
entryLength = 2;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO
break;
}
}
break;
}
case 0x0030: // General Commissioning Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0001: // BasicCommissioningInfoList
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _BasicCommissioningInfoType
_BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->FailSafeExpiryLengthMs, write ? (uint8_t *)&entry->FailSafeExpiryLengthMs : src, write, &entryOffset, sizeof(entry->FailSafeExpiryLengthMs)); // INT32U
break;
}
}
break;
}
case 0x0033: // General Diagnostics Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // NetworkInterfaces
{
entryLength = 48;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _NetworkInterfaceType
_NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest);
ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING
ByteSpan * NameSpan = &NameSpanStorage;
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 34);
copyListMember(write ? dest : (uint8_t *)&entry->FabricConnected, write ? (uint8_t *)&entry->FabricConnected : src, write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->OffPremiseServicesReachableIPv4, write ? (uint8_t *)&entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->OffPremiseServicesReachableIPv6, write ? (uint8_t *)&entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN
ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 10);
copyListMember(write ? dest : (uint8_t *)&entry->Type, write ? (uint8_t *)&entry->Type : src, write, &entryOffset, sizeof(entry->Type)); // InterfaceType
break;
}
}
break;
}
case 0x003E: // Operational Credentials Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0001: // fabrics list
{
entryLength = 120;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _FabricDescriptor
_FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->FabricIndex, write ? (uint8_t *)&entry->FabricIndex : src, write, &entryOffset, sizeof(entry->FabricIndex)); // INT8U
ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 67);
copyListMember(write ? dest : (uint8_t *)&entry->VendorId, write ? (uint8_t *)&entry->VendorId : src, write, &entryOffset, sizeof(entry->VendorId)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->FabricId, write ? (uint8_t *)&entry->FabricId : src, write, &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID
copyListMember(write ? dest : (uint8_t *)&entry->NodeId, write ? (uint8_t *)&entry->NodeId : src, write, &entryOffset, sizeof(entry->NodeId)); // NODE_ID
ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING
ByteSpan * LabelSpan = &LabelSpanStorage;
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 34);
break;
}
case 0x0004: // TrustedRootCertificates
{
entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast<uint16_t>(index - 1));
if (entryOffset == 0)
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
ByteSpan * trustedRootCertificatesSpan = reinterpret_cast<ByteSpan *>(write ? src : dest); // OCTET_STRING
uint16_t trustedRootCertificatesRemainingSpace = static_cast<uint16_t>(am->size - entryOffset);
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
if (!CanCastTo<uint16_t>(trustedRootCertificatesSpan->size()))
{
ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size());
return 0;
}
entryLength = static_cast<uint16_t>(trustedRootCertificatesSpan->size());
break;
}
}
break;
}
case 0x0035: // Thread Network Diagnostics Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0007: // NeighborTableList
{
entryLength = 31;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _NeighborTable
_NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->ExtAddress, write ? (uint8_t *)&entry->ExtAddress : src, write, &entryOffset, sizeof(entry->ExtAddress)); // INT64U
copyListMember(write ? dest : (uint8_t *)&entry->Age, write ? (uint8_t *)&entry->Age : src, write, &entryOffset, sizeof(entry->Age)); // INT32U
copyListMember(write ? dest : (uint8_t *)&entry->Rloc16, write ? (uint8_t *)&entry->Rloc16 : src, write, &entryOffset, sizeof(entry->Rloc16)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->LinkFrameCounter, write ? (uint8_t *)&entry->LinkFrameCounter : src, write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U
copyListMember(write ? dest : (uint8_t *)&entry->MleFrameCounter, write ? (uint8_t *)&entry->MleFrameCounter : src, write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U
copyListMember(write ? dest : (uint8_t *)&entry->LQI, write ? (uint8_t *)&entry->LQI : src, write, &entryOffset, sizeof(entry->LQI)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->AverageRssi, write ? (uint8_t *)&entry->AverageRssi : src, write, &entryOffset, sizeof(entry->AverageRssi)); // INT8S
copyListMember(write ? dest : (uint8_t *)&entry->LastRssi, write ? (uint8_t *)&entry->LastRssi : src, write, &entryOffset, sizeof(entry->LastRssi)); // INT8S
copyListMember(write ? dest : (uint8_t *)&entry->FrameErrorRate, write ? (uint8_t *)&entry->FrameErrorRate : src, write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->MessageErrorRate, write ? (uint8_t *)&entry->MessageErrorRate : src, write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->RxOnWhenIdle, write ? (uint8_t *)&entry->RxOnWhenIdle : src, write, &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->FullThreadDevice, write ? (uint8_t *)&entry->FullThreadDevice : src, write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->FullNetworkData, write ? (uint8_t *)&entry->FullNetworkData : src, write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->IsChild, write ? (uint8_t *)&entry->IsChild : src, write, &entryOffset, sizeof(entry->IsChild)); // BOOLEAN
break;
}
case 0x0008: // RouteTableList
{
entryLength = 18;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _RouteTable
_RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->ExtAddress, write ? (uint8_t *)&entry->ExtAddress : src, write, &entryOffset, sizeof(entry->ExtAddress)); // INT64U
copyListMember(write ? dest : (uint8_t *)&entry->Rloc16, write ? (uint8_t *)&entry->Rloc16 : src, write, &entryOffset, sizeof(entry->Rloc16)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->RouterId, write ? (uint8_t *)&entry->RouterId : src, write, &entryOffset, sizeof(entry->RouterId)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->NextHop, write ? (uint8_t *)&entry->NextHop : src, write, &entryOffset, sizeof(entry->NextHop)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->PathCost, write ? (uint8_t *)&entry->PathCost : src, write, &entryOffset, sizeof(entry->PathCost)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->LQIIn, write ? (uint8_t *)&entry->LQIIn : src, write, &entryOffset, sizeof(entry->LQIIn)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->LQIOut, write ? (uint8_t *)&entry->LQIOut : src, write, &entryOffset, sizeof(entry->LQIOut)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->Age, write ? (uint8_t *)&entry->Age : src, write, &entryOffset, sizeof(entry->Age)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->Allocated, write ? (uint8_t *)&entry->Allocated : src, write, &entryOffset, sizeof(entry->Allocated)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->LinkEstablished, write ? (uint8_t *)&entry->LinkEstablished : src, write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN
break;
}
case 0x003B: // SecurityPolicy
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _SecurityPolicy
_SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->RotationTime, write ? (uint8_t *)&entry->RotationTime : src, write, &entryOffset, sizeof(entry->RotationTime)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->Flags, write ? (uint8_t *)&entry->Flags : src, write, &entryOffset, sizeof(entry->Flags)); // BITMAP16
break;
}
case 0x003D: // OperationalDatasetComponents
{
entryLength = 12;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _OperationalDatasetComponents
_OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->ActiveTimestampPresent, write ? (uint8_t *)&entry->ActiveTimestampPresent : src, write, &entryOffset, sizeof(entry->ActiveTimestampPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->PendingTimestampPresent, write ? (uint8_t *)&entry->PendingTimestampPresent : src, write, &entryOffset, sizeof(entry->PendingTimestampPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->MasterKeyPresent, write ? (uint8_t *)&entry->MasterKeyPresent : src, write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->NetworkNamePresent, write ? (uint8_t *)&entry->NetworkNamePresent : src, write, &entryOffset, sizeof(entry->NetworkNamePresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->ExtendedPanIdPresent, write ? (uint8_t *)&entry->ExtendedPanIdPresent : src, write, &entryOffset, sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->MeshLocalPrefixPresent, write ? (uint8_t *)&entry->MeshLocalPrefixPresent : src, write, &entryOffset, sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->DelayPresent, write ? (uint8_t *)&entry->DelayPresent : src, write, &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->PanIdPresent, write ? (uint8_t *)&entry->PanIdPresent : src, write, &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->ChannelPresent, write ? (uint8_t *)&entry->ChannelPresent : src, write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->PskcPresent, write ? (uint8_t *)&entry->PskcPresent : src, write, &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->SecurityPolicyPresent, write ? (uint8_t *)&entry->SecurityPolicyPresent : src, write, &entryOffset, sizeof(entry->SecurityPolicyPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->ChannelMaskPresent, write ? (uint8_t *)&entry->ChannelMaskPresent : src, write, &entryOffset, sizeof(entry->ChannelMaskPresent)); // BOOLEAN
break;
}
case 0x003E: // ActiveNetworkFaultsList
{
entryLength = 1;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault
break;
}
}
break;
}
}
return entryLength;
}
// A list is a collection of entries of the same data type. The data type may be any defined data type.
uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer)
{
// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes);
if (entryCount == 0xFFFF)
{
return 0;
}
uint16_t entryLength = 0;
switch (clusterId)
{
case 0x001D: // Descriptor Cluster
switch (attributeId)
{
case 0x0000: // device list
// Struct _DeviceType
entryLength = 6;
break;
case 0x0001: // server list
// chip::ClusterId
entryLength = 4;
break;
case 0x0002: // client list
// chip::ClusterId
entryLength = 4;
break;
case 0x0003: // parts list
// chip::EndpointId
entryLength = 2;
break;
}
break;
case 0x0030: // General Commissioning Cluster
switch (attributeId)
{
case 0x0001: // BasicCommissioningInfoList
// Struct _BasicCommissioningInfoType
entryLength = 4;
break;
}
break;
case 0x0033: // General Diagnostics Cluster
switch (attributeId)
{
case 0x0000: // NetworkInterfaces
// Struct _NetworkInterfaceType
entryLength = 48;
break;
}
break;
case 0x003E: // Operational Credentials Cluster
switch (attributeId)
{
case 0x0001: // fabrics list
// Struct _FabricDescriptor
entryLength = 120;
break;
case 0x0004: // TrustedRootCertificates
// chip::ByteSpan
return GetByteSpanOffsetFromIndex(buffer, 402, entryCount);
break;
}
break;
case 0x0035: // Thread Network Diagnostics Cluster
switch (attributeId)
{
case 0x0007: // NeighborTableList
// Struct _NeighborTable
entryLength = 31;
break;
case 0x0008: // RouteTableList
// Struct _RouteTable
entryLength = 18;
break;
case 0x003B: // SecurityPolicy
// Struct _SecurityPolicy
entryLength = 4;
break;
case 0x003D: // OperationalDatasetComponents
// Struct _OperationalDatasetComponents
entryLength = 12;
break;
case 0x003E: // ActiveNetworkFaultsList
// uint8_t
entryLength = 1;
break;
}
break;
}
uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength);
if (!CanCastTo<uint16_t>(totalSize))
{
ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));
return 0;
}
return static_cast<uint16_t>(totalSize);
}
@@ -29,49 +29,61 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
{
switch (clusterId)
{
case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID :
case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID:
emberAfAdministratorCommissioningClusterInitCallback(endpoint);
break;
case ZCL_BASIC_CLUSTER_ID :
case ZCL_BASIC_CLUSTER_ID:
emberAfBasicClusterInitCallback(endpoint);
break;
case ZCL_COLOR_CONTROL_CLUSTER_ID :
case ZCL_COLOR_CONTROL_CLUSTER_ID:
emberAfColorControlClusterInitCallback(endpoint);
break;
case ZCL_DESCRIPTOR_CLUSTER_ID :
case ZCL_DESCRIPTOR_CLUSTER_ID:
emberAfDescriptorClusterInitCallback(endpoint);
break;
case ZCL_DIAGNOSTIC_LOGS_CLUSTER_ID :
case ZCL_DIAGNOSTIC_LOGS_CLUSTER_ID:
emberAfDiagnosticLogsClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID :
case ZCL_FIXED_LABEL_CLUSTER_ID:
emberAfFixedLabelClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID:
emberAfGeneralCommissioningClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID :
case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID:
emberAfGeneralDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_IDENTIFY_CLUSTER_ID :
case ZCL_IDENTIFY_CLUSTER_ID:
emberAfIdentifyClusterInitCallback(endpoint);
break;
case ZCL_LEVEL_CONTROL_CLUSTER_ID :
case ZCL_LEVEL_CONTROL_CLUSTER_ID:
emberAfLevelControlClusterInitCallback(endpoint);
break;
case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID :
case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID:
emberAfNetworkCommissioningClusterInitCallback(endpoint);
break;
case ZCL_ON_OFF_CLUSTER_ID :
case ZCL_OTA_PROVIDER_CLUSTER_ID:
emberAfOtaSoftwareUpdateProviderClusterInitCallback(endpoint);
break;
case ZCL_OTA_REQUESTOR_CLUSTER_ID:
emberAfOtaSoftwareUpdateRequestorClusterInitCallback(endpoint);
break;
case ZCL_ON_OFF_CLUSTER_ID:
emberAfOnOffClusterInitCallback(endpoint);
break;
case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID :
case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID:
emberAfOperationalCredentialsClusterInitCallback(endpoint);
break;
case ZCL_SOFTWARE_DIAGNOSTICS_CLUSTER_ID :
case ZCL_SOFTWARE_DIAGNOSTICS_CLUSTER_ID:
emberAfSoftwareDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID :
case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID:
emberAfThreadNetworkDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID :
case ZCL_USER_LABEL_CLUSTER_ID:
emberAfUserLabelClusterInitCallback(endpoint);
break;
case ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID:
emberAfWiFiNetworkDiagnosticsClusterInitCallback(endpoint);
break;
default:
@@ -105,6 +117,11 @@ void __attribute__((weak)) emberAfDiagnosticLogsClusterInitCallback(EndpointId e
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfFixedLabelClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfGeneralCommissioningClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
@@ -130,6 +147,16 @@ void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(Endpoi
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOtaSoftwareUpdateProviderClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOtaSoftwareUpdateRequestorClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
@@ -150,6 +177,11 @@ void __attribute__((weak)) emberAfThreadNetworkDiagnosticsClusterInitCallback(En
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfUserLabelClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfWiFiNetworkDiagnosticsClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
@@ -164,60 +196,51 @@ void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicatio
void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
EmberAfAttributeWritePermission __attribute__((weak)) emberAfAllowNetworkWriteAttributeCallback(
EndpointId endpoint, ClusterId clusterId,
AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode, uint8_t * value, uint8_t type)
EmberAfAttributeWritePermission __attribute__((weak))
emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode, uint8_t * value, uint8_t type)
{
return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
}
bool __attribute__((weak)) emberAfAttributeReadAccessCallback(
EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode,
AttributeId attributeId)
bool __attribute__((weak))
emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
{
return true;
}
bool __attribute__((weak)) emberAfAttributeWriteAccessCallback(
EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode,
AttributeId attributeId)
bool __attribute__((weak))
emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
{
return true;
}
bool __attribute__((weak)) emberAfDefaultResponseCallback(
ClusterId clusterId, CommandId commandId, EmberAfStatus status)
bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
{
return false;
}
bool __attribute__((weak)) emberAfPreMessageSendCallback(
EmberAfMessageStruct * messageStruct, EmberStatus * status)
bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
{
return false;
}
bool __attribute__((weak)) emberAfMessageSentCallback(
const MessageSendDestination & destination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status)
bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status)
{
return false;
}
EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(
EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, uint16_t maxReadLength, int32_t index)
EmberAfStatus __attribute__((weak))
emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
{
return EMBER_ZCL_STATUS_FAILURE;
}
EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(
EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, int32_t index)
EmberAfStatus __attribute__((weak))
emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
uint16_t manufacturerCode, uint8_t * buffer)
{
return EMBER_ZCL_STATUS_FAILURE;
}
@@ -227,17 +250,16 @@ uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
return 0;
}
bool __attribute__((weak)) emberAfGetEndpointInfoCallback(
EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo)
bool __attribute__((weak))
emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
{
return false;
}
void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
EmberStatus __attribute__((weak)) emberAfInterpanSendMessageCallback(
EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
EmberStatus __attribute__((weak))
emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
{
return EMBER_LIBRARY_NOT_PRESENT;
}
@@ -247,15 +269,13 @@ bool __attribute__((weak)) emberAfStartMoveCallback()
return false;
}
chip::Protocols::InteractionModel::Status __attribute__((weak)) MatterPreAttributeChangeCallback(
const chip::app::ConcreteAttributePath & attributePath,
uint8_t mask, uint8_t type, uint16_t size, uint8_t * value)
chip::Protocols::InteractionModel::Status __attribute__((weak))
MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, uint16_t size,
uint8_t * value)
{
return chip::Protocols::InteractionModel::Status::Success;
}
void __attribute__((weak)) MatterPostAttributeChangeCallback(
const chip::app::ConcreteAttributePath & attributePath,
uint8_t mask, uint8_t type, uint16_t size, uint8_t * value)
{
}
void __attribute__((weak)) MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask,
uint8_t type, uint16_t size, uint8_t * value)
{}
File diff suppressed because it is too large Load Diff
@@ -1,19 +0,0 @@
/*
*
* 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.
*/
// THIS FILE IS GENERATED BY ZAP
@@ -1,19 +0,0 @@
/*
*
* 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.
*/
// THIS FILE IS GENERATED BY ZAP
File diff suppressed because it is too large Load Diff
+23 -1
View File
@@ -26,7 +26,6 @@
/**** Network Section ****/
#define EMBER_SUPPORTED_NETWORKS (1)
#define EMBER_APS_UNICAST_MESSAGE_COUNT 10
/**** Cluster endpoint counts ****/
@@ -35,15 +34,19 @@
#define EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_DESCRIPTOR_CLUSTER_SERVER_ENDPOINT_COUNT (2)
#define EMBER_AF_DIAGNOSTIC_LOGS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_FIXED_LABEL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_GENERAL_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OTA_PROVIDER_CLUSTER_CLIENT_ENDPOINT_COUNT (1)
#define EMBER_AF_OTA_REQUESTOR_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_SOFTWARE_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_USER_LABEL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
/**** Cluster Plugins ****/
@@ -77,6 +80,11 @@
#define EMBER_AF_PLUGIN_DIAGNOSTIC_LOGS_SERVER
#define EMBER_AF_PLUGIN_DIAGNOSTIC_LOGS
// Use this macro to check if the server side of the Fixed Label cluster is included
#define ZCL_USING_FIXED_LABEL_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_FIXED_LABEL_SERVER
#define EMBER_AF_PLUGIN_FIXED_LABEL
// Use this macro to check if the server side of the General Commissioning cluster is included
#define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_SERVER
@@ -106,6 +114,15 @@
#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER
#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING
// Use this macro to check if the client side of the OTA Software Update Provider cluster is included
#define ZCL_USING_OTA_PROVIDER_CLUSTER_CLIENT
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_CLIENT
// Use this macro to check if the server side of the OTA Software Update Requestor cluster is included
#define ZCL_USING_OTA_REQUESTOR_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR_SERVER
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR
// Use this macro to check if the server side of the On/Off cluster is included
#define ZCL_USING_ON_OFF_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_ON_OFF_SERVER
@@ -126,6 +143,11 @@
#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS_SERVER
#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS
// Use this macro to check if the server side of the User Label cluster is included
#define ZCL_USING_USER_LABEL_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_USER_LABEL_SERVER
#define EMBER_AF_PLUGIN_USER_LABEL
// Use this macro to check if the server side of the WiFi Network Diagnostics cluster is included
#define ZCL_USING_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_WI_FI_NETWORK_DIAGNOSTICS_SERVER
+4 -4
View File
@@ -21,6 +21,7 @@ CONFIG_NEWTOS_ENABLE=n
CONFIG_BLE_50_FEATURE_SUPPORT=y
CONFIG_BLE_HCI_UART_BAUD=921600
CONFIG_BLE_EXT_ADV=n
CONFIG_BLE_LOG_LEVEL=1
# Enable OpenThread
CONFIG_OPENTHREAD_ENABLED=y
@@ -50,13 +51,12 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_ECJPAKE=y
# MDNS platform
CONFIG_USE_MINIMAL_MDNS=n
# Disable Matter Shell
CONFIG_ENABLE_CHIP_SHELL=n
# Increase stacks size
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
CONFIG_NIMBLE_CONTROLLER_TASK_STACK_SIZE=5120
CONFIG_NIMBLE_HOST_TASK_STACK_SIZE=5120
# ESP32H2 BLE using a ext 32k crystal
CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y
# Enable OTA Requestor
CONFIG_ENABLE_OTA_REQUESTOR=y
+7 -4
View File
@@ -8,14 +8,17 @@ set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}"
"${MATTER_SDK_PATH}/src/app/clusters/administrator-commissioning-server"
"${MATTER_SDK_PATH}/src/app/clusters/application-basic-server"
"${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server"
"${MATTER_SDK_PATH}/src/app/clusters/general_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/general-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/identify-server"
"${MATTER_SDK_PATH}/src/app/clusters/user-label-server"
"${MATTER_SDK_PATH}/src/app/clusters/fixed-label-server"
"${MATTER_SDK_PATH}/src/app/clusters/ota-requestor"
"${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server"
"${MATTER_SDK_PATH}/src/app/clusters/network-commissioning"
"${MATTER_SDK_PATH}/src/app/clusters/diagnostic-logs-server"
"${MATTER_SDK_PATH}/src/app/clusters/software_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/thread_network_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/wifi_network_diagnostics_server"
"${MATTER_SDK_PATH}/src/app/clusters/software-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/thread-network-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/wifi-network-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/on-off-server"
"${MATTER_SDK_PATH}/src/app/clusters/operational-credentials-server"
"${MATTER_SDK_PATH}/src/app/clusters/descriptor"
File diff suppressed because it is too large Load Diff
@@ -17,3 +17,158 @@
// THIS FILE IS GENERATED BY ZAP
#include <zap-generated/CHIPClientCallbacks.h>
#include <cinttypes>
#include <app-common/zap-generated/enums.h>
#include <app/util/CHIPDeviceCallbacksMgr.h>
#include <app/util/af-enums.h>
#include <app/util/af.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPEncoding.h>
#include <lib/support/SafeInt.h>
#include <lib/support/TypeTraits.h>
#include <lib/support/logging/CHIPLogging.h>
using namespace ::chip;
using namespace ::chip::app::DataModel;
namespace {
[[maybe_unused]] constexpr uint16_t kByteSpanSizeLengthInBytes = 2;
} // namespace
#define CHECK_STATUS_WITH_RETVAL(error, retval) \
if (CHIP_NO_ERROR != error) \
{ \
ChipLogError(Zcl, "CHECK_STATUS %s", ErrorStr(error)); \
if (onFailureCallback != nullptr) \
{ \
Callback::Callback<DefaultFailureCallback> * cb = \
Callback::Callback<DefaultFailureCallback>::FromCancelable(onFailureCallback); \
cb->mCall(cb->mContext, static_cast<uint8_t>(EMBER_ZCL_STATUS_INVALID_VALUE)); \
} \
return retval; \
}
#define CHECK_STATUS(error) CHECK_STATUS_WITH_RETVAL(error, true)
#define CHECK_STATUS_VOID(error) CHECK_STATUS_WITH_RETVAL(error, )
#define CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, retval) \
if (!CanCastTo<uint16_t>(value)) \
{ \
ChipLogError(Zcl, "CHECK_MESSAGE_LENGTH expects a uint16_t value, got: %d", value); \
if (onFailureCallback != nullptr) \
{ \
Callback::Callback<DefaultFailureCallback> * cb = \
Callback::Callback<DefaultFailureCallback>::FromCancelable(onFailureCallback); \
cb->mCall(cb->mContext, static_cast<uint8_t>(EMBER_ZCL_STATUS_INVALID_VALUE)); \
} \
return retval; \
} \
\
if (messageLen < value) \
{ \
ChipLogError(Zcl, "Unexpected response length: %d", messageLen); \
if (onFailureCallback != nullptr) \
{ \
Callback::Callback<DefaultFailureCallback> * cb = \
Callback::Callback<DefaultFailureCallback>::FromCancelable(onFailureCallback); \
cb->mCall(cb->mContext, static_cast<uint8_t>(EMBER_ZCL_STATUS_INVALID_VALUE)); \
} \
return retval; \
} \
\
messageLen = static_cast<uint16_t>(messageLen - static_cast<uint16_t>(value));
#define CHECK_MESSAGE_LENGTH(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, true)
#define CHECK_MESSAGE_LENGTH_VOID(value) CHECK_MESSAGE_LENGTH_WITH_RETVAL(value, )
#define GET_RESPONSE_CALLBACKS(name) \
Callback::Cancelable * onSuccessCallback = nullptr; \
Callback::Cancelable * onFailureCallback = nullptr; \
NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \
uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \
CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \
\
if (CHIP_NO_ERROR != err) \
{ \
if (onSuccessCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing success callback", name); \
} \
\
if (onFailureCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing failure callback", name); \
} \
\
return true; \
}
#define GET_CLUSTER_RESPONSE_CALLBACKS(name) \
Callback::Cancelable * onSuccessCallback = nullptr; \
Callback::Cancelable * onFailureCallback = nullptr; \
NodeId sourceIdentifier = reinterpret_cast<NodeId>(commandObj); \
/* #6559: Currently, we only have one commands for the IMInvokeCommands and to a device, so the seqNum is always set to 0. */ \
CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceIdentifier, 0, &onSuccessCallback, &onFailureCallback); \
\
if (CHIP_NO_ERROR != err) \
{ \
if (onSuccessCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing success callback", name); \
} \
\
if (onFailureCallback == nullptr) \
{ \
ChipLogDetail(Zcl, "%s: Missing failure callback", name); \
} \
\
return true; \
}
// Singleton instance of the callbacks manager
app::CHIPDeviceCallbacksMgr & gCallbacks = app::CHIPDeviceCallbacksMgr::GetInstance();
bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback(EndpointId endpoint, app::CommandSender * commandObj,
uint8_t action, uint32_t delayedActionTime)
{
ChipLogProgress(Zcl, "ApplyUpdateResponse:");
ChipLogProgress(Zcl, " action: %" PRIu8 "", action);
ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime);
GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback");
Callback::Callback<OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback> * cb =
Callback::Callback<OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback>::FromCancelable(onSuccessCallback);
cb->mCall(cb->mContext, action, delayedActionTime);
return true;
}
bool emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback(EndpointId endpoint, app::CommandSender * commandObj,
uint8_t status, uint32_t delayedActionTime,
chip::CharSpan imageURI, uint32_t softwareVersion,
chip::CharSpan softwareVersionString,
chip::ByteSpan updateToken, bool userConsentNeeded,
chip::ByteSpan metadataForRequestor)
{
ChipLogProgress(Zcl, "QueryImageResponse:");
ChipLogProgress(Zcl, " status: %" PRIu8 "", status);
ChipLogProgress(Zcl, " delayedActionTime: %" PRIu32 "", delayedActionTime);
ChipLogProgress(Zcl, " imageURI: %.*s", static_cast<int>(imageURI.size()), imageURI.data());
ChipLogProgress(Zcl, " softwareVersion: %" PRIu32 "", softwareVersion);
ChipLogProgress(Zcl, " softwareVersionString: %.*s", static_cast<int>(softwareVersionString.size()),
softwareVersionString.data());
ChipLogProgress(Zcl, " updateToken: %zu", updateToken.size());
ChipLogProgress(Zcl, " userConsentNeeded: %d", userConsentNeeded);
ChipLogProgress(Zcl, " metadataForRequestor: %zu", metadataForRequestor.size());
GET_CLUSTER_RESPONSE_CALLBACKS("OtaSoftwareUpdateProviderClusterQueryImageResponseCallback");
Callback::Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback> * cb =
Callback::Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback>::FromCancelable(onSuccessCallback);
cb->mCall(cb->mContext, status, delayedActionTime, imageURI, softwareVersion, softwareVersionString, updateToken,
userConsentNeeded, metadataForRequestor);
return true;
}
@@ -17,5 +17,28 @@
// THIS FILE IS GENERATED BY ZAP
#pragma once
#include <app-common/zap-generated/af-structs.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/InteractionModelEngine.h>
#include <app/data-model/DecodableList.h>
#include <app/util/af-enums.h>
#include <app/util/attribute-filter.h>
#include <app/util/im-client-callbacks.h>
#include <inttypes.h>
#include <lib/support/FunctionTraits.h>
#include <lib/support/Span.h>
// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus
// instead of IM status code.
// #6308 should handle IM error code on the application side, either modify this function or remove this.
// Cluster Specific Response Callbacks
typedef void (*OtaSoftwareUpdateProviderClusterApplyUpdateResponseCallback)(void * context, uint8_t action,
uint32_t delayedActionTime);
typedef void (*OtaSoftwareUpdateProviderClusterQueryImageResponseCallback)(
void * context, uint8_t status, uint32_t delayedActionTime, chip::CharSpan imageURI, uint32_t softwareVersion,
chip::CharSpan softwareVersionString, chip::ByteSpan updateToken, bool userConsentNeeded, chip::ByteSpan metadataForRequestor);
// List specific responses
@@ -17,3 +17,172 @@
// THIS FILE IS GENERATED BY ZAP
#include "CHIPClusters.h"
#include <app-common/zap-generated/ids/Attributes.h>
#include <zap-generated/CHIPClientCallbacks.h>
namespace chip {
using namespace app::Clusters;
using namespace System;
using namespace Encoding::LittleEndian;
namespace Controller {
// TODO(#4502): onCompletion is not used by IM for now.
// TODO(#4503): length should be passed to commands when byte string is in argument list.
// TODO(#4503): Commands should take group id as an argument.
// OtaSoftwareUpdateProvider Cluster Commands
CHIP_ERROR OtaSoftwareUpdateProviderCluster::ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t newVersion)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId,
OtaSoftwareUpdateProvider::Commands::ApplyUpdateRequest::Id,
(app::CommandPathFlags::kEndpointIdValid) };
CommandSenderHandle sender(
Platform::New<app::CommandSender>(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager()));
VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY);
SuccessOrExit(err = sender->PrepareCommand(cmdParams));
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
// updateToken: octetString
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken));
// newVersion: int32u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), newVersion));
SuccessOrExit(err = sender->FinishCommand());
// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback);
SuccessOrExit(err = mDevice->SendCommands(sender.get()));
// We have successfully sent the command, and the callback handler will be responsible to free the object, release the object
// now.
sender.release();
exit:
return err;
}
CHIP_ERROR OtaSoftwareUpdateProviderCluster::NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t softwareVersion)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId,
OtaSoftwareUpdateProvider::Commands::NotifyUpdateApplied::Id,
(app::CommandPathFlags::kEndpointIdValid) };
CommandSenderHandle sender(
Platform::New<app::CommandSender>(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager()));
VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY);
SuccessOrExit(err = sender->PrepareCommand(cmdParams));
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
// updateToken: octetString
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateToken));
// softwareVersion: int32u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion));
SuccessOrExit(err = sender->FinishCommand());
// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback);
SuccessOrExit(err = mDevice->SendCommands(sender.get()));
// We have successfully sent the command, and the callback handler will be responsible to free the object, release the object
// now.
sender.release();
exit:
return err;
}
CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback, chip::VendorId vendorId,
uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent,
chip::ByteSpan metadataForProvider)
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
uint8_t argSeqNumber = 0;
// Used when encoding non-empty command. Suppress error message when encoding empty commands.
(void) writer;
(void) argSeqNumber;
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId,
OtaSoftwareUpdateProvider::Commands::QueryImage::Id,
(app::CommandPathFlags::kEndpointIdValid) };
CommandSenderHandle sender(
Platform::New<app::CommandSender>(mDevice->GetInteractionModelDelegate(), mDevice->GetExchangeManager()));
VerifyOrReturnError(sender != nullptr, CHIP_ERROR_NO_MEMORY);
SuccessOrExit(err = sender->PrepareCommand(cmdParams));
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
// vendorId: vendorId
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId));
// productId: int16u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), productId));
// softwareVersion: int32u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), softwareVersion));
// protocolsSupported: OTADownloadProtocol
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), protocolsSupported));
// hardwareVersion: int16u
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), hardwareVersion));
// location: charString
SuccessOrExit(err = writer->PutString(TLV::ContextTag(argSeqNumber++), location));
// requestorCanConsent: boolean
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), requestorCanConsent));
// metadataForProvider: octetString
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForProvider));
SuccessOrExit(err = sender->FinishCommand());
// #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate.
mDevice->AddIMResponseHandler(sender.get(), onSuccessCallback, onFailureCallback);
SuccessOrExit(err = mDevice->SendCommands(sender.get()));
// We have successfully sent the command, and the callback handler will be responsible to free the object, release the object
// now.
sender.release();
exit:
return err;
}
} // namespace Controller
} // namespace chip
@@ -17,3 +17,35 @@
// THIS FILE IS GENERATED BY ZAP
// Prevent multiple inclusion
#pragma once
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <controller/CHIPCluster.h>
#include <lib/core/CHIPCallback.h>
#include <lib/support/Span.h>
namespace chip {
namespace Controller {
class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase
{
public:
OtaSoftwareUpdateProviderCluster() : ClusterBase(app::Clusters::OtaSoftwareUpdateProvider::Id) {}
~OtaSoftwareUpdateProviderCluster() {}
// Cluster Commands
CHIP_ERROR ApplyUpdateRequest(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t newVersion);
CHIP_ERROR NotifyUpdateApplied(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
chip::ByteSpan updateToken, uint32_t softwareVersion);
CHIP_ERROR QueryImage(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
chip::VendorId vendorId, uint16_t productId, uint32_t softwareVersion, uint8_t protocolsSupported,
uint16_t hardwareVersion, chip::CharSpan location, bool requestorCanConsent,
chip::ByteSpan metadataForProvider);
};
} // namespace Controller
} // namespace chip
File diff suppressed because it is too large Load Diff
@@ -21,5 +21,23 @@
#include <app-common/zap-generated/callbacks/PluginCallbacks.h>
#define MATTER_PLUGINS_INIT MatterAdministratorCommissioningPluginServerInitCallback(); MatterBasicPluginServerInitCallback(); MatterColorControlPluginServerInitCallback(); MatterDescriptorPluginServerInitCallback(); MatterDiagnosticLogsPluginServerInitCallback(); MatterGeneralCommissioningPluginServerInitCallback(); MatterGeneralDiagnosticsPluginServerInitCallback(); MatterIdentifyPluginServerInitCallback(); MatterLevelControlPluginServerInitCallback(); MatterNetworkCommissioningPluginServerInitCallback(); MatterOnOffPluginServerInitCallback(); MatterOperationalCredentialsPluginServerInitCallback(); MatterSoftwareDiagnosticsPluginServerInitCallback(); MatterThreadNetworkDiagnosticsPluginServerInitCallback(); MatterWiFiNetworkDiagnosticsPluginServerInitCallback();
#define MATTER_PLUGINS_INIT \
MatterAdministratorCommissioningPluginServerInitCallback(); \
MatterBasicPluginServerInitCallback(); \
MatterColorControlPluginServerInitCallback(); \
MatterDescriptorPluginServerInitCallback(); \
MatterDiagnosticLogsPluginServerInitCallback(); \
MatterFixedLabelPluginServerInitCallback(); \
MatterGeneralCommissioningPluginServerInitCallback(); \
MatterGeneralDiagnosticsPluginServerInitCallback(); \
MatterIdentifyPluginServerInitCallback(); \
MatterLevelControlPluginServerInitCallback(); \
MatterNetworkCommissioningPluginServerInitCallback(); \
MatterOtaSoftwareUpdateProviderPluginClientInitCallback(); \
MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(); \
MatterOnOffPluginServerInitCallback(); \
MatterOperationalCredentialsPluginServerInitCallback(); \
MatterSoftwareDiagnosticsPluginServerInitCallback(); \
MatterThreadNetworkDiagnosticsPluginServerInitCallback(); \
MatterUserLabelPluginServerInitCallback(); \
MatterWiFiNetworkDiagnosticsPluginServerInitCallback();
@@ -1,483 +0,0 @@
/*
*
* 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.
*/
// THIS FILE IS GENERATED BY ZAP
#include <app-common/zap-generated/af-structs.h>
#include <app/util/af.h>
#include <app/util/attribute-list-byte-span.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPSafeCasts.h>
#include <lib/support/SafeInt.h>
#include <lib/support/logging/CHIPLogging.h>
using namespace chip;
using namespace chip::app::List;
// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
constexpr uint16_t kSizeLengthInBytes = 2u;
void copyListMember(uint8_t * dest, uint8_t * src, bool write, uint16_t * offset, uint16_t length)
{
if (write)
{
memmove(dest + *offset, src, length);
}
else
{
memmove(dest, src + *offset, length);
}
*offset = static_cast<uint16_t>(*offset + length);
}
uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, bool write, uint8_t * dest, uint8_t * src, int32_t index)
{
if (index == -1)
{
memmove(dest, src, am->size);
return am->size;
}
if (index == 0)
{
if (write)
{
// src is a pointer to native-endian uint16_t, dest is pointer to buffer that should hold little-endian value
emberAfCopyInt16u(dest, 0, *reinterpret_cast<uint16_t*>(src));
}
else
{
// src is pointer to buffer holding little-endian value, dest is a pointer to native-endian uint16_t
*reinterpret_cast<uint16_t*>(dest) = emberAfGetInt16u(src, 0, kSizeLengthInBytes);
}
return kSizeLengthInBytes;
}
if (!CanCastTo<uint16_t>(index))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index);
return 0;
}
uint16_t entryLength = 0;
switch (clusterId)
{
case 0x001D: // Descriptor Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // device list
{
entryLength = 6;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _DeviceType
_DeviceType * entry = reinterpret_cast<_DeviceType *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->type, write ? (uint8_t *)&entry->type : src, write, &entryOffset, sizeof(entry->type)); // DEVTYPE_ID
copyListMember(write ? dest : (uint8_t *)&entry->revision, write ? (uint8_t *)&entry->revision : src, write, &entryOffset, sizeof(entry->revision)); // INT16U
break;
}
case 0x0001: // server list
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID
break;
}
case 0x0002: // client list
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // CLUSTER_ID
break;
}
case 0x0003: // parts list
{
entryLength = 2;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // ENDPOINT_NO
break;
}
}
break;
}
case 0x0030: // General Commissioning Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0001: // BasicCommissioningInfoList
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _BasicCommissioningInfoType
_BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->FailSafeExpiryLengthMs, write ? (uint8_t *)&entry->FailSafeExpiryLengthMs : src, write, &entryOffset, sizeof(entry->FailSafeExpiryLengthMs)); // INT32U
break;
}
}
break;
}
case 0x0033: // General Diagnostics Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0000: // NetworkInterfaces
{
entryLength = 48;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _NetworkInterfaceType
_NetworkInterfaceType * entry = reinterpret_cast<_NetworkInterfaceType *>(write ? src : dest);
ByteSpan NameSpanStorage(Uint8::from_const_char(entry->Name.data()), entry->Name.size()); // CHAR_STRING
ByteSpan * NameSpan = &NameSpanStorage;
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 34, NameSpan) : ReadByteSpan(src + entryOffset, 34, NameSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 34);
copyListMember(write ? dest : (uint8_t *)&entry->FabricConnected, write ? (uint8_t *)&entry->FabricConnected : src, write, &entryOffset, sizeof(entry->FabricConnected)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->OffPremiseServicesReachableIPv4, write ? (uint8_t *)&entry->OffPremiseServicesReachableIPv4 : src, write, &entryOffset, sizeof(entry->OffPremiseServicesReachableIPv4)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->OffPremiseServicesReachableIPv6, write ? (uint8_t *)&entry->OffPremiseServicesReachableIPv6 : src, write, &entryOffset, sizeof(entry->OffPremiseServicesReachableIPv6)); // BOOLEAN
ByteSpan * HardwareAddressSpan = &entry->HardwareAddress; // OCTET_STRING
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 10, HardwareAddressSpan) : ReadByteSpan(src + entryOffset, 10, HardwareAddressSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 10);
copyListMember(write ? dest : (uint8_t *)&entry->Type, write ? (uint8_t *)&entry->Type : src, write, &entryOffset, sizeof(entry->Type)); // InterfaceType
break;
}
}
break;
}
case 0x003E: // Operational Credentials Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0001: // fabrics list
{
entryLength = 120;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _FabricDescriptor
_FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->FabricIndex, write ? (uint8_t *)&entry->FabricIndex : src, write, &entryOffset, sizeof(entry->FabricIndex)); // INT8U
ByteSpan * RootPublicKeySpan = &entry->RootPublicKey; // OCTET_STRING
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 67, RootPublicKeySpan) : ReadByteSpan(src + entryOffset, 67, RootPublicKeySpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 67);
copyListMember(write ? dest : (uint8_t *)&entry->VendorId, write ? (uint8_t *)&entry->VendorId : src, write, &entryOffset, sizeof(entry->VendorId)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->FabricId, write ? (uint8_t *)&entry->FabricId : src, write, &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID
copyListMember(write ? dest : (uint8_t *)&entry->NodeId, write ? (uint8_t *)&entry->NodeId : src, write, &entryOffset, sizeof(entry->NodeId)); // NODE_ID
ByteSpan LabelSpanStorage(Uint8::from_const_char(entry->Label.data()), entry->Label.size()); // CHAR_STRING
ByteSpan * LabelSpan = &LabelSpanStorage;
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + 34);
break;
}
case 0x0004: // TrustedRootCertificates
{
entryOffset = GetByteSpanOffsetFromIndex(write ? dest : src, am->size, static_cast<uint16_t>(index - 1));
if (entryOffset == 0)
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
ByteSpan * trustedRootCertificatesSpan = reinterpret_cast<ByteSpan *>(write ? src : dest); // OCTET_STRING
uint16_t trustedRootCertificatesRemainingSpace = static_cast<uint16_t>(am->size - entryOffset);
if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan) : ReadByteSpan(src + entryOffset, trustedRootCertificatesRemainingSpace, trustedRootCertificatesSpan)))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index);
return 0;
}
if (!CanCastTo<uint16_t>(trustedRootCertificatesSpan->size()))
{
ChipLogError(Zcl, "Span size %zu is too large", trustedRootCertificatesSpan->size());
return 0;
}
entryLength = static_cast<uint16_t>(trustedRootCertificatesSpan->size());
break;
}
}
break;
}
case 0x0035: // Thread Network Diagnostics Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0007: // NeighborTableList
{
entryLength = 31;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _NeighborTable
_NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->ExtAddress, write ? (uint8_t *)&entry->ExtAddress : src, write, &entryOffset, sizeof(entry->ExtAddress)); // INT64U
copyListMember(write ? dest : (uint8_t *)&entry->Age, write ? (uint8_t *)&entry->Age : src, write, &entryOffset, sizeof(entry->Age)); // INT32U
copyListMember(write ? dest : (uint8_t *)&entry->Rloc16, write ? (uint8_t *)&entry->Rloc16 : src, write, &entryOffset, sizeof(entry->Rloc16)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->LinkFrameCounter, write ? (uint8_t *)&entry->LinkFrameCounter : src, write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U
copyListMember(write ? dest : (uint8_t *)&entry->MleFrameCounter, write ? (uint8_t *)&entry->MleFrameCounter : src, write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U
copyListMember(write ? dest : (uint8_t *)&entry->LQI, write ? (uint8_t *)&entry->LQI : src, write, &entryOffset, sizeof(entry->LQI)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->AverageRssi, write ? (uint8_t *)&entry->AverageRssi : src, write, &entryOffset, sizeof(entry->AverageRssi)); // INT8S
copyListMember(write ? dest : (uint8_t *)&entry->LastRssi, write ? (uint8_t *)&entry->LastRssi : src, write, &entryOffset, sizeof(entry->LastRssi)); // INT8S
copyListMember(write ? dest : (uint8_t *)&entry->FrameErrorRate, write ? (uint8_t *)&entry->FrameErrorRate : src, write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->MessageErrorRate, write ? (uint8_t *)&entry->MessageErrorRate : src, write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->RxOnWhenIdle, write ? (uint8_t *)&entry->RxOnWhenIdle : src, write, &entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->FullThreadDevice, write ? (uint8_t *)&entry->FullThreadDevice : src, write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->FullNetworkData, write ? (uint8_t *)&entry->FullNetworkData : src, write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->IsChild, write ? (uint8_t *)&entry->IsChild : src, write, &entryOffset, sizeof(entry->IsChild)); // BOOLEAN
break;
}
case 0x0008: // RouteTableList
{
entryLength = 18;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _RouteTable
_RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->ExtAddress, write ? (uint8_t *)&entry->ExtAddress : src, write, &entryOffset, sizeof(entry->ExtAddress)); // INT64U
copyListMember(write ? dest : (uint8_t *)&entry->Rloc16, write ? (uint8_t *)&entry->Rloc16 : src, write, &entryOffset, sizeof(entry->Rloc16)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->RouterId, write ? (uint8_t *)&entry->RouterId : src, write, &entryOffset, sizeof(entry->RouterId)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->NextHop, write ? (uint8_t *)&entry->NextHop : src, write, &entryOffset, sizeof(entry->NextHop)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->PathCost, write ? (uint8_t *)&entry->PathCost : src, write, &entryOffset, sizeof(entry->PathCost)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->LQIIn, write ? (uint8_t *)&entry->LQIIn : src, write, &entryOffset, sizeof(entry->LQIIn)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->LQIOut, write ? (uint8_t *)&entry->LQIOut : src, write, &entryOffset, sizeof(entry->LQIOut)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->Age, write ? (uint8_t *)&entry->Age : src, write, &entryOffset, sizeof(entry->Age)); // INT8U
copyListMember(write ? dest : (uint8_t *)&entry->Allocated, write ? (uint8_t *)&entry->Allocated : src, write, &entryOffset, sizeof(entry->Allocated)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->LinkEstablished, write ? (uint8_t *)&entry->LinkEstablished : src, write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN
break;
}
case 0x003B: // SecurityPolicy
{
entryLength = 4;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _SecurityPolicy
_SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->RotationTime, write ? (uint8_t *)&entry->RotationTime : src, write, &entryOffset, sizeof(entry->RotationTime)); // INT16U
copyListMember(write ? dest : (uint8_t *)&entry->Flags, write ? (uint8_t *)&entry->Flags : src, write, &entryOffset, sizeof(entry->Flags)); // BITMAP16
break;
}
case 0x003D: // OperationalDatasetComponents
{
entryLength = 12;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _OperationalDatasetComponents
_OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *)&entry->ActiveTimestampPresent, write ? (uint8_t *)&entry->ActiveTimestampPresent : src, write, &entryOffset, sizeof(entry->ActiveTimestampPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->PendingTimestampPresent, write ? (uint8_t *)&entry->PendingTimestampPresent : src, write, &entryOffset, sizeof(entry->PendingTimestampPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->MasterKeyPresent, write ? (uint8_t *)&entry->MasterKeyPresent : src, write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->NetworkNamePresent, write ? (uint8_t *)&entry->NetworkNamePresent : src, write, &entryOffset, sizeof(entry->NetworkNamePresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->ExtendedPanIdPresent, write ? (uint8_t *)&entry->ExtendedPanIdPresent : src, write, &entryOffset, sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->MeshLocalPrefixPresent, write ? (uint8_t *)&entry->MeshLocalPrefixPresent : src, write, &entryOffset, sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->DelayPresent, write ? (uint8_t *)&entry->DelayPresent : src, write, &entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->PanIdPresent, write ? (uint8_t *)&entry->PanIdPresent : src, write, &entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->ChannelPresent, write ? (uint8_t *)&entry->ChannelPresent : src, write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->PskcPresent, write ? (uint8_t *)&entry->PskcPresent : src, write, &entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->SecurityPolicyPresent, write ? (uint8_t *)&entry->SecurityPolicyPresent : src, write, &entryOffset, sizeof(entry->SecurityPolicyPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *)&entry->ChannelMaskPresent, write ? (uint8_t *)&entry->ChannelMaskPresent : src, write, &entryOffset, sizeof(entry->ChannelMaskPresent)); // BOOLEAN
break;
}
case 0x003E: // ActiveNetworkFaultsList
{
entryLength = 1;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault
break;
}
}
break;
}
}
return entryLength;
}
// A list is a collection of entries of the same data type. The data type may be any defined data type.
uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attributeId, const uint8_t * buffer)
{
// The first 2 bytes specify the number of entries. A value of 0xFFFF means the list in invalid
// and data is undefined.
uint16_t entryCount = emberAfGetInt16u(buffer, 0, kSizeLengthInBytes);
if (entryCount == 0xFFFF)
{
return 0;
}
uint16_t entryLength = 0;
switch (clusterId)
{
case 0x001D: // Descriptor Cluster
switch (attributeId)
{
case 0x0000: // device list
// Struct _DeviceType
entryLength = 6;
break;
case 0x0001: // server list
// chip::ClusterId
entryLength = 4;
break;
case 0x0002: // client list
// chip::ClusterId
entryLength = 4;
break;
case 0x0003: // parts list
// chip::EndpointId
entryLength = 2;
break;
}
break;
case 0x0030: // General Commissioning Cluster
switch (attributeId)
{
case 0x0001: // BasicCommissioningInfoList
// Struct _BasicCommissioningInfoType
entryLength = 4;
break;
}
break;
case 0x0033: // General Diagnostics Cluster
switch (attributeId)
{
case 0x0000: // NetworkInterfaces
// Struct _NetworkInterfaceType
entryLength = 48;
break;
}
break;
case 0x003E: // Operational Credentials Cluster
switch (attributeId)
{
case 0x0001: // fabrics list
// Struct _FabricDescriptor
entryLength = 120;
break;
case 0x0004: // TrustedRootCertificates
// chip::ByteSpan
return GetByteSpanOffsetFromIndex(buffer, 402, entryCount);
break;
}
break;
case 0x0035: // Thread Network Diagnostics Cluster
switch (attributeId)
{
case 0x0007: // NeighborTableList
// Struct _NeighborTable
entryLength = 31;
break;
case 0x0008: // RouteTableList
// Struct _RouteTable
entryLength = 18;
break;
case 0x003B: // SecurityPolicy
// Struct _SecurityPolicy
entryLength = 4;
break;
case 0x003D: // OperationalDatasetComponents
// Struct _OperationalDatasetComponents
entryLength = 12;
break;
case 0x003E: // ActiveNetworkFaultsList
// uint8_t
entryLength = 1;
break;
}
break;
}
uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength);
if (!CanCastTo<uint16_t>(totalSize))
{
ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId));
return 0;
}
return static_cast<uint16_t>(totalSize);
}
@@ -29,49 +29,61 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
{
switch (clusterId)
{
case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID :
case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID:
emberAfAdministratorCommissioningClusterInitCallback(endpoint);
break;
case ZCL_BASIC_CLUSTER_ID :
case ZCL_BASIC_CLUSTER_ID:
emberAfBasicClusterInitCallback(endpoint);
break;
case ZCL_COLOR_CONTROL_CLUSTER_ID :
case ZCL_COLOR_CONTROL_CLUSTER_ID:
emberAfColorControlClusterInitCallback(endpoint);
break;
case ZCL_DESCRIPTOR_CLUSTER_ID :
case ZCL_DESCRIPTOR_CLUSTER_ID:
emberAfDescriptorClusterInitCallback(endpoint);
break;
case ZCL_DIAGNOSTIC_LOGS_CLUSTER_ID :
case ZCL_DIAGNOSTIC_LOGS_CLUSTER_ID:
emberAfDiagnosticLogsClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID :
case ZCL_FIXED_LABEL_CLUSTER_ID:
emberAfFixedLabelClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID:
emberAfGeneralCommissioningClusterInitCallback(endpoint);
break;
case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID :
case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID:
emberAfGeneralDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_IDENTIFY_CLUSTER_ID :
case ZCL_IDENTIFY_CLUSTER_ID:
emberAfIdentifyClusterInitCallback(endpoint);
break;
case ZCL_LEVEL_CONTROL_CLUSTER_ID :
case ZCL_LEVEL_CONTROL_CLUSTER_ID:
emberAfLevelControlClusterInitCallback(endpoint);
break;
case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID :
case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID:
emberAfNetworkCommissioningClusterInitCallback(endpoint);
break;
case ZCL_ON_OFF_CLUSTER_ID :
case ZCL_OTA_PROVIDER_CLUSTER_ID:
emberAfOtaSoftwareUpdateProviderClusterInitCallback(endpoint);
break;
case ZCL_OTA_REQUESTOR_CLUSTER_ID:
emberAfOtaSoftwareUpdateRequestorClusterInitCallback(endpoint);
break;
case ZCL_ON_OFF_CLUSTER_ID:
emberAfOnOffClusterInitCallback(endpoint);
break;
case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID :
case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID:
emberAfOperationalCredentialsClusterInitCallback(endpoint);
break;
case ZCL_SOFTWARE_DIAGNOSTICS_CLUSTER_ID :
case ZCL_SOFTWARE_DIAGNOSTICS_CLUSTER_ID:
emberAfSoftwareDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID :
case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID:
emberAfThreadNetworkDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID :
case ZCL_USER_LABEL_CLUSTER_ID:
emberAfUserLabelClusterInitCallback(endpoint);
break;
case ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID:
emberAfWiFiNetworkDiagnosticsClusterInitCallback(endpoint);
break;
default:
@@ -105,6 +117,11 @@ void __attribute__((weak)) emberAfDiagnosticLogsClusterInitCallback(EndpointId e
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfFixedLabelClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfGeneralCommissioningClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
@@ -130,6 +147,16 @@ void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(Endpoi
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOtaSoftwareUpdateProviderClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOtaSoftwareUpdateRequestorClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
@@ -150,6 +177,11 @@ void __attribute__((weak)) emberAfThreadNetworkDiagnosticsClusterInitCallback(En
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfUserLabelClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfWiFiNetworkDiagnosticsClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
@@ -164,60 +196,51 @@ void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicatio
void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {}
EmberAfAttributeWritePermission __attribute__((weak)) emberAfAllowNetworkWriteAttributeCallback(
EndpointId endpoint, ClusterId clusterId,
AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode, uint8_t * value, uint8_t type)
EmberAfAttributeWritePermission __attribute__((weak))
emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
uint16_t manufacturerCode, uint8_t * value, uint8_t type)
{
return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
}
bool __attribute__((weak)) emberAfAttributeReadAccessCallback(
EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode,
AttributeId attributeId)
bool __attribute__((weak))
emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
{
return true;
}
bool __attribute__((weak)) emberAfAttributeWriteAccessCallback(
EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode,
AttributeId attributeId)
bool __attribute__((weak))
emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, uint16_t manufacturerCode, AttributeId attributeId)
{
return true;
}
bool __attribute__((weak)) emberAfDefaultResponseCallback(
ClusterId clusterId, CommandId commandId, EmberAfStatus status)
bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
{
return false;
}
bool __attribute__((weak)) emberAfPreMessageSendCallback(
EmberAfMessageStruct * messageStruct, EmberStatus * status)
bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status)
{
return false;
}
bool __attribute__((weak)) emberAfMessageSentCallback(
const MessageSendDestination & destination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status)
bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status)
{
return false;
}
EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(
EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, uint16_t maxReadLength, int32_t index)
EmberAfStatus __attribute__((weak))
emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
uint16_t manufacturerCode, uint8_t * buffer, uint16_t maxReadLength)
{
return EMBER_ZCL_STATUS_FAILURE;
}
EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(
EndpointId endpoint, ClusterId clusterId,
EmberAfAttributeMetadata * attributeMetadata, uint16_t manufacturerCode,
uint8_t * buffer, int32_t index)
EmberAfStatus __attribute__((weak))
emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, EmberAfAttributeMetadata * attributeMetadata,
uint16_t manufacturerCode, uint8_t * buffer)
{
return EMBER_ZCL_STATUS_FAILURE;
}
@@ -227,17 +250,16 @@ uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback()
return 0;
}
bool __attribute__((weak)) emberAfGetEndpointInfoCallback(
EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo)
bool __attribute__((weak))
emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
{
return false;
}
void __attribute__((weak)) emberAfRegistrationAbortCallback() {}
EmberStatus __attribute__((weak)) emberAfInterpanSendMessageCallback(
EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
EmberStatus __attribute__((weak))
emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message)
{
return EMBER_LIBRARY_NOT_PRESENT;
}
@@ -247,15 +269,13 @@ bool __attribute__((weak)) emberAfStartMoveCallback()
return false;
}
chip::Protocols::InteractionModel::Status __attribute__((weak)) MatterPreAttributeChangeCallback(
const chip::app::ConcreteAttributePath & attributePath,
uint8_t mask, uint8_t type, uint16_t size, uint8_t * value)
chip::Protocols::InteractionModel::Status __attribute__((weak))
MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, uint16_t size,
uint8_t * value)
{
return chip::Protocols::InteractionModel::Status::Success;
}
void __attribute__((weak)) MatterPostAttributeChangeCallback(
const chip::app::ConcreteAttributePath & attributePath,
uint8_t mask, uint8_t type, uint16_t size, uint8_t * value)
{
}
void __attribute__((weak)) MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask,
uint8_t type, uint16_t size, uint8_t * value)
{}
File diff suppressed because it is too large Load Diff
@@ -1,19 +0,0 @@
/*
*
* 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.
*/
// THIS FILE IS GENERATED BY ZAP
@@ -1,19 +0,0 @@
/*
*
* 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.
*/
// THIS FILE IS GENERATED BY ZAP
File diff suppressed because it is too large Load Diff
@@ -26,7 +26,6 @@
/**** Network Section ****/
#define EMBER_SUPPORTED_NETWORKS (1)
#define EMBER_APS_UNICAST_MESSAGE_COUNT 10
/**** Cluster endpoint counts ****/
@@ -35,15 +34,19 @@
#define EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_DESCRIPTOR_CLUSTER_SERVER_ENDPOINT_COUNT (2)
#define EMBER_AF_DIAGNOSTIC_LOGS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_FIXED_LABEL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_GENERAL_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OTA_PROVIDER_CLUSTER_CLIENT_ENDPOINT_COUNT (1)
#define EMBER_AF_OTA_REQUESTOR_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_SOFTWARE_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_USER_LABEL_CLUSTER_SERVER_ENDPOINT_COUNT (1)
#define EMBER_AF_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1)
/**** Cluster Plugins ****/
@@ -77,6 +80,11 @@
#define EMBER_AF_PLUGIN_DIAGNOSTIC_LOGS_SERVER
#define EMBER_AF_PLUGIN_DIAGNOSTIC_LOGS
// Use this macro to check if the server side of the Fixed Label cluster is included
#define ZCL_USING_FIXED_LABEL_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_FIXED_LABEL_SERVER
#define EMBER_AF_PLUGIN_FIXED_LABEL
// Use this macro to check if the server side of the General Commissioning cluster is included
#define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_SERVER
@@ -106,6 +114,15 @@
#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER
#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING
// Use this macro to check if the client side of the OTA Software Update Provider cluster is included
#define ZCL_USING_OTA_PROVIDER_CLUSTER_CLIENT
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_CLIENT
// Use this macro to check if the server side of the OTA Software Update Requestor cluster is included
#define ZCL_USING_OTA_REQUESTOR_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR_SERVER
#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR
// Use this macro to check if the server side of the On/Off cluster is included
#define ZCL_USING_ON_OFF_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_ON_OFF_SERVER
@@ -126,6 +143,11 @@
#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS_SERVER
#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS
// Use this macro to check if the server side of the User Label cluster is included
#define ZCL_USING_USER_LABEL_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_USER_LABEL_SERVER
#define EMBER_AF_PLUGIN_USER_LABEL
// Use this macro to check if the server side of the WiFi Network Diagnostics cluster is included
#define ZCL_USING_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_SERVER
#define EMBER_AF_PLUGIN_WI_FI_NETWORK_DIAGNOSTICS_SERVER