Skip to content

Commit

Permalink
Use the incoming exchange context to send responses in the data model (
Browse files Browse the repository at this point in the history
…#6438)

* Switch to a union for the indexOrDestination argument to message send functions.

* Return a non-const ExchangeContext from Command's getter.

Sending a reply needs a non-const ExchangeContext.

* Propagate the incoming-message exchange context down so we can use it for responses.

* Add a way to Close() all the exchange contexts for a given delegate.

* Use the incoming exchange context to send reply messages instead of creating a new one.

* Regenerate generated files
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Aug 11, 2021
1 parent b895678 commit 2b64064
Show file tree
Hide file tree
Showing 54 changed files with 698 additions and 564 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct *
* @param status Ver.: always
*/
bool __attribute__((weak))
emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
uint8_t * message, EmberStatus status)
emberAfMessageSentCallback(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status)
{
return false;
}
Expand Down
125 changes: 65 additions & 60 deletions examples/all-clusters-app/all-clusters-common/gen/callback.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/bridge-app/bridge-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct *
* @param status Ver.: always
*/
bool __attribute__((weak))
emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
uint8_t * message, EmberStatus status)
emberAfMessageSentCallback(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status)
{
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions examples/bridge-app/bridge-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip:
* Server Message Sent
*
* @param type The type of message sent
* @param indexOrDestination The destination or address to which the message was sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief Basic Cluster Server Pre Attribute Changed
Expand Down Expand Up @@ -188,15 +188,15 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange
* Server Message Sent
*
* @param type The type of message sent
* @param indexOrDestination The destination or address to which the message was sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status);
void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type,
chip::MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief General Commissioning Cluster Server Pre Attribute Changed
*
Expand Down Expand Up @@ -259,13 +259,13 @@ void emberAfLevelControlClusterServerManufacturerSpecificAttributeChangedCallbac
* Server Message Sent
*
* @param type The type of message sent
* @param indexOrDestination The destination or address to which the message was sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfLevelControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
void emberAfLevelControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status);

Expand Down Expand Up @@ -329,15 +329,15 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange
* Server Message Sent
*
* @param type The type of message sent
* @param indexOrDestination The destination or address to which the message was sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status);
void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type,
chip::MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief Network Commissioning Cluster Server Pre Attribute Changed
*
Expand Down Expand Up @@ -399,13 +399,13 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip:
* Server Message Sent
*
* @param type The type of message sent
* @param indexOrDestination The destination or address to which the message was sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination,
void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief On/off Cluster Server Pre Attribute Changed
Expand Down Expand Up @@ -885,13 +885,13 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt
* be handled by the application framework.
*
* @param type Ver.: always
* @param indexOrDestination Ver.: always
* @param destination Ver.: always
* @param apsFrame Ver.: always
* @param msgLen Ver.: always
* @param message Ver.: always
* @param status Ver.: always
*/
bool emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame,
bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status);

/** @brief Pre Attribute Change
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/gen/CHIPClientCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ using namespace ::chip;
#define GET_RESPONSE_CALLBACKS(name) \
Callback::Cancelable * onSuccessCallback = nullptr; \
Callback::Cancelable * onFailureCallback = nullptr; \
NodeId sourceId = emberAfCurrentCommand()->source; \
NodeId sourceId = emberAfCurrentCommand()->SourceNodeId(); \
uint8_t sequenceNumber = emberAfCurrentCommand()->seqNum; \
CHIP_ERROR err = gCallbacks.GetResponseCallback(sourceId, sequenceNumber, &onSuccessCallback, &onFailureCallback); \
\
Expand Down Expand Up @@ -2087,7 +2087,7 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin
ChipLogProgress(Zcl, "emberAfReportAttributeCallback:");
ChipLogProgress(Zcl, " ClusterId: 0x%04x", clusterId);

NodeId sourceId = emberAfCurrentCommand()->source;
NodeId sourceId = emberAfCurrentCommand()->SourceNodeId();
ChipLogProgress(Zcl, " Source NodeId: %" PRIu64, sourceId);

EndpointId endpointId = emberAfCurrentCommand()->apsFrame->sourceEndpoint;
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct *
* @param status Ver.: always
*/
bool __attribute__((weak))
emberAfMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, uint16_t msgLen,
uint8_t * message, EmberStatus status)
emberAfMessageSentCallback(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame,
uint16_t msgLen, uint8_t * message, EmberStatus status)
{
return false;
}
Expand Down
Loading

0 comments on commit 2b64064

Please sign in to comment.