Skip to content

Commit

Permalink
Zap remove ember af maximum aps payload length (#6428)
Browse files Browse the repository at this point in the history
* Remove emberAfMaximumApsPayloadLength method

 #### Problem
 Ember has a limit on the actual message payload. Currently this limit is `82` and it starts to be
 too small for reading `List` attributes.
 Futhermore, there is a method named `emberAfMaximumApsPayloadLength` use to calculate the size
 of the payload depending on some routing parameters as far as I can tell. It is unclear to me
 that CHIP will ever use those.

 #### Summary of changes
 * Remove `emberAfMaximumApsPayloadLength` and some dependencies
 * Upgrade the maximum payload size from `82` to `1024`

* Update gen/ folders
  • Loading branch information
vivien-apple authored May 3, 2021
1 parent 93186c4 commit c2327a5
Show file tree
Hide file tree
Showing 28 changed files with 10 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -742,18 +742,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/all-clusters-app/all-clusters-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -3173,15 +3173,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
12 changes: 0 additions & 12 deletions examples/bridge-app/bridge-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,18 +590,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/bridge-app/bridge-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -1093,15 +1093,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
12 changes: 0 additions & 12 deletions examples/chip-tool/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,18 +798,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/chip-tool/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -3495,15 +3495,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
12 changes: 0 additions & 12 deletions examples/lighting-app/lighting-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,18 +590,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/lighting-app/lighting-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -1093,15 +1093,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
12 changes: 0 additions & 12 deletions examples/lock-app/lock-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/lock-app/lock-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -940,15 +940,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,15 +925,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
12 changes: 0 additions & 12 deletions examples/tv-app/tv-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,18 +758,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/tv-app/tv-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -3152,15 +3152,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
12 changes: 0 additions & 12 deletions examples/window-app/common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,6 @@ emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex
return false;
}

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t __attribute__((weak)) emberAfGetSourceRouteOverheadCallback(chip::NodeId destination)
{
return 0;
}

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
9 changes: 0 additions & 9 deletions examples/window-app/common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,15 +620,6 @@ uint32_t emberAfGetCurrentTimeCallback();
bool emberAfGetEndpointInfoCallback(chip::EndpointId endpoint, uint8_t * returnNetworkIndex,
EmberAfEndpointInfoStruct * returnEndpointInfo);

/** @brief Get Source Route Overhead
*
* This function is called by the framework to determine the overhead required
* in the network frame for source routing to a particular destination.
*
* @param destination The node id of the destination Ver.: always
*/
uint8_t emberAfGetSourceRouteOverheadCallback(chip::NodeId destination);

/** @brief Registration Abort
*
* This callback is called when the device should abort the registration
Expand Down
6 changes: 3 additions & 3 deletions src/app/reporting/reporting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ void emberAfPluginReportingTickEventHandler(void)
// reportSize needs to be able to fit a sum of dataSize and some other stuff
// without overflowing.
uint32_t reportSize;
uint8_t index, currentPayloadMaxLength = 0, smallestPayloadMaxLength = 0;
uint8_t index;
uint16_t currentPayloadMaxLength = 0, smallestPayloadMaxLength = 0;

for (i = 0; i < REPORT_TABLE_SIZE; i++)
{
Expand Down Expand Up @@ -292,8 +293,7 @@ void emberAfPluginReportingTickEventHandler(void)
if (status == (EmberAfStatus) EMBER_SUCCESS && bindingEntry.local == entry.endpoint &&
bindingEntry.clusterId == entry.clusterId)
{
currentPayloadMaxLength =
emberAfMaximumApsPayloadLength(bindingEntry.type, bindingEntry.networkIndex, apsFrame);
currentPayloadMaxLength = EMBER_AF_RESPONSE_BUFFER_LEN;
if (currentPayloadMaxLength < smallestPayloadMaxLength)
{
smallestPayloadMaxLength = currentPayloadMaxLength;
Expand Down
9 changes: 1 addition & 8 deletions src/app/util/af-main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,9 @@ static EmberStatus send(EmberOutgoingMessageType type, uint64_t indexOrDestinati
emAfApplyDisableDefaultResponse(&message[0]);
emAfApplyRetryOverride(&apsFrame->options);

if (messageLength <= emberAfMaximumApsPayloadLength(type, indexOrDestination, apsFrame))
if (messageLength <= EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH)
{
status = emAfSend(type, indexOrDestination, apsFrame, (uint8_t) messageLength, message, &messageTag, alias, sequence);
#ifdef EMBER_AF_PLUGIN_FRAGMENTATION
}
else if (!broadcast)
{
status = emAfFragmentationSendUnicast(type, indexOrDestination, apsFrame, message, messageLength, &messageTag);
emberAfDebugPrintln("%pstart:len=%d.", "Fragmentation:", messageLength);
#endif
}
else
{
Expand Down
18 changes: 0 additions & 18 deletions src/app/util/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -1474,24 +1474,6 @@ EmberStatus emberAfSendImmediateDefaultResponse(EmberAfStatus status);
*/
EmberStatus emberAfSendImmediateDefaultResponseWithCallback(EmberAfStatus status, EmberAfMessageSentFunction callback);

/**
* @brief Returns the maximum size of the payload that the Application
* Support sub-layer will accept for the given message type, destination, and
* APS frame.
*
* The size depends on multiple factors, including the security level in use
* and additional information added to the message to support the various
* options.
*
* @param type The outgoing message type.
* @param indexOrDestination Depending on the message type, this is either the
* EmberNodeId of the destination, an index into the address table, an index
* into the binding table, the multicast identifier, or a broadcast address.
* @param apsFrame The APS frame for the message.
* @return The maximum APS payload length for the given message.
*/
uint8_t emberAfMaximumApsPayloadLength(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame);

/**
* @brief Access to client API APS frame.
*/
Expand Down
19 changes: 2 additions & 17 deletions src/app/util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@
#define ZA_MAX_HOPS 12
#endif

#ifndef EMBER_AF_SOURCE_ROUTING_RESERVED_PAYLOAD_LENGTH
#define EMBER_AF_SOURCE_ROUTING_RESERVED_PAYLOAD_LENGTH 0
#endif

// The maximum APS payload, not including any APS options. This value is also
// available from emberMaximumApsPayloadLength() or ezspMaximumPayloadLength().
// See http://portal.ember.com/faq/payload for more information.
#define EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH 82 - EMBER_AF_SOURCE_ROUTING_RESERVED_PAYLOAD_LENGTH

// Max PHY size = 128
// -1 byte for PHY length
// -2 bytes for MAC CRC
Expand All @@ -157,14 +148,8 @@
// affects the payloads generated from the CLI and the payloads generated
// as responses.
// Maximum payload length.
// If fragmenation is enabled, and fragmentation length is bigger than default, then use that
#if defined(EMBER_AF_PLUGIN_FRAGMENTATION) && (EMBER_AF_PLUGIN_FRAGMENTATION_BUFFER_SIZE > EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH)
#define EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH EMBER_AF_PLUGIN_FRAGMENTATION_BUFFER_SIZE
#define EMBER_AF_INCOMING_BUFFER_LENGTH EMBER_AF_PLUGIN_FRAGMENTATION_BUFFER_SIZE
#else
#define EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH
#define EMBER_AF_INCOMING_BUFFER_LENGTH EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH
#endif
#define EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH 1024
#define EMBER_AF_INCOMING_BUFFER_LENGTH 1024

// *******************************************************************
// Application configuration of Flash
Expand Down
8 changes: 4 additions & 4 deletions src/app/util/process-global-message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ bool emAfSyncingTime = false;
#endif

#define DISC_ATTR_RSP_MAX_ATTRIBUTES \
(((EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH - EMBER_AF_ZCL_MANUFACTURER_SPECIFIC_OVERHEAD /* max ZCL header size */ \
- 1) /* discovery is complete boolean */ \
(((EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH - EMBER_AF_ZCL_MANUFACTURER_SPECIFIC_OVERHEAD /* max ZCL header size */ \
- 1) /* discovery is complete boolean */ \
/ 3) /* size of one discover attributes response entry */ \
% UINT8_MAX) /* make count fit in an 8 bit integer */
#define DISC_ATTR_EXT_RSP_MAX_ATTRIBUTES \
(((EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH - EMBER_AF_ZCL_MANUFACTURER_SPECIFIC_OVERHEAD /* max ZCL header size */ \
- 1) /* discovery is complete boolean */ \
(((EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH - EMBER_AF_ZCL_MANUFACTURER_SPECIFIC_OVERHEAD /* max ZCL header size */ \
- 1) /* discovery is complete boolean */ \
/ 4) /* size of one discover attributes extended response entry */ \
% UINT8_MAX) /* make count fit in an 8 bit integer */

Expand Down
Loading

0 comments on commit c2327a5

Please sign in to comment.