Skip to content

Commit

Permalink
Remove fixed code from callbacks-stubs.cpp generated files (#23424)
Browse files Browse the repository at this point in the history
* Move non-codegen callback stubs out of the zap template

* Zap regen

* Add generic-callback-stubs to cmake builds as well

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
andy31415 and andreilitvin authored Nov 2, 2022
1 parent 152beaa commit 5030df4
Show file tree
Hide file tree
Showing 46 changed files with 98 additions and 3,237 deletions.
1 change: 1 addition & 0 deletions src/app/chip_data_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function(chip_configure_data_model APP_TARGET)
${CHIP_APP_BASE_DIR}/util/ember-compatibility-functions.cpp
${CHIP_APP_BASE_DIR}/util/ember-print.cpp
${CHIP_APP_BASE_DIR}/util/error-mapping.cpp
${CHIP_APP_BASE_DIR}/util/generic-callback-stubs.cpp
${CHIP_APP_BASE_DIR}/util/message.cpp
${CHIP_APP_BASE_DIR}/util/privilege-storage.cpp
${CHIP_APP_BASE_DIR}/util/util.cpp
Expand Down
1 change: 1 addition & 0 deletions src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ template("chip_data_model") {
"${_app_root}/util/ember-compatibility-functions.cpp",
"${_app_root}/util/ember-print.cpp",
"${_app_root}/util/error-mapping.cpp",
"${_app_root}/util/generic-callback-stubs.cpp",
"${_app_root}/util/message.cpp",
"${_app_root}/util/privilege-storage.cpp",
"${_app_root}/util/util.cpp",
Expand Down
96 changes: 96 additions & 0 deletions src/app/util/generic-callback-stubs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
*
* Copyright (c) 2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-id.h>
#include <lib/support/Span.h>
#include <protocols/interaction_model/Constants.h>

using namespace chip;

// This file contains overridable callbacks that are not cluster specific.

EmberAfAttributeWritePermission __attribute__((weak))
emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t * value,
uint8_t type)
{
return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
}

bool __attribute__((weak)) emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId)
{
return true;
}

bool __attribute__((weak)) emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId)
{
return true;
}

bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status)
{
return false;
}

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)
{
return false;
}

EmberAfStatus __attribute__((weak))
emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
{
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus __attribute__((weak))
emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer)
{
return EMBER_ZCL_STATUS_FAILURE;
}

bool __attribute__((weak))
emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo)
{
return false;
}

void __attribute__((weak)) emberAfRegistrationAbortCallback() {}

bool __attribute__((weak)) emberAfStartMoveCallback()
{
return false;
}

chip::Protocols::InteractionModel::Status __attribute__((weak))
MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, 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 type,
uint16_t size, uint8_t * value)
{}
87 changes: 0 additions & 87 deletions src/app/zap-templates/templates/app/callback-stub-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -30,90 +30,3 @@ void __attribute__((weak)) emberAf{{asUpperCamelCase name}}ClusterInitCallback(E
(void) endpoint;
}
{{/all_user_clusters_names}}

//
// Non-Cluster Related Callbacks
//

EmberAfAttributeWritePermission __attribute__((weak)) emberAfAllowNetworkWriteAttributeCallback(
EndpointId endpoint, ClusterId clusterId,
AttributeId attributeId,
uint8_t * value, uint8_t type)
{
return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default
}

bool __attribute__((weak)) emberAfAttributeReadAccessCallback(
EndpointId endpoint, ClusterId clusterId, AttributeId attributeId)
{
return true;
}

bool __attribute__((weak)) emberAfAttributeWriteAccessCallback(
EndpointId endpoint, ClusterId clusterId, AttributeId attributeId)
{
return true;
}

bool __attribute__((weak)) emberAfDefaultResponseCallback(
ClusterId clusterId, CommandId commandId, EmberAfStatus status)
{
return false;
}

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)
{
return false;
}

EmberAfStatus __attribute__((weak)) emberAfExternalAttributeReadCallback(
EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer, uint16_t maxReadLength)
{
return EMBER_ZCL_STATUS_FAILURE;
}

EmberAfStatus __attribute__((weak)) emberAfExternalAttributeWriteCallback(
EndpointId endpoint, ClusterId clusterId,
const EmberAfAttributeMetadata * attributeMetadata,
uint8_t * buffer)
{
return EMBER_ZCL_STATUS_FAILURE;
}

bool __attribute__((weak)) emberAfGetEndpointInfoCallback(
EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo)
{
return false;
}

void __attribute__((weak)) emberAfRegistrationAbortCallback() {}

bool __attribute__((weak)) emberAfStartMoveCallback()
{
return false;
}

chip::Protocols::InteractionModel::Status __attribute__((weak)) MatterPreAttributeChangeCallback(
const chip::app::ConcreteAttributePath & attributePath,
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 type, uint16_t size, uint8_t * value)
{
}
75 changes: 0 additions & 75 deletions zzz_generated/all-clusters-app/zap-generated/callback-stub.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5030df4

Please sign in to comment.