diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp index 1b669d0870bb3c..f0e468d11ed7c0 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp @@ -678,9 +678,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index d80660c8745ff1..d8ba88a2c17e90 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -446,9 +446,8 @@ void emberAfAccountLoginClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfAccountLoginClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfAccountLoginClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Account Login Cluster Server Pre Attribute Changed * @@ -516,9 +515,9 @@ void emberAfApplicationBasicClusterServerManufacturerSpecificAttributeChangedCal * @param message The message that was sent * @param status The status of the sent message */ -void emberAfApplicationBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfApplicationBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Application Basic Cluster Server Pre Attribute Changed * @@ -587,9 +586,9 @@ void emberAfApplicationLauncherClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfApplicationLauncherClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfApplicationLauncherClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Application Launcher Cluster Server Pre Attribute Changed * @@ -658,9 +657,8 @@ void emberAfAudioOutputClusterServerManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfAudioOutputClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfAudioOutputClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Audio Output Cluster Server Pre Attribute Changed * @@ -728,7 +726,7 @@ void emberAfBarrierControlClusterServerManufacturerSpecificAttributeChangedCallb * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBarrierControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfBarrierControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -798,8 +796,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -867,9 +865,8 @@ void emberAfBindingClusterServerManufacturerSpecificAttributeChangedCallback(chi * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBindingClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfBindingClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Binding Cluster Server Pre Attribute Changed * @@ -937,9 +934,9 @@ void emberAfBridgedDeviceBasicClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBridgedDeviceBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBridgedDeviceBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Bridged Device Basic Cluster Server Pre Attribute Changed * @@ -1008,9 +1005,8 @@ void emberAfColorControlClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfColorControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfColorControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Color Control Cluster Server Pre Attribute Changed * @@ -1078,7 +1074,7 @@ void emberAfContentLaunchClusterServerManufacturerSpecificAttributeChangedCallba * @param message The message that was sent * @param status The status of the sent message */ -void emberAfContentLaunchClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfContentLaunchClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1148,9 +1144,8 @@ void emberAfDescriptorClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfDescriptorClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfDescriptorClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Descriptor Cluster Server Pre Attribute Changed * @@ -1218,9 +1213,8 @@ void emberAfDoorLockClusterServerManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfDoorLockClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfDoorLockClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Door Lock Cluster Server Pre Attribute Changed * @@ -1289,8 +1283,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1361,9 +1354,8 @@ void emberAfFixedLabelClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfFixedLabelClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfFixedLabelClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Fixed Label Cluster Server Pre Attribute Changed * @@ -1431,9 +1423,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -1502,9 +1494,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -1573,9 +1565,9 @@ void emberAfGroupKeyManagementClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGroupKeyManagementClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGroupKeyManagementClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Group Key Management Cluster Server Pre Attribute Changed * @@ -1644,9 +1636,8 @@ void emberAfGroupsClusterServerManufacturerSpecificAttributeChangedCallback(chip * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGroupsClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfGroupsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Groups Cluster Server Pre Attribute Changed * @@ -1714,9 +1705,8 @@ void emberAfIasZoneClusterServerManufacturerSpecificAttributeChangedCallback(chi * @param message The message that was sent * @param status The status of the sent message */ -void emberAfIasZoneClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfIasZoneClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief IAS Zone Cluster Server Pre Attribute Changed * @@ -1784,9 +1774,8 @@ void emberAfIdentifyClusterServerManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfIdentifyClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfIdentifyClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Identify Cluster Server Pre Attribute Changed * @@ -1854,9 +1843,8 @@ void emberAfKeypadInputClusterServerManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfKeypadInputClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfKeypadInputClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Keypad Input Cluster Server Pre Attribute Changed * @@ -1924,9 +1912,8 @@ void emberAfLevelControlClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLevelControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLevelControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Level Control Cluster Server Pre Attribute Changed * @@ -1994,9 +1981,8 @@ void emberAfLowPowerClusterServerManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLowPowerClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLowPowerClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Low Power Cluster Server Pre Attribute Changed * @@ -2064,9 +2050,8 @@ void emberAfMediaInputClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfMediaInputClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfMediaInputClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Media Input Cluster Server Pre Attribute Changed * @@ -2134,7 +2119,7 @@ void emberAfMediaPlaybackClusterServerManufacturerSpecificAttributeChangedCallba * @param message The message that was sent * @param status The status of the sent message */ -void emberAfMediaPlaybackClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfMediaPlaybackClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2204,9 +2189,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -2275,8 +2260,7 @@ void emberAfOtaSoftwareUpdateClientClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOtaSoftwareUpdateClientClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOtaSoftwareUpdateClientClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2347,8 +2331,7 @@ void emberAfOtaSoftwareUpdateServerClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOtaSoftwareUpdateServerClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOtaSoftwareUpdateServerClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2419,9 +2402,9 @@ void emberAfOccupancySensingClusterServerManufacturerSpecificAttributeChangedCal * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOccupancySensingClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOccupancySensingClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Occupancy Sensing Cluster Server Pre Attribute Changed * @@ -2489,8 +2472,8 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Server Pre Attribute Changed * @@ -2558,8 +2541,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2631,8 +2613,7 @@ void emberAfPumpConfigurationAndControlClusterServerManufacturerSpecificAttribut * @param message The message that was sent * @param status The status of the sent message */ -void emberAfPumpConfigurationAndControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfPumpConfigurationAndControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2703,9 +2684,8 @@ void emberAfScenesClusterServerManufacturerSpecificAttributeChangedCallback(chip * @param message The message that was sent * @param status The status of the sent message */ -void emberAfScenesClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfScenesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Scenes Cluster Server Pre Attribute Changed * @@ -2773,9 +2753,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -2844,9 +2824,8 @@ void emberAfSwitchClusterServerManufacturerSpecificAttributeChangedCallback(chip * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSwitchClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfSwitchClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Switch Cluster Server Pre Attribute Changed * @@ -2914,9 +2893,8 @@ void emberAfTvChannelClusterServerManufacturerSpecificAttributeChangedCallback(c * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTvChannelClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfTvChannelClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief TV Channel Cluster Server Pre Attribute Changed * @@ -2984,7 +2962,7 @@ void emberAfTargetNavigatorClusterServerManufacturerSpecificAttributeChangedCall * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTargetNavigatorClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfTargetNavigatorClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3055,8 +3033,7 @@ void emberAfTemperatureMeasurementClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTemperatureMeasurementClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTemperatureMeasurementClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3127,9 +3104,8 @@ void emberAfTestClusterClusterServerManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTestClusterClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfTestClusterClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Test Cluster Cluster Server Pre Attribute Changed * @@ -3197,9 +3173,8 @@ void emberAfThermostatClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThermostatClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfThermostatClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Thermostat Cluster Server Pre Attribute Changed * @@ -3267,8 +3242,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3339,8 +3313,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3411,9 +3384,8 @@ void emberAfWakeOnLanClusterServerManufacturerSpecificAttributeChangedCallback(c * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWakeOnLanClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfWakeOnLanClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Wake on LAN Cluster Server Pre Attribute Changed * @@ -3481,8 +3453,7 @@ void emberAfWiFiNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3553,7 +3524,7 @@ void emberAfWindowCoveringClusterServerManufacturerSpecificAttributeChangedCallb * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWindowCoveringClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfWindowCoveringClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -4463,8 +4434,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/bridge-app/bridge-common/gen/callback-stub.cpp b/examples/bridge-app/bridge-common/gen/callback-stub.cpp index 8929c3953c2598..4800ed20139dc5 100644 --- a/examples/bridge-app/bridge-common/gen/callback-stub.cpp +++ b/examples/bridge-app/bridge-common/gen/callback-stub.cpp @@ -406,9 +406,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/bridge-app/bridge-common/gen/callback.h b/examples/bridge-app/bridge-common/gen/callback.h index f1f0b390d52f55..d9aa86da0506a0 100644 --- a/examples/bridge-app/bridge-common/gen/callback.h +++ b/examples/bridge-app/bridge-common/gen/callback.h @@ -173,8 +173,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -242,9 +242,8 @@ void emberAfDescriptorClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfDescriptorClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfDescriptorClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Descriptor Cluster Server Pre Attribute Changed * @@ -313,8 +312,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -385,9 +383,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -456,9 +454,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -527,9 +525,8 @@ void emberAfLevelControlClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLevelControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLevelControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Level Control Cluster Server Pre Attribute Changed * @@ -597,9 +594,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -667,8 +664,8 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Server Pre Attribute Changed * @@ -736,9 +733,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -807,8 +804,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -879,8 +875,7 @@ void emberAfWiFiNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1312,8 +1307,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/lighting-app/lighting-common/gen/callback-stub.cpp b/examples/lighting-app/lighting-common/gen/callback-stub.cpp index f721e330f851cf..2570c789ba8a67 100644 --- a/examples/lighting-app/lighting-common/gen/callback-stub.cpp +++ b/examples/lighting-app/lighting-common/gen/callback-stub.cpp @@ -414,9 +414,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/lighting-app/lighting-common/gen/callback.h b/examples/lighting-app/lighting-common/gen/callback.h index 70f19e2c72c812..5383c0af7cd7bc 100644 --- a/examples/lighting-app/lighting-common/gen/callback.h +++ b/examples/lighting-app/lighting-common/gen/callback.h @@ -181,8 +181,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -251,8 +251,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -323,9 +322,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -394,9 +393,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -465,9 +464,8 @@ void emberAfLevelControlClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLevelControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLevelControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Level Control Cluster Server Pre Attribute Changed * @@ -535,9 +533,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -605,8 +603,8 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Server Pre Attribute Changed * @@ -674,8 +672,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -746,9 +743,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -817,8 +814,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -889,8 +885,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -961,8 +956,7 @@ void emberAfWiFiNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1447,8 +1441,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/lock-app/lock-common/gen/callback-stub.cpp b/examples/lock-app/lock-common/gen/callback-stub.cpp index b7cd6413f25725..26df6cc1357c0c 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -406,9 +406,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/lock-app/lock-common/gen/callback.h b/examples/lock-app/lock-common/gen/callback.h index 6c8f3f08d51869..8bfa7d4580f8af 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -173,8 +173,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -243,8 +243,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -315,9 +314,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -386,9 +385,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -457,9 +456,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -527,8 +526,8 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Server Pre Attribute Changed * @@ -596,8 +595,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -668,9 +666,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -739,8 +737,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -811,8 +808,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -883,8 +879,7 @@ void emberAfWiFiNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1316,8 +1311,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/pump-app/pump-common/gen/callback-stub.cpp b/examples/pump-app/pump-common/gen/callback-stub.cpp index 0b758d172855d0..af8e5fb1dc7d77 100644 --- a/examples/pump-app/pump-common/gen/callback-stub.cpp +++ b/examples/pump-app/pump-common/gen/callback-stub.cpp @@ -406,9 +406,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/pump-app/pump-common/gen/callback.h b/examples/pump-app/pump-common/gen/callback.h index 76e997021add1f..f2f65abf95c0ee 100644 --- a/examples/pump-app/pump-common/gen/callback.h +++ b/examples/pump-app/pump-common/gen/callback.h @@ -173,8 +173,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -243,8 +243,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -315,9 +314,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -386,9 +385,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -457,9 +456,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -527,8 +526,8 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Server Pre Attribute Changed * @@ -596,8 +595,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -669,8 +667,7 @@ void emberAfPumpConfigurationAndControlClusterServerManufacturerSpecificAttribut * @param message The message that was sent * @param status The status of the sent message */ -void emberAfPumpConfigurationAndControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfPumpConfigurationAndControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -741,9 +738,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -812,8 +809,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -884,8 +880,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1317,8 +1312,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp b/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp index 0896214984b929..008bfc4b753d7f 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp +++ b/examples/pump-controller-app/pump-controller-common/gen/callback-stub.cpp @@ -382,9 +382,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/pump-controller-app/pump-controller-common/gen/callback.h b/examples/pump-controller-app/pump-controller-common/gen/callback.h index d433e92ab4a785..fa9fe47a522d3f 100644 --- a/examples/pump-controller-app/pump-controller-common/gen/callback.h +++ b/examples/pump-controller-app/pump-controller-common/gen/callback.h @@ -149,8 +149,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -218,9 +218,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -289,9 +289,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -359,8 +359,8 @@ void emberAfOnOffClusterClientManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Client Pre Attribute Changed * @@ -428,8 +428,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -501,8 +500,7 @@ void emberAfPumpConfigurationAndControlClusterClientManufacturerSpecificAttribut * @param message The message that was sent * @param status The status of the sent message */ -void emberAfPumpConfigurationAndControlClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfPumpConfigurationAndControlClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -573,8 +571,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -645,8 +642,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1060,8 +1056,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/shell/shell_common/cmd_ping.cpp b/examples/shell/shell_common/cmd_ping.cpp index f8995db411deff..a1d7a0a56381a4 100644 --- a/examples/shell/shell_common/cmd_ping.cpp +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -220,7 +220,7 @@ CHIP_ERROR EstablishSecureSession(streamer_t * stream, Transport::PeerAddress & return err; } -void HandleEchoResponseReceived(Messaging::ExchangeContext * ec, System::PacketBufferHandle && payload) +void HandleEchoResponseReceived(Messaging::ExchangeHandle ec, System::PacketBufferHandle && payload) { uint32_t respTime = System::Timer::GetCurrentEpoch(); uint32_t transitTime = respTime - gPingArguments.GetLastEchoTime(); diff --git a/examples/shell/shell_common/cmd_send.cpp b/examples/shell/shell_common/cmd_send.cpp index 9a6ef3f4a9869d..bd8ff677fe4326 100644 --- a/examples/shell/shell_common/cmd_send.cpp +++ b/examples/shell/shell_common/cmd_send.cpp @@ -40,7 +40,7 @@ using namespace Logging; namespace { -Messaging::ExchangeContext * gExchangeCtx = nullptr; +Messaging::ExchangeHandle gExchangeCtx; class SendArguments { @@ -100,7 +100,7 @@ class SendArguments class MockAppDelegate : public Messaging::ExchangeDelegate { public: - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && buffer) override { uint32_t respTime = System::Timer::GetCurrentEpoch(); @@ -111,16 +111,16 @@ class MockAppDelegate : public Messaging::ExchangeDelegate static_cast(transitTime) / 1000); gExchangeCtx->Close(); - gExchangeCtx = nullptr; + gExchangeCtx.Release(); } - void OnResponseTimeout(Messaging::ExchangeContext * ec) override + void OnResponseTimeout(Messaging::ExchangeHandle ec) override { streamer_t * sout = streamer_get(); streamer_printf(sout, "No response received\n"); gExchangeCtx->Close(); - gExchangeCtx = nullptr; + gExchangeCtx.Release(); } } gMockAppDelegate; @@ -135,15 +135,15 @@ CHIP_ERROR SendMessage(streamer_t * stream) // Discard any existing exchange context. Effectively we can only have one exchange with // a single node at any one time. - if (gExchangeCtx != nullptr) + if (gExchangeCtx.HasValue()) { gExchangeCtx->Abort(); - gExchangeCtx = nullptr; + gExchangeCtx.Release(); } // Create a new exchange context. gExchangeCtx = gExchangeManager.NewContext({ kTestDeviceNodeId, 0, gAdminId }, &gMockAppDelegate); - VerifyOrExit(gExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(gExchangeCtx.HasValue(), err = CHIP_ERROR_NO_MEMORY); size = gSendArguments.GetPayloadSize(); VerifyOrExit(size <= kMaxPayloadSize, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH); @@ -177,7 +177,7 @@ CHIP_ERROR SendMessage(streamer_t * stream) if (err != CHIP_NO_ERROR) { gExchangeCtx->Abort(); - gExchangeCtx = nullptr; + gExchangeCtx.Release(); } exit: diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp index 0cea6cf249294c..6da4ea87caa34f 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp @@ -398,9 +398,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback.h b/examples/temperature-measurement-app/esp32/main/gen/callback.h index 0252d7b1011338..da2582db08bff6 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback.h +++ b/examples/temperature-measurement-app/esp32/main/gen/callback.h @@ -165,8 +165,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -235,8 +235,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -307,9 +306,9 @@ void emberAfGeneralCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Server Pre Attribute Changed * @@ -378,9 +377,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -449,9 +448,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -520,8 +519,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -592,9 +590,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -663,8 +661,7 @@ void emberAfTemperatureMeasurementClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTemperatureMeasurementClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTemperatureMeasurementClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -735,8 +732,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -807,8 +803,7 @@ void emberAfWiFiNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1222,8 +1217,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/tv-app/tv-common/gen/callback-stub.cpp b/examples/tv-app/tv-common/gen/callback-stub.cpp index bda990e2b57475..6161868520f857 100644 --- a/examples/tv-app/tv-common/gen/callback-stub.cpp +++ b/examples/tv-app/tv-common/gen/callback-stub.cpp @@ -494,9 +494,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/tv-app/tv-common/gen/callback.h b/examples/tv-app/tv-common/gen/callback.h index 1c45bc529347b3..1a6f85bcb37058 100644 --- a/examples/tv-app/tv-common/gen/callback.h +++ b/examples/tv-app/tv-common/gen/callback.h @@ -262,9 +262,8 @@ void emberAfAccountLoginClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfAccountLoginClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfAccountLoginClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Account Login Cluster Server Pre Attribute Changed * @@ -332,9 +331,9 @@ void emberAfApplicationBasicClusterServerManufacturerSpecificAttributeChangedCal * @param message The message that was sent * @param status The status of the sent message */ -void emberAfApplicationBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfApplicationBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Application Basic Cluster Server Pre Attribute Changed * @@ -403,9 +402,9 @@ void emberAfApplicationLauncherClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfApplicationLauncherClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfApplicationLauncherClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Application Launcher Cluster Server Pre Attribute Changed * @@ -474,9 +473,8 @@ void emberAfAudioOutputClusterServerManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfAudioOutputClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfAudioOutputClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Audio Output Cluster Server Pre Attribute Changed * @@ -544,7 +542,7 @@ void emberAfContentLaunchClusterServerManufacturerSpecificAttributeChangedCallba * @param message The message that was sent * @param status The status of the sent message */ -void emberAfContentLaunchClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfContentLaunchClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -614,9 +612,8 @@ void emberAfDescriptorClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfDescriptorClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfDescriptorClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Descriptor Cluster Server Pre Attribute Changed * @@ -685,8 +682,7 @@ void emberAfEthernetNetworkDiagnosticsClusterServerManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -757,9 +753,9 @@ void emberAfGeneralDiagnosticsClusterServerManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Server Pre Attribute Changed * @@ -828,9 +824,8 @@ void emberAfKeypadInputClusterServerManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfKeypadInputClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfKeypadInputClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Keypad Input Cluster Server Pre Attribute Changed * @@ -898,9 +893,8 @@ void emberAfLevelControlClusterServerManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLevelControlClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLevelControlClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Level Control Cluster Server Pre Attribute Changed * @@ -968,9 +962,8 @@ void emberAfLowPowerClusterServerManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLowPowerClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLowPowerClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Low Power Cluster Server Pre Attribute Changed * @@ -1038,9 +1031,8 @@ void emberAfMediaInputClusterServerManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfMediaInputClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfMediaInputClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Media Input Cluster Server Pre Attribute Changed * @@ -1108,7 +1100,7 @@ void emberAfMediaPlaybackClusterServerManufacturerSpecificAttributeChangedCallba * @param message The message that was sent * @param status The status of the sent message */ -void emberAfMediaPlaybackClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfMediaPlaybackClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1177,8 +1169,8 @@ void emberAfOnOffClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Server Pre Attribute Changed * @@ -1246,8 +1238,7 @@ void emberAfOperationalCredentialsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1318,9 +1309,9 @@ void emberAfSoftwareDiagnosticsClusterServerManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Server Pre Attribute Changed * @@ -1389,9 +1380,8 @@ void emberAfTvChannelClusterServerManufacturerSpecificAttributeChangedCallback(c * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTvChannelClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfTvChannelClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief TV Channel Cluster Server Pre Attribute Changed * @@ -1459,7 +1449,7 @@ void emberAfTargetNavigatorClusterServerManufacturerSpecificAttributeChangedCall * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTargetNavigatorClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfTargetNavigatorClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1530,8 +1520,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1602,8 +1591,7 @@ void emberAfTrustedRootCertificatesClusterServerManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1674,9 +1662,8 @@ void emberAfWakeOnLanClusterServerManufacturerSpecificAttributeChangedCallback(c * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWakeOnLanClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfWakeOnLanClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Wake on LAN Cluster Server Pre Attribute Changed * @@ -1744,8 +1731,7 @@ void emberAfWiFiNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfWiFiNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2151,8 +2137,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/examples/window-app/common/gen/callback-stub.cpp b/examples/window-app/common/gen/callback-stub.cpp index 49e83a51661cbe..ab010709e34541 100644 --- a/examples/window-app/common/gen/callback-stub.cpp +++ b/examples/window-app/common/gen/callback-stub.cpp @@ -350,9 +350,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/examples/window-app/common/gen/callback.h b/examples/window-app/common/gen/callback.h index 72f44a8251be2c..bf09d0c526eb4e 100644 --- a/examples/window-app/common/gen/callback.h +++ b/examples/window-app/common/gen/callback.h @@ -117,8 +117,8 @@ void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Server Pre Attribute Changed * @@ -186,9 +186,9 @@ void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Server Pre Attribute Changed * @@ -257,8 +257,7 @@ void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeCh * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -329,7 +328,7 @@ void emberAfWindowCoveringClusterServerManufacturerSpecificAttributeChangedCallb * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWindowCoveringClusterServerMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfWindowCoveringClusterServerMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -714,8 +713,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/src/app/Command.cpp b/src/app/Command.cpp index bea7e493370bf3..35560164e64942 100644 --- a/src/app/Command.cpp +++ b/src/app/Command.cpp @@ -216,10 +216,10 @@ CHIP_ERROR Command::AbortExistingExchangeContext() { // Discard any existing exchange context. Effectively we can only have one Echo exchange with // a single node at any one time. - if (mpExchangeCtx != nullptr) + if (mpExchangeCtx.HasValue()) { mpExchangeCtx->Abort(); - mpExchangeCtx = nullptr; + mpExchangeCtx.Release(); } return CHIP_NO_ERROR; diff --git a/src/app/Command.h b/src/app/Command.h index 9b79be051efae5..a00df3824da991 100644 --- a/src/app/Command.h +++ b/src/app/Command.h @@ -109,7 +109,7 @@ class Command * exchange context has been assigned or the context * has been released. */ - Messaging::ExchangeContext * GetExchangeContext() const { return mpExchangeCtx; } + const Messaging::ExchangeHandle GetExchangeContext() const { return mpExchangeCtx; } CHIP_ERROR Reset(); @@ -128,7 +128,7 @@ class Command InvokeCommand::Builder mInvokeCommandBuilder; Messaging::ExchangeManager * mpExchangeMgr = nullptr; - Messaging::ExchangeContext * mpExchangeCtx = nullptr; + Messaging::ExchangeHandle mpExchangeCtx; InteractionModelDelegate * mpDelegate = nullptr; chip::System::PacketBufferHandle mCommandMessageBuf; uint8_t mCommandIndex = 0; diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 4913ed423347f1..1738807e954725 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -33,7 +33,7 @@ using GeneralStatusCode = chip::Protocols::SecureChannel::GeneralStatusCode; namespace chip { namespace app { -void CommandHandler::OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, +void CommandHandler::OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -62,7 +62,7 @@ CHIP_ERROR CommandHandler::SendCommandResponse() err = FinalizeCommandsMessage(); SuccessOrExit(err); - VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mpExchangeCtx.HasValue(), err = CHIP_ERROR_INCORRECT_STATE); err = mpExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::InvokeCommandResponse, std::move(mCommandMessageBuf)); SuccessOrExit(err); diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index a3fe1e8309e30e..865521e74733a0 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -42,7 +42,7 @@ namespace app { class CommandHandler : public Command { public: - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload); CHIP_ERROR AddStatusCode(const CommandPathParams * apCommandPathParams, const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, const Protocols::Id aProtocolId, diff --git a/src/app/CommandSender.cpp b/src/app/CommandSender.cpp index 235ce294b1033a..653065bc6199ad 100644 --- a/src/app/CommandSender.cpp +++ b/src/app/CommandSender.cpp @@ -58,7 +58,7 @@ CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId, Transport::AdminId { mpExchangeCtx = mpExchangeMgr->NewContext(*secureSession, this); } - VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(mpExchangeCtx.HasValue(), err = CHIP_ERROR_NO_MEMORY); mpExchangeCtx->SetResponseTimeout(kImMessageTimeoutMsec); err = mpExchangeCtx->SendMessage( @@ -77,7 +77,7 @@ CHIP_ERROR CommandSender::SendCommandRequest(NodeId aNodeId, Transport::AdminId return err; } -void CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, +void CommandSender::OnMessageReceived(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -95,7 +95,7 @@ void CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExchangeCon // Close the exchange cleanly so that the ExchangeManager will send an ack for the message we just received. // This needs to be done before the Reset() call, because Reset() aborts mpExchangeCtx if its not null. mpExchangeCtx->Close(); - mpExchangeCtx = nullptr; + mpExchangeCtx.Release(); if (mpDelegate != nullptr) { @@ -112,7 +112,7 @@ void CommandSender::OnMessageReceived(Messaging::ExchangeContext * apExchangeCon Shutdown(); } -void CommandSender::OnResponseTimeout(Messaging::ExchangeContext * apExchangeContext) +void CommandSender::OnResponseTimeout(Messaging::ExchangeHandle apExchangeContext) { ChipLogProgress(DataManagement, "Time out! failed to receive invoke command response from Exchange: %d", apExchangeContext->GetExchangeId()); diff --git a/src/app/CommandSender.h b/src/app/CommandSender.h index aa0a47e7d2366f..1a18ab9ab3e213 100644 --- a/src/app/CommandSender.h +++ b/src/app/CommandSender.h @@ -58,9 +58,9 @@ class CommandSender : public Command, public Messaging::ExchangeDelegate // ExchangeDelegate interface implementation. Private so people won't // accidentally call it on us when we're not being treated as an actual // ExchangeDelegate. - void OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, + void OnMessageReceived(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) override; - void OnResponseTimeout(Messaging::ExchangeContext * apExchangeContext) override; + void OnResponseTimeout(Messaging::ExchangeHandle apExchangeContext) override; CHIP_ERROR ProcessCommandDataElement(CommandDataElement::Parser & aCommandElement) override; }; diff --git a/src/app/InteractionModelDelegate.h b/src/app/InteractionModelDelegate.h index f4f01c284ec3cf..2009ee1ff7a452 100644 --- a/src/app/InteractionModelDelegate.h +++ b/src/app/InteractionModelDelegate.h @@ -54,7 +54,7 @@ class InteractionModelDelegate * * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented */ - virtual CHIP_ERROR EventStreamReceived(const Messaging::ExchangeContext * apExchangeContext, TLV::TLVReader * apEventListReader) + virtual CHIP_ERROR EventStreamReceived(const Messaging::ExchangeHandle apExchangeContext, TLV::TLVReader * apEventListReader) { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 3b8515a858e92b..abd5c50f7bae0c 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -139,7 +139,7 @@ CHIP_ERROR InteractionModelEngine::NewReadClient(ReadClient ** const apReadClien return err; } -void InteractionModelEngine::OnUnknownMsgType(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, +void InteractionModelEngine::OnUnknownMsgType(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -151,18 +151,12 @@ void InteractionModelEngine::OnUnknownMsgType(Messaging::ExchangeContext * apExc // SuccessOrExit(err); apExchangeContext->Close(); - apExchangeContext = nullptr; + apExchangeContext.Release(); ChipLogFunctError(err); - - // Todo: Fix the below check after the above status report is implemented. - if (nullptr != apExchangeContext) - { - apExchangeContext->Abort(); - } } -void InteractionModelEngine::OnInvokeCommandRequest(Messaging::ExchangeContext * apExchangeContext, +void InteractionModelEngine::OnInvokeCommandRequest(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { @@ -175,7 +169,7 @@ void InteractionModelEngine::OnInvokeCommandRequest(Messaging::ExchangeContext * err = commandHandler.Init(mpExchangeMgr, mpDelegate); SuccessOrExit(err); commandHandler.OnMessageReceived(apExchangeContext, aPacketHeader, aPayloadHeader, std::move(aPayload)); - apExchangeContext = nullptr; + apExchangeContext.Release(); break; } } @@ -183,13 +177,13 @@ void InteractionModelEngine::OnInvokeCommandRequest(Messaging::ExchangeContext * exit: ChipLogFunctError(err); - if (nullptr != apExchangeContext) + if (apExchangeContext.HasValue()) { apExchangeContext->Abort(); } } -void InteractionModelEngine::OnReadRequest(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, +void InteractionModelEngine::OnReadRequest(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -204,7 +198,7 @@ void InteractionModelEngine::OnReadRequest(Messaging::ExchangeContext * apExchan SuccessOrExit(err); err = readHandler.OnReadRequest(apExchangeContext, std::move(aPayload)); SuccessOrExit(err); - apExchangeContext = nullptr; + apExchangeContext.Release(); break; } } @@ -212,13 +206,13 @@ void InteractionModelEngine::OnReadRequest(Messaging::ExchangeContext * apExchan exit: ChipLogFunctError(err); - if (nullptr != apExchangeContext) + if (apExchangeContext.HasValue()) { apExchangeContext->Abort(); } } -void InteractionModelEngine::OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, +void InteractionModelEngine::OnMessageReceived(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { if (aPayloadHeader.HasMessageType(Protocols::InteractionModel::MsgType::InvokeCommandRequest)) @@ -236,7 +230,7 @@ void InteractionModelEngine::OnMessageReceived(Messaging::ExchangeContext * apEx } } -void InteractionModelEngine::OnResponseTimeout(Messaging::ExchangeContext * ec) +void InteractionModelEngine::OnResponseTimeout(Messaging::ExchangeHandle ec) { ChipLogProgress(DataManagement, "Time out! failed to receive echo response from Exchange: %d", ec->GetExchangeId()); } diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index c2ff6ea0111a53..a2b22518d62e93 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -136,19 +137,19 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate private: friend class reporting::Engine; - void OnUnknownMsgType(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, + void OnUnknownMsgType(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload); - void OnInvokeCommandRequest(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, + void OnInvokeCommandRequest(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload); - void OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, + void OnMessageReceived(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload); - void OnResponseTimeout(Messaging::ExchangeContext * ec); + void OnResponseTimeout(Messaging::ExchangeHandle ec); /** * Called when Interaction Model receives a Read Request message. Errors processing * the Read Request are handled entirely within this function. */ - void OnReadRequest(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, + void OnReadRequest(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload); Messaging::ExchangeManager * mpExchangeMgr = nullptr; diff --git a/src/app/ReadClient.cpp b/src/app/ReadClient.cpp index e857eb5ea37396..0ce185ec0054e5 100644 --- a/src/app/ReadClient.cpp +++ b/src/app/ReadClient.cpp @@ -168,7 +168,7 @@ CHIP_ERROR ReadClient::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdmin } mpExchangeCtx = mpExchangeMgr->NewContext({ aNodeId, 0, aAdminId }, this); - VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(mpExchangeCtx.HasValue(), err = CHIP_ERROR_NO_MEMORY); mpExchangeCtx->SetResponseTimeout(kImMessageTimeoutMsec); err = mpExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::ReadRequest, std::move(msgBuf), @@ -187,7 +187,7 @@ CHIP_ERROR ReadClient::SendReadRequest(NodeId aNodeId, Transport::AdminId aAdmin return err; } -void ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, +void ReadClient::OnMessageReceived(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -202,7 +202,7 @@ void ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchangeContex // Close the exchange cleanly so that the ExchangeManager will send an ack for the message we just received. mpExchangeCtx->Close(); - mpExchangeCtx = nullptr; + mpExchangeCtx.Release(); MoveToState(ClientState::Initialized); if (mpDelegate != nullptr) @@ -222,10 +222,10 @@ void ReadClient::OnMessageReceived(Messaging::ExchangeContext * apExchangeContex CHIP_ERROR ReadClient::AbortExistingExchangeContext() { - if (mpExchangeCtx != nullptr) + if (mpExchangeCtx.HasValue()) { mpExchangeCtx->Abort(); - mpExchangeCtx = nullptr; + mpExchangeCtx.Release(); } return CHIP_NO_ERROR; @@ -311,7 +311,7 @@ CHIP_ERROR ReadClient::ProcessReportData(System::PacketBufferHandle && aPayload) return err; } -void ReadClient::OnResponseTimeout(Messaging::ExchangeContext * apExchangeContext) +void ReadClient::OnResponseTimeout(Messaging::ExchangeHandle apExchangeContext) { ChipLogProgress(DataManagement, "Time out! failed to receive report data from Exchange: %d", apExchangeContext->GetExchangeId()); diff --git a/src/app/ReadClient.h b/src/app/ReadClient.h index dae8a6878101f0..6105dec75f68ec 100644 --- a/src/app/ReadClient.h +++ b/src/app/ReadClient.h @@ -101,9 +101,9 @@ class ReadClient : public Messaging::ExchangeDelegate virtual ~ReadClient() = default; - void OnMessageReceived(Messaging::ExchangeContext * apExchangeContext, const PacketHeader & aPacketHeader, + void OnMessageReceived(Messaging::ExchangeHandle apExchangeContext, const PacketHeader & aPacketHeader, const PayloadHeader & aPayloadHeader, System::PacketBufferHandle && aPayload) override; - void OnResponseTimeout(Messaging::ExchangeContext * apExchangeContext) override; + void OnResponseTimeout(Messaging::ExchangeHandle apExchangeContext) override; /** * Check if current read client is being used @@ -119,7 +119,7 @@ class ReadClient : public Messaging::ExchangeDelegate const char * GetStateStr() const; Messaging::ExchangeManager * mpExchangeMgr = nullptr; - Messaging::ExchangeContext * mpExchangeCtx = nullptr; + Messaging::ExchangeHandle mpExchangeCtx; InteractionModelDelegate * mpDelegate = nullptr; ClientState mState = ClientState::Uninitialized; }; diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index cef5e6a3d8977e..4d86ecfe0ba4b3 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -34,8 +34,7 @@ CHIP_ERROR ReadHandler::Init(InteractionModelDelegate * apDelegate) CHIP_ERROR err = CHIP_NO_ERROR; // Error if already initialized. VerifyOrExit(apDelegate != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mpExchangeCtx == nullptr, err = CHIP_ERROR_INCORRECT_STATE); - mpExchangeCtx = nullptr; + VerifyOrExit(!mpExchangeCtx.HasValue(), err = CHIP_ERROR_INCORRECT_STATE); mpDelegate = apDelegate; mSuppressResponse = true; mpAttributeClusterInfoList = nullptr; @@ -62,16 +61,16 @@ void ReadHandler::Shutdown() CHIP_ERROR ReadHandler::AbortExistingExchangeContext() { - if (mpExchangeCtx != nullptr) + if (mpExchangeCtx.HasValue()) { mpExchangeCtx->Abort(); - mpExchangeCtx = nullptr; + mpExchangeCtx.Release(); } return CHIP_NO_ERROR; } -CHIP_ERROR ReadHandler::OnReadRequest(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload) +CHIP_ERROR ReadHandler::OnReadRequest(Messaging::ExchangeHandle apExchangeContext, System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; System::PacketBufferHandle response; @@ -93,7 +92,7 @@ CHIP_ERROR ReadHandler::OnReadRequest(Messaging::ExchangeContext * apExchangeCon CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload) { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(mpExchangeCtx != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mpExchangeCtx.HasValue(), err = CHIP_ERROR_INCORRECT_STATE); err = mpExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::ReportData, std::move(aPayload)); exit: diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index 8218b228eb6c67..d1683d5e3d3b1c 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -83,7 +83,7 @@ class ReadHandler * @retval #CHIP_NO_ERROR On success. * */ - CHIP_ERROR OnReadRequest(Messaging::ExchangeContext * apExchangeContext, System::PacketBufferHandle && aPayload); + CHIP_ERROR OnReadRequest(Messaging::ExchangeHandle apExchangeContext, System::PacketBufferHandle && aPayload); /** * Send ReportData to initiator @@ -130,7 +130,7 @@ class ReadHandler const char * GetStateStr() const; CHIP_ERROR AbortExistingExchangeContext(); - Messaging::ExchangeContext * mpExchangeCtx = nullptr; + Messaging::ExchangeHandle mpExchangeCtx; InteractionModelDelegate * mpDelegate = nullptr; // Don't need the response for report data if true diff --git a/src/app/clusters/ias-zone-client/ias-zone-client.cpp b/src/app/clusters/ias-zone-client/ias-zone-client.cpp index fe17ebdb647ced..ffd0713c132297 100644 --- a/src/app/clusters/ias-zone-client/ias-zone-client.cpp +++ b/src/app/clusters/ias-zone-client/ias-zone-client.cpp @@ -390,7 +390,8 @@ static void removeServer(uint8_t * ieeeAddress) static EmberStatus sendCommand(EmberNodeId destAddress) { emberAfSetCommandEndpoints(myEndpoint, emberAfIasZoneClientKnownServers[currentIndex].endpoint); - EmberStatus status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, destAddress); + MessageSendDestination destination = MessageSendDestination(MessageSendDestination::OutGoingDirect(destAddress)); + EmberStatus status = emberAfSendCommandUnicast(destination); emberAfIasZoneClusterPrintln("Sent IAS Zone Client Command to 0x%2X (%d -> %d) status: 0x%X", destAddress, myEndpoint, emberAfIasZoneClientKnownServers[currentIndex].endpoint, status); if (status != EMBER_SUCCESS) diff --git a/src/app/clusters/ias-zone-server/ias-zone-server.cpp b/src/app/clusters/ias-zone-server/ias-zone-server.cpp index c39e401261d5dc..f9329b11437b47 100644 --- a/src/app/clusters/ias-zone-server/ias-zone-server.cpp +++ b/src/app/clusters/ias-zone-server/ias-zone-server.cpp @@ -762,9 +762,8 @@ void emberAfPluginIasZoneServerPrintQueueConfig(void) // destination when the destination is the only router the node is joined to. // In that case, the command will never have been sent, as the device will have // had no router by which to send the command. -void emberAfIasZoneClusterServerMessageSentCallback(EmberOutgoingMessageType type, MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status) +void emberAfIasZoneClusterServerMessageSentCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status) { #if defined(EMBER_AF_PLUGIN_IAS_ZONE_SERVER_ENABLE_QUEUE) uint8_t frameControl; diff --git a/src/app/clusters/messaging-client/messaging-client.cpp b/src/app/clusters/messaging-client/messaging-client.cpp index 504b1168b76580..7aa8ba0d8afe15 100644 --- a/src/app/clusters/messaging-client/messaging-client.cpp +++ b/src/app/clusters/messaging-client/messaging-client.cpp @@ -328,8 +328,9 @@ EmberAfStatus emberAfPluginMessagingClientConfirmMessage(EndpointId endpoint) emberAfGetCurrentTime(), 0x00, ""); // The source and destination are reversed for the confirmation. emberAfSetCommandEndpoints(messageTable[ep].clientEndpoint, esiEntry->endpoint); - status = ((emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, nodeId) == EMBER_SUCCESS) ? EMBER_ZCL_STATUS_SUCCESS - : EMBER_ZCL_STATUS_FAILURE); + MessageSendDestination destination = MessageSendDestination(MessageSendDestination::OutGoingDirect(nodeId)); + status = + ((emberAfSendCommandUnicast(destination) == EMBER_SUCCESS) ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); } } else diff --git a/src/app/clusters/messaging-server/messaging-server.cpp b/src/app/clusters/messaging-server/messaging-server.cpp index e5ad2086aa59b6..47ebddaf6dfc6a 100644 --- a/src/app/clusters/messaging-server/messaging-server.cpp +++ b/src/app/clusters/messaging-server/messaging-server.cpp @@ -226,7 +226,8 @@ void emberAfPluginMessagingServerDisplayMessage(EmberNodeId nodeId, uint8_t srcE message.startTime, message.durationInMinutes, message.message, message.extendedMessageControl); emberAfSetCommandEndpoints(srcEndpoint, dstEndpoint); emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64; - status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, nodeId); + MessageSendDestination destination = MessageSendDestination(MessageSendDestination::OutGoingDirect(nodeId)); + status = emberAfSendCommandUnicast(destination); if (status != EMBER_SUCCESS) { emberAfMessagingClusterPrintln("Error in display %x", status); @@ -248,7 +249,8 @@ void emberAfPluginMessagingServerCancelMessage(EmberNodeId nodeId, uint8_t srcEn ZCL_CANCEL_MESSAGE_COMMAND_ID, "wu", message.messageId, message.messageControl); emberAfSetCommandEndpoints(srcEndpoint, dstEndpoint); emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64; - status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, nodeId); + MessageSendDestination destination = MessageSendDestination(MessageSendDestination::OutGoingDirect(nodeId)); + status = emberAfSendCommandUnicast(destination); if (status != EMBER_SUCCESS) { emberAfMessagingClusterPrintln("Error in cancel %x", status); diff --git a/src/app/reporting/reporting.cpp b/src/app/reporting/reporting.cpp index fbde4972cde499..d1c92ccd37499e 100644 --- a/src/app/reporting/reporting.cpp +++ b/src/app/reporting/reporting.cpp @@ -73,8 +73,8 @@ static void removeConfigurationAndScheduleTick(uint8_t index); static EmberAfStatus configureReceivedAttribute(const EmberAfClusterCommand * cmd, AttributeId attributeId, uint8_t mask, uint16_t timeout); static void putReportableChangeInResp(const EmberAfPluginReportingEntry * entry, EmberAfAttributeType dataType); -static void retrySendReport(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +static void retrySendReport(MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); static uint32_t computeStringHash(uint8_t * data, uint8_t length); EmberEventControl emberAfPluginReportingTickEventControl; @@ -99,13 +99,13 @@ EmberAfStatus emberAfPluginReportingConfiguredCallback(const EmberAfPluginReport return EMBER_ZCL_STATUS_SUCCESS; } -static void retrySendReport(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status) +static void retrySendReport(MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status) { // Retry once, and do so by unicasting without a pointer to this callback if (status != EMBER_SUCCESS) { - emberAfSendUnicast(type, destination, apsFrame, msgLen, message); + emberAfSendUnicast(destination, apsFrame, msgLen, message); } } diff --git a/src/app/server/EchoHandler.cpp b/src/app/server/EchoHandler.cpp index 16fa70ee8a7b9b..947bdab015ec25 100644 --- a/src/app/server/EchoHandler.cpp +++ b/src/app/server/EchoHandler.cpp @@ -38,7 +38,7 @@ chip::Protocols::Echo::EchoServer gEchoServer; * that it will free the buffer before returning. * */ -void HandleEchoRequestReceived(chip::Messaging::ExchangeContext * ec, chip::System::PacketBufferHandle && payload) +void HandleEchoRequestReceived(chip::Messaging::ExchangeHandle ec, chip::System::PacketBufferHandle && payload) { ChipLogProgress(AppServer, "Echo Request, len=%u ... sending response.\n", payload->DataLength()); } diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 3e6a908f6385c6..6503355d005bf9 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -315,7 +315,7 @@ static CHIP_ERROR OpenPairingWindowUsingVerifier(uint16_t discriminator, PASEVer class ServerCallback : public ExchangeDelegate { public: - void OnMessageReceived(Messaging::ExchangeContext * exchangeContext, const PacketHeader & packetHeader, + void OnMessageReceived(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && buffer) override { // as soon as a client connects, assume it is connected @@ -382,7 +382,7 @@ class ServerCallback : public ExchangeDelegate exchangeContext->Close(); } - void OnResponseTimeout(ExchangeContext * ec) override + void OnResponseTimeout(ExchangeHandle ec) override { ChipLogProgress(AppServer, "Failed to receive response"); if (mDelegate != nullptr) diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index 5cbb314538d3cb..416992397bb965 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -113,11 +113,11 @@ class TestCommandInteraction class TestExchangeDelegate : public Messaging::ExchangeDelegate { - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override {} - void OnResponseTimeout(Messaging::ExchangeContext * ec) override {} + void OnResponseTimeout(Messaging::ExchangeHandle ec) override {} }; void TestCommandInteraction::GenerateReceivedCommand(nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload, diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 5831a2ffc68a55..477c4d8e4c89b0 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -136,7 +136,7 @@ void TestReadInteraction::TestReadHandler(nlTestSuite * apSuite, void * apContex err = writer.Finalize(&readRequestbuf); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - err = readHandler.OnReadRequest(nullptr, std::move(readRequestbuf)); + err = readHandler.OnReadRequest(Messaging::ExchangeHandle(), std::move(readRequestbuf)); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); } diff --git a/src/app/tests/TestReportingEngine.cpp b/src/app/tests/TestReportingEngine.cpp index 5c0fec489efe01..3ef4b1855d344b 100644 --- a/src/app/tests/TestReportingEngine.cpp +++ b/src/app/tests/TestReportingEngine.cpp @@ -89,11 +89,11 @@ class TestReportingEngine class TestExchangeDelegate : public Messaging::ExchangeDelegate { - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override {} - void OnResponseTimeout(Messaging::ExchangeContext * ec) override {} + void OnResponseTimeout(Messaging::ExchangeHandle ec) override {} }; void TestReportingEngine::TestBuildAndSendSingleReportData(nlTestSuite * apSuite, void * apContext) @@ -109,7 +109,7 @@ void TestReportingEngine::TestBuildAndSendSingleReportData(nlTestSuite * apSuite err = InteractionModelEngine::GetInstance()->Init(&gExchangeManager, nullptr); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); - Messaging::ExchangeContext * exchangeCtx = gExchangeManager.NewContext({ 0, 0, 0 }, nullptr); + Messaging::ExchangeHandle exchangeCtx = gExchangeManager.NewContext({ 0, 0, 0 }, nullptr); TestExchangeDelegate delegate; exchangeCtx->SetDelegate(&delegate); diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index 5b9fffc3f3d24e..406997b1edef70 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -244,7 +244,7 @@ void HandleReadComplete() class MockInteractionModelApp : public chip::app::InteractionModelDelegate { public: - CHIP_ERROR EventStreamReceived(const chip::Messaging::ExchangeContext * apExchangeContext, + CHIP_ERROR EventStreamReceived(const chip::Messaging::ExchangeHandle apExchangeContext, chip::TLV::TLVReader * apEventListReader) override { return CHIP_NO_ERROR; diff --git a/src/app/util/DataModelHandler.cpp b/src/app/util/DataModelHandler.cpp index d9202fdc2aff42..be318a32f6288d 100644 --- a/src/app/util/DataModelHandler.cpp +++ b/src/app/util/DataModelHandler.cpp @@ -65,7 +65,7 @@ void InitDataModelHandler(chip::Messaging::ExchangeManager * exchangeManager) #endif } -void HandleDataModelMessage(Messaging::ExchangeContext * exchange, System::PacketBufferHandle && buffer) +void HandleDataModelMessage(Messaging::ExchangeHandle exchange, System::PacketBufferHandle && buffer) { #ifdef USE_ZAP_CONFIG EmberApsFrame frame; diff --git a/src/app/util/DataModelHandler.h b/src/app/util/DataModelHandler.h index 99cf71873cf8b7..5d25c504e59ca5 100644 --- a/src/app/util/DataModelHandler.h +++ b/src/app/util/DataModelHandler.h @@ -43,4 +43,4 @@ void InitDataModelHandler(chip::Messaging::ExchangeManager * exchangeMgr); * that it will free the buffer before returning. * */ -void HandleDataModelMessage(chip::Messaging::ExchangeContext * exchange, chip::System::PacketBufferHandle && buffer); +void HandleDataModelMessage(chip::Messaging::ExchangeHandle exchange, chip::System::PacketBufferHandle && buffer); diff --git a/src/app/util/af-main-common.cpp b/src/app/util/af-main-common.cpp index 6ffd8cd5983822..09ccd2ada82967 100644 --- a/src/app/util/af-main-common.cpp +++ b/src/app/util/af-main-common.cpp @@ -202,9 +202,8 @@ void emAfInitializeMessageSentCallbackArray(void) } } -static EmberStatus send(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t messageLength, uint8_t * message, bool broadcast, EmberNodeId alias, uint8_t sequence, - EmberAfMessageSentFunction callback) +static EmberStatus send(const MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t messageLength, + uint8_t * message, bool broadcast, EmberNodeId alias, uint8_t sequence, EmberAfMessageSentFunction callback) { EmberStatus status; uint8_t index; @@ -268,7 +267,7 @@ static EmberStatus send(EmberOutgoingMessageType type, MessageSendDestination de { EmberAfMessageStruct messageStruct = { - callback, apsFrame, message, destination, messageLength, type, broadcast, + callback, apsFrame, message, destination, messageLength, broadcast, }; // Called prior to fragmentation in case the mesasge does not go out over the // Zigbee radio, and instead goes to some other transport that does not require @@ -285,7 +284,7 @@ static EmberStatus send(EmberOutgoingMessageType type, MessageSendDestination de if (messageLength <= EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH) { - status = emAfSend(type, destination, apsFrame, (uint8_t) messageLength, message, &messageTag, alias, sequence); + status = emAfSend(destination, apsFrame, (uint8_t) messageLength, message, &messageTag, alias, sequence); } else { @@ -297,7 +296,7 @@ static EmberStatus send(EmberOutgoingMessageType type, MessageSendDestination de if ((status != EMBER_SUCCESS) && (callback == emberAfPluginCriticalMessageQueueEnqueueCallback || callback == emAfPluginCriticalMessageQueueRetryCallback)) { - callback(type, destination, apsFrame, messageLength, message, status); + callback(destination, apsFrame, messageLength, message, status); } #endif // EMBER_AF_PLUGIN_CRITICAL_MESSAGE_QUEUE @@ -331,8 +330,9 @@ EmberStatus emberAfSendMulticastWithAliasWithCallback(GroupId multicastId, Ember uint8_t * message, EmberNodeId alias, uint8_t sequence, EmberAfMessageSentFunction callback) { - apsFrame->groupId = multicastId; - return send(EMBER_OUTGOING_MULTICAST_WITH_ALIAS, MessageSendDestination(multicastId), apsFrame, messageLength, message, + apsFrame->groupId = multicastId; + const MessageSendDestination destination = MessageSendDestination::Multicast(multicastId); + return send(destination, apsFrame, messageLength, message, true, // broadcast alias, sequence, callback); } @@ -340,8 +340,9 @@ EmberStatus emberAfSendMulticastWithAliasWithCallback(GroupId multicastId, Ember EmberStatus emberAfSendMulticastWithCallback(GroupId multicastId, EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * message, EmberAfMessageSentFunction callback) { - apsFrame->groupId = multicastId; - return send(EMBER_OUTGOING_MULTICAST, MessageSendDestination(multicastId), apsFrame, messageLength, message, + apsFrame->groupId = multicastId; + const MessageSendDestination destination = MessageSendDestination::Multicast(multicastId); + return send(destination, apsFrame, messageLength, message, true, // broadcast? 0, // alias 0, // sequence @@ -422,13 +423,12 @@ EmberStatus emberAfSendMulticastToBindings(EmberApsFrame * apsFrame, uint16_t me // return emberAfSendBroadcastWithCallback(destination, apsFrame, messageLength, message, NULL); //} -EmberStatus emberAfSendUnicastWithCallback(EmberOutgoingMessageType type, MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * message, - EmberAfMessageSentFunction callback) +EmberStatus emberAfSendUnicastWithCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t messageLength, uint8_t * message, EmberAfMessageSentFunction callback) { // The source endpoint in the APS frame MAY NOT be valid at this point if the // outgoing type is "via binding." - if (type == EMBER_OUTGOING_VIA_BINDING) + if (destination.IsViaBinding()) { // If using binding, set the endpoints based on those in the binding. The // cluster in the binding is not used because bindings can be used to send @@ -436,7 +436,7 @@ EmberStatus emberAfSendUnicastWithCallback(EmberOutgoingMessageType type, Messag EmberBindingTableEntry binding; // TODO: This cast should go away once // https://github.com/project-chip/connectedhomeip/issues/3584 is fixed. - EmberStatus status = emberGetBinding(destination.mBindingIndex, &binding); + EmberStatus status = emberGetBinding(destination.Get().mBindingIndex, &binding); if (status != EMBER_SUCCESS) { return status; @@ -444,17 +444,17 @@ EmberStatus emberAfSendUnicastWithCallback(EmberOutgoingMessageType type, Messag apsFrame->sourceEndpoint = binding.local; apsFrame->destinationEndpoint = binding.remote; } - return send(type, destination, apsFrame, messageLength, message, + return send(destination, apsFrame, messageLength, message, false, // broadcast? 0, // alias 0, // sequence callback); } -EmberStatus emberAfSendUnicast(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t messageLength, uint8_t * message) +EmberStatus emberAfSendUnicast(const MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t messageLength, + uint8_t * message) { - return emberAfSendUnicastWithCallback(type, destination, apsFrame, messageLength, message, NULL); + return emberAfSendUnicastWithCallback(destination, apsFrame, messageLength, message, NULL); } EmberStatus emberAfSendUnicastToBindingsWithCallback(EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * message, @@ -474,8 +474,9 @@ EmberStatus emberAfSendUnicastToBindingsWithCallback(EmberApsFrame * apsFrame, u if (binding.type == EMBER_UNICAST_BINDING && binding.local == apsFrame->sourceEndpoint && binding.clusterId == apsFrame->clusterId) { - apsFrame->destinationEndpoint = binding.remote; - status = send(EMBER_OUTGOING_VIA_BINDING, MessageSendDestination(i), apsFrame, messageLength, message, + apsFrame->destinationEndpoint = binding.remote; + const MessageSendDestination destination = MessageSendDestination::ViaBinding(i); + status = send(destination, apsFrame, messageLength, message, false, // broadcast? 0, // alias 0, // sequence @@ -547,7 +548,7 @@ void emAfPrintStatus(const char * task, EmberStatus status) // Functions called by the Serial Command Line Interface (CLI) // ****************************************************************** -static void printMessage(EmberIncomingMessageType type, EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * messageContents) +static void printMessage(EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * messageContents) { emberAfAppPrint("Cluster: 0x%2X, %d bytes,", apsFrame->clusterId, messageLength); if (messageLength >= 3) @@ -558,14 +559,14 @@ static void printMessage(EmberIncomingMessageType type, EmberApsFrame * apsFrame emberAfAppPrintln(""); } -void emAfMessageSentHandler(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - EmberStatus status, uint16_t messageLength, uint8_t * messageContents, uint8_t messageTag) +void emAfMessageSentHandler(const MessageSendDestination & destination, EmberApsFrame * apsFrame, EmberStatus status, + uint16_t messageLength, uint8_t * messageContents, uint8_t messageTag) { EmberAfMessageSentFunction callback; if (status != EMBER_SUCCESS) { emberAfAppPrint("%ptx %x, ", "ERROR: ", status); - printMessage(type, apsFrame, messageLength, messageContents); + printMessage(apsFrame, messageLength, messageContents); } callback = getMessageSentCallback(messageTag); @@ -576,7 +577,7 @@ void emAfMessageSentHandler(EmberOutgoingMessageType type, MessageSendDestinatio if (messageContents != NULL && messageContents[0] & ZCL_CLUSTER_SPECIFIC_COMMAND) { emberAfClusterMessageSentWithMfgCodeCallback( - type, destination, apsFrame, messageLength, messageContents, status, + destination, apsFrame, messageLength, messageContents, status, // If the manufacturer specific flag is set // get read it as next part of message // else use null code. @@ -587,24 +588,23 @@ void emAfMessageSentHandler(EmberOutgoingMessageType type, MessageSendDestinatio if (callback != NULL) { - (*callback)(type, destination, apsFrame, messageLength, messageContents, status); + (*callback)(destination, apsFrame, messageLength, messageContents, status); } #ifdef EMBER_AF_GENERATED_PLUGIN_MESSAGE_SENT_FUNCTION_CALLS EMBER_AF_GENERATED_PLUGIN_MESSAGE_SENT_FUNCTION_CALLS #endif - emberAfMessageSentCallback(type, destination, apsFrame, messageLength, messageContents, status); + emberAfMessageSentCallback(destination, apsFrame, messageLength, messageContents, status); } #ifdef EMBER_AF_PLUGIN_FRAGMENTATION -void emAfFragmentationMessageSentHandler(EmberOutgoingMessageType type, MessageSendDestination destination, - EmberApsFrame * apsFrame, uint8_t * buffer, uint16_t bufLen, EmberStatus status, - uint8_t messageTag) +void emAfFragmentationMessageSentHandler(const MessageSendDestination & destination, EmberApsFrame * apsFrame, uint8_t * buffer, + uint16_t bufLen, EmberStatus status, uint8_t messageTag) { // the fragmented message is no longer in process emberAfDebugPrintln("%pend.", "Fragmentation:"); - emAfMessageSentHandler(type, destination, apsFrame, status, bufLen, buffer, messageTag); + emAfMessageSentHandler(destination, apsFrame, status, bufLen, buffer, messageTag); // EMZIGBEE-4437: setting back the buffers to the original in case someone set // that to something else. @@ -612,8 +612,8 @@ void emAfFragmentationMessageSentHandler(EmberOutgoingMessageType type, MessageS } #endif // EMBER_AF_PLUGIN_FRAGMENTATION -EmberStatus emAfSend(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - uint8_t messageLength, uint8_t * message, uint8_t * messageTag, EmberNodeId alias, uint8_t sequence) +EmberStatus emAfSend(const MessageSendDestination & destination, EmberApsFrame * apsFrame, uint8_t messageLength, uint8_t * message, + uint8_t * messageTag, EmberNodeId alias, uint8_t sequence) { // TODO: There's an impedance mismatch here in a few ways: // 1) The caller expects to get a messageTag out that will identify this @@ -630,11 +630,11 @@ EmberStatus emAfSend(EmberOutgoingMessageType type, MessageSendDestination desti // tracks this. *messageTag = INVALID_MESSAGE_TAG; EmberStatus status = EMBER_SUCCESS; - switch (type) + switch (destination.GetType()) { - case EMBER_OUTGOING_VIA_BINDING: { + case MessageSendDestination::VariantViaBinding::VariantId: { EmberBindingTableEntry binding; - status = emberGetBinding(destination.mBindingIndex, &binding); + status = emberGetBinding(destination.Get().mBindingIndex, &binding); if (status != EMBER_SUCCESS) { break; @@ -647,31 +647,33 @@ EmberStatus emAfSend(EmberOutgoingMessageType type, MessageSendDestination desti status = chipSendUnicast(binding.nodeId, apsFrame, messageLength, message); break; } - case EMBER_OUTGOING_VIA_ADDRESS_TABLE: + case MessageSendDestination::VariantViaAddressTable::VariantId: // No implementation yet. status = EMBER_ERR_FATAL; break; - case EMBER_OUTGOING_DIRECT: - status = chipSendUnicast(destination.mNodeId, apsFrame, messageLength, message); + case MessageSendDestination::VariantDirect::VariantId: + status = + chipSendUnicast(destination.Get().mNodeId, apsFrame, messageLength, message); break; - case EMBER_OUTGOING_MULTICAST: + case MessageSendDestination::VariantMulticast::VariantId: // No implementation yet. status = EMBER_ERR_FATAL; break; - case EMBER_OUTGOING_MULTICAST_WITH_ALIAS: + case MessageSendDestination::VariantMulticastWithAlias::VariantId: // No implementation yet. status = EMBER_ERR_FATAL; break; - case EMBER_OUTGOING_BROADCAST: + case MessageSendDestination::VariantBroadcast::VariantId: // No implementation yet. status = EMBER_ERR_FATAL; break; - case EMBER_OUTGOING_BROADCAST_WITH_ALIAS: + case MessageSendDestination::VariantBroadcastWithAlias::VariantId: // No implementation yet. status = EMBER_ERR_FATAL; break; - case EMBER_OUTGOING_VIA_EXCHANGE: - status = chipSendUnicast(destination.mExchangeContext, apsFrame, messageLength, message); + case MessageSendDestination::VariantViaExchange::VariantId: + status = chipSendUnicast(destination.Get().mExchangeContext, apsFrame, + messageLength, message); break; default: status = EMBER_BAD_ARGUMENT; diff --git a/src/app/util/af-main.h b/src/app/util/af-main.h index 777fde0ebe4b90..19c0ec81489671 100644 --- a/src/app/util/af-main.h +++ b/src/app/util/af-main.h @@ -121,10 +121,10 @@ bool emAfProcessZdo(EmberNodeId sender, EmberApsFrame * apsFrame, uint8_t * mess void emAfIncomingMessageHandler(EmberIncomingMessageType type, EmberApsFrame * apsFrame, uint8_t lastHopLqi, int8_t lastHopRssi, uint16_t messageLength, uint8_t * messageContents); -EmberStatus emAfSend(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint8_t messageLength, uint8_t * message, uint8_t * messageTag, EmberNodeId alias, uint8_t sequence); -void emAfMessageSentHandler(EmberOutgoingMessageType type, uint64_t indexOrDestination, EmberApsFrame * apsFrame, - EmberStatus status, uint16_t messageLength, uint8_t * messageContents, uint8_t messageTag); +EmberStatus emAfSend(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint8_t messageLength, + uint8_t * message, uint8_t * messageTag, EmberNodeId alias, uint8_t sequence); +void emAfMessageSentHandler(chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, EmberStatus status, + uint16_t messageLength, uint8_t * messageContents, uint8_t messageTag); void emAfStackStatusHandler(EmberStatus status); void emAfNetworkInit(void); diff --git a/src/app/util/af-types.h b/src/app/util/af-types.h index 7df8c212ca8b7d..b24f580dec9c3a 100644 --- a/src/app/util/af-types.h +++ b/src/app/util/af-types.h @@ -56,6 +56,7 @@ #include // For various types. #include +#include #ifdef EZSP_HOST #include "app/util/ezsp/ezsp-enum.h" @@ -434,6 +435,7 @@ typedef struct */ struct EmberAfClusterCommand { + EmberAfClusterCommand() : source() {} chip::NodeId SourceNodeId() const { return source->GetSecureSession().GetPeerNodeId(); } /** @@ -441,7 +443,7 @@ struct EmberAfClusterCommand */ EmberApsFrame * apsFrame; EmberIncomingMessageType type; - chip::Messaging::ExchangeContext * source; + chip::Messaging::ExchangeHandle source; uint8_t * buffer; uint16_t bufLen; bool clusterSpecific; @@ -1252,26 +1254,105 @@ typedef void (*EmberAfDefaultResponseFunction)(chip::EndpointId endpoint, chip:: namespace chip { /** - * @brief a type that represents where we are trying to send a message. This - * must always be paired with an EmberOutgoingMessageType that identifies - * which arm of the union is in use. - */ -union MessageSendDestination -{ - explicit constexpr MessageSendDestination(uint8_t aBindingIndex) : mBindingIndex(aBindingIndex) {} - explicit constexpr MessageSendDestination(NodeId aNodeId) : mNodeId(aNodeId) {} - explicit constexpr MessageSendDestination(GroupId aGroupId) : mGroupId(aGroupId) {} - explicit constexpr MessageSendDestination(Messaging::ExchangeContext * aExchangeContext) : mExchangeContext(aExchangeContext) {} - - // Used when the type is EMBER_OUTGOING_VIA_BINDING - uint8_t mBindingIndex; - // Used when the type is EMBER_OUTGOING_DIRECT - NodeId mNodeId; - // Used when the type is EMBER_OUTGOING_MULTICAST or - // EMBER_OUTGOING_MULTICAST_WITH_ALIAS - GroupId mGroupId; - // Used when the type is EMBER_OUTGOING_VIA_EXCHANGE - Messaging::ExchangeContext * mExchangeContext; + * @brief a type that represents where we are trying to send a message. + * The variant type identifies which arm of the union is in use. + */ +class MessageSendDestination +{ +public: + struct VariantViaBinding + { + static constexpr const std::size_t VariantId = 1; + explicit VariantViaBinding(uint8_t bindingIndex) : mBindingIndex(bindingIndex) {} + uint8_t mBindingIndex; + }; + + struct VariantViaAddressTable + { + static constexpr const std::size_t VariantId = 2; + }; + + struct VariantDirect + { + static constexpr const std::size_t VariantId = 3; + explicit VariantDirect(NodeId nodeId) : mNodeId(nodeId) {} + NodeId mNodeId; + }; + + struct VariantMulticast + { + static constexpr const std::size_t VariantId = 4; + explicit VariantMulticast(GroupId groupId) : mGroupId(groupId) {} + GroupId mGroupId; + }; + + struct VariantMulticastWithAlias + { + static constexpr const std::size_t VariantId = 5; + explicit VariantMulticastWithAlias(GroupId groupId) : mGroupId(groupId) {} + GroupId mGroupId; + }; + + struct VariantBroadcast + { + static constexpr const std::size_t VariantId = 6; + }; + + struct VariantBroadcastWithAlias + { + static constexpr const std::size_t VariantId = 7; + }; + + struct VariantViaExchange + { + static constexpr const std::size_t VariantId = 8; + explicit VariantViaExchange(Messaging::ExchangeHandle exchangeContext) : mExchangeContext(exchangeContext) {} + Messaging::ExchangeHandle mExchangeContext; + }; + + MessageSendDestination(MessageSendDestination & that) = default; + MessageSendDestination(const MessageSendDestination & that) = default; + MessageSendDestination(MessageSendDestination && that) = default; + + static MessageSendDestination ViaBinding(uint8_t bindingIndex) + { + return MessageSendDestination(VariantViaBinding(bindingIndex)); + } + + static MessageSendDestination Direct(NodeId nodeId) { return MessageSendDestination(VariantDirect(nodeId)); } + + static MessageSendDestination Multicast(GroupId groupId) { return MessageSendDestination(VariantMulticast(groupId)); } + + static MessageSendDestination MulticastWithAlias(GroupId groupId) + { + return MessageSendDestination(VariantMulticastWithAlias(groupId)); + } + + static MessageSendDestination ViaExchange(Messaging::ExchangeHandle exchangeContext) + { + return MessageSendDestination(VariantViaExchange(exchangeContext)); + } + + std::size_t GetType() const { return mDestination.GetType(); } + + bool IsViaBinding() const { return mDestination.Is(); } + + template + const Destination & Get() const + { + return mDestination.Get(); + } + +private: + template + MessageSendDestination(Destination && destination) + { + mDestination.Set(std::forward(destination)); + } + + Variant + mDestination; }; } // namespace chip @@ -1280,8 +1361,8 @@ union MessageSendDestination * * This function is called when a message is sent. */ -typedef void (*EmberAfMessageSentFunction)(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +typedef void (*EmberAfMessageSentFunction)(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** * @brief The EmberAfMessageStruct is a struct wrapper that @@ -1293,9 +1374,8 @@ typedef struct EmberAfMessageSentFunction callback; EmberApsFrame * apsFrame; uint8_t * message; - chip::MessageSendDestination destination; + const chip::MessageSendDestination destination; uint16_t messageLength; - EmberOutgoingMessageType type; bool broadcast; } EmberAfMessageStruct; diff --git a/src/app/util/af.h b/src/app/util/af.h index 239a8ba183227f..ae8128aa0cf54d 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -1297,15 +1297,14 @@ EmberStatus emberAfSendMulticastWithCallback(chip::GroupId multicastId, EmberAps /** * @brief Sends unicast. */ -EmberStatus emberAfSendUnicast(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t messageLength, uint8_t * message); +EmberStatus emberAfSendUnicast(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t messageLength, + uint8_t * message); /** * @brief Sends unicast with attached message sent callback. */ -EmberStatus emberAfSendUnicastWithCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * message, - EmberAfMessageSentFunction callback); +EmberStatus emberAfSendUnicastWithCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t messageLength, uint8_t * message, EmberAfMessageSentFunction callback); /** * @brief Unicasts the message to each remote node in the binding table that @@ -1391,12 +1390,12 @@ EmberStatus emberAfSendCommandMulticastToBindings(void); * using the emberAfFill... macros from the client command API. * It will be sent as unicast. */ -EmberStatus emberAfSendCommandUnicast(EmberOutgoingMessageType type, uint16_t indexOrDestination); +EmberStatus emberAfSendCommandUnicast(const chip::MessageSendDestination & destination); /** * @brief emberAfSendCommandUnicast with attached message sent callback. */ -EmberStatus emberAfSendCommandUnicastWithCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, +EmberStatus emberAfSendCommandUnicastWithCallback(const chip::MessageSendDestination & destination, EmberAfMessageSentFunction callback); /** diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 6948c7ba36206c..d65f7cd87de58d 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -214,9 +214,8 @@ void emberAfClusterDefaultResponseCallback(EndpointId endpoint, ClusterId cluste } // This function is used to call the per-cluster message sent callback -void emberAfClusterMessageSentWithMfgCodeCallback(EmberOutgoingMessageType type, MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status, - uint16_t mfgCode) +void emberAfClusterMessageSentWithMfgCodeCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status, uint16_t mfgCode) { if (apsFrame != NULL && message != NULL && msgLen != 0) { @@ -231,7 +230,7 @@ void emberAfClusterMessageSentWithMfgCodeCallback(EmberOutgoingMessageType type, if (f != NULL) { // emberAfPushEndpointNetworkIndex(apsFrame->sourceEndpoint); - ((EmberAfMessageSentFunction) f)(type, destination, apsFrame, msgLen, message, status); + ((EmberAfMessageSentFunction) f)(destination, apsFrame, msgLen, message, status); // emberAfPopNetworkIndex(); } } @@ -241,11 +240,10 @@ void emberAfClusterMessageSentWithMfgCodeCallback(EmberOutgoingMessageType type, // This function is used to call the per-cluster message sent callback, and // wraps the emberAfClusterMessageSentWithMfgCodeCallback with a // EMBER_AF_NULL_MANUFACTURER_CODE. -void emberAfClusterMessageSentCallback(EmberOutgoingMessageType type, MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status) +void emberAfClusterMessageSentCallback(MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status) { - emberAfClusterMessageSentWithMfgCodeCallback(type, destination, apsFrame, msgLen, message, status, - EMBER_AF_NULL_MANUFACTURER_CODE); + emberAfClusterMessageSentWithMfgCodeCallback(destination, apsFrame, msgLen, message, status, EMBER_AF_NULL_MANUFACTURER_CODE); } // This function is used to call the per-cluster attribute changed callback diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index 37059bddf19cd1..5e62539b0bdb38 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -189,12 +189,12 @@ void emberAfClusterDefaultResponseWithMfgCodeCallback(chip::EndpointId endpoint, EmberAfStatus status, uint8_t clientServerMask, uint16_t manufacturerCode); // Calls the message sent callback for a specific cluster, and wraps emberAfClusterMessageSentWithMfgCodeCallback -void emberAfClusterMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfClusterMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); // Calls the message sent callback for a specific cluster. -void emberAfClusterMessageSentWithMfgCodeCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status, +void emberAfClusterMessageSentWithMfgCodeCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status, uint16_t manufacturerCode); // Used to retrieve a manufacturer code from an attribute metadata diff --git a/src/app/util/chip-message-send.cpp b/src/app/util/chip-message-send.cpp index ff43a94491dad5..298c23f8244682 100644 --- a/src/app/util/chip-message-send.cpp +++ b/src/app/util/chip-message-send.cpp @@ -43,16 +43,16 @@ namespace chip { // Delete this class when Device::SendMessage() is obsoleted. class DeviceExchangeDelegate : public Messaging::ExchangeDelegate { - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override {} - void OnResponseTimeout(Messaging::ExchangeContext * ec) override {} + void OnResponseTimeout(Messaging::ExchangeHandle ec) override {} }; extern Messaging::ExchangeManager * ExchangeManager(); } // namespace chip -EmberStatus chipSendUnicast(Messaging::ExchangeContext * exchange, EmberApsFrame * apsFrame, uint16_t messageLength, +EmberStatus chipSendUnicast(Messaging::ExchangeHandle exchange, EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * message, Messaging::SendFlags sendFlags) { uint16_t frameSize = encodeApsFrame(nullptr, 0, apsFrame); @@ -108,8 +108,8 @@ EmberStatus chipSendUnicast(NodeId destination, EmberApsFrame * apsFrame, uint16 return EMBER_DELIVERY_FAILED; } - Messaging::ExchangeContext * exchange = exchangeMgr->NewContext({ destination, Transport::kAnyKeyId, 0 }, nullptr); - if (exchange == nullptr) + Messaging::ExchangeHandle exchange = exchangeMgr->NewContext({ destination, Transport::kAnyKeyId, 0 }, nullptr); + if (!exchange.HasValue()) { return EMBER_DELIVERY_FAILED; } diff --git a/src/app/util/chip-message-send.h b/src/app/util/chip-message-send.h index ca429785eb360b..255ddbaa7e7e3d 100644 --- a/src/app/util/chip-message-send.h +++ b/src/app/util/chip-message-send.h @@ -41,7 +41,7 @@ * @param[in] message The message to send after the APS frame. * @param[in] sendFlags The SendFlags needed, if any. */ -EmberStatus chipSendUnicast(chip::Messaging::ExchangeContext * exchange, EmberApsFrame * apsFrame, uint16_t messageLength, +EmberStatus chipSendUnicast(chip::Messaging::ExchangeHandle exchange, EmberApsFrame * apsFrame, uint16_t messageLength, uint8_t * message, chip::Messaging::SendFlags sendFlags = chip::Messaging::SendFlags()); /** diff --git a/src/app/util/client-api.cpp b/src/app/util/client-api.cpp index efae02ecec684a..800dd404206ef4 100644 --- a/src/app/util/client-api.cpp +++ b/src/app/util/client-api.cpp @@ -330,16 +330,15 @@ EmberStatus emberAfSendCommandMulticastToBindings(void) return emberAfSendMulticastToBindings(emAfCommandApsFrame, *emAfResponseLengthPtr, emAfZclBuffer); } -// EmberStatus emberAfSendCommandUnicastWithCallback(EmberOutgoingMessageType type, uint16_t indexOrDestination, -// EmberAfMessageSentFunction callback) +// EmberStatus emberAfSendCommandUnicastWithCallback(chip::MessageSendDestination & destination, EmberAfMessageSentFunction +// callback) // { -// return emberAfSendUnicastWithCallback(type, indexOrDestination, emAfCommandApsFrame, *emAfResponseLengthPtr, emAfZclBuffer, -// callback); +// return emberAfSendUnicastWithCallback(destination, emAfCommandApsFrame, *emAfResponseLengthPtr, emAfZclBuffer, callback); // } -// EmberStatus emberAfSendCommandUnicast(EmberOutgoingMessageType type, uint16_t indexOrDestination) +// EmberStatus emberAfSendCommandUnicast(chip::MessageSendDestination & destination) // { -// return emberAfSendCommandUnicastWithCallback(type, indexOrDestination, NULL); +// return emberAfSendCommandUnicastWithCallback(destination, NULL); // } // EmberStatus emberAfSendCommandBroadcastWithCallback(EmberNodeId destination, EmberAfMessageSentFunction callback) diff --git a/src/app/util/common.h b/src/app/util/common.h index 05cef174755586..146a5f0eb5d5d6 100644 --- a/src/app/util/common.h +++ b/src/app/util/common.h @@ -54,4 +54,4 @@ extern EmberApsFrame emberAfResponseApsFrame; extern uint8_t appResponseData[EMBER_AF_RESPONSE_BUFFER_LEN]; extern uint16_t appResponseLength; -extern chip::Messaging::ExchangeContext * emberAfResponseDestination; +extern chip::Messaging::ExchangeHandle emberAfResponseDestination; diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index f55c66fe0b5978..5b3ca085e1ca5c 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -41,12 +41,12 @@ Command * currentCommandObject; void SetupEmberAfObjects(Command * command, ClusterId clusterId, CommandId commandId, EndpointId endpointId) { - Messaging::ExchangeContext * commandExchangeCtx = command->GetExchangeContext(); + Messaging::ExchangeHandle commandExchangeCtx = command->GetExchangeContext(); imCompatibilityEmberApsFrame.clusterId = clusterId; imCompatibilityEmberApsFrame.destinationEndpoint = endpointId; imCompatibilityEmberApsFrame.sourceEndpoint = 1; // source endpoint is fixed to 1 for now. - imCompatibilityEmberApsFrame.sequence = (commandExchangeCtx != nullptr ? commandExchangeCtx->GetExchangeId() & 0xFF : 0); + imCompatibilityEmberApsFrame.sequence = (commandExchangeCtx.HasValue() ? commandExchangeCtx->GetExchangeId() & 0xFF : 0); imCompatibilityEmberAfCluster.commandId = commandId; imCompatibilityEmberAfCluster.apsFrame = &imCompatibilityEmberApsFrame; diff --git a/src/app/util/types_stub.h b/src/app/util/types_stub.h index 3446702bb84510..37382566ff6684 100644 --- a/src/app/util/types_stub.h +++ b/src/app/util/types_stub.h @@ -365,38 +365,6 @@ enum EMBER_INCOMING_BROADCAST_LOOPBACK }; -/** - * @brief Defines the possible outgoing message types. - */ -#ifdef DOXYGEN_SHOULD_SKIP_THIS -enum EmberOutgoingMessageType -#else -typedef uint8_t EmberOutgoingMessageType; -enum -#endif -{ - /** Unicast sent directly to an EmberNodeId. */ - EMBER_OUTGOING_DIRECT, - /** Unicast sent using an entry in the address table. */ - EMBER_OUTGOING_VIA_ADDRESS_TABLE, - /** Unicast sent using an entry in the binding table. */ - EMBER_OUTGOING_VIA_BINDING, - /** Multicast message. This value is passed to emberMessageSentHandler() only. - * It may not be passed to emberSendUnicast(). */ - EMBER_OUTGOING_MULTICAST, - /** An aliased multicast message. This value is passed to emberMessageSentHandler() only. - * It may not be passed to emberSendUnicast(). */ - EMBER_OUTGOING_MULTICAST_WITH_ALIAS, - /** An aliased Broadcast message. This value is passed to emberMessageSentHandler() only. - * It may not be passed to emberSendUnicast(). */ - EMBER_OUTGOING_BROADCAST_WITH_ALIAS, - /** A broadcast message. This value is passed to emberMessageSentHandler() only. - * It may not be passed to emberSendUnicast(). */ - EMBER_OUTGOING_BROADCAST, - /** A messaging going via some existing exchange. */ - EMBER_OUTGOING_VIA_EXCHANGE, -}; - /** @brief Endpoint information (a ZigBee Simple Descriptor). * * This is a ZigBee Simple Descriptor and contains information diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index ee3af8322b7fc6..356b9c6aa522df 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -493,7 +493,7 @@ static bool dispatchZclMessage(EmberAfClusterCommand * cmd) } bool emberAfProcessMessageIntoZclCmd(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, - uint16_t messageLength, Messaging::ExchangeContext * exchange, InterPanHeader * interPanHeader, + uint16_t messageLength, Messaging::ExchangeHandle exchange, InterPanHeader * interPanHeader, EmberAfClusterCommand * returnCmd) { uint8_t minLength = @@ -539,7 +539,7 @@ bool emberAfProcessMessageIntoZclCmd(EmberApsFrame * apsFrame, EmberIncomingMess // a single call to process global and cluster-specific messages and callbacks. bool emberAfProcessMessage(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, uint16_t msgLen, - Messaging::ExchangeContext * exchange, InterPanHeader * interPanHeader) + Messaging::ExchangeHandle exchange, InterPanHeader * interPanHeader) { bool msgHandled = false; // reset/reinitialize curCmd @@ -703,7 +703,7 @@ void emAfApplyDisableDefaultResponse(uint8_t * frame_control) } } -static bool isBroadcastDestination(Messaging::ExchangeContext * responseDestination) +static bool isBroadcastDestination(Messaging::ExchangeHandle responseDestination) { // TODO: Will need to actually figure out how to test for this! return false; @@ -755,7 +755,7 @@ EmberStatus emberAfSendResponseWithCallback(EmberAfMessageSentFunction callback) else if (!isBroadcastDestination(emberAfResponseDestination)) { label = 'U'; - status = emberAfSendUnicastWithCallback(EMBER_OUTGOING_VIA_EXCHANGE, MessageSendDestination(emberAfResponseDestination), + status = emberAfSendUnicastWithCallback(MessageSendDestination::ViaExchange(emberAfResponseDestination), &emberAfResponseApsFrame, appResponseLength, appResponseData, callback); } else diff --git a/src/app/util/util.h b/src/app/util/util.h index 20ab0f3cb081e8..422356cf561656 100644 --- a/src/app/util/util.h +++ b/src/app/util/util.h @@ -152,10 +152,10 @@ void emberAfDecodeAndPrintCluster(chip::ClusterId cluster); void emberAfDecodeAndPrintClusterWithMfgCode(chip::ClusterId cluster, uint16_t mfgCode); bool emberAfProcessMessage(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, uint16_t msgLen, - chip::Messaging::ExchangeContext * source, InterPanHeader * interPanHeader); + chip::Messaging::ExchangeHandle source, InterPanHeader * interPanHeader); bool emberAfProcessMessageIntoZclCmd(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, - uint16_t messageLength, chip::Messaging::ExchangeContext * source, + uint16_t messageLength, chip::Messaging::ExchangeHandle source, InterPanHeader * interPanHeader, EmberAfClusterCommand * returnCmd); /** diff --git a/src/app/zap-templates/templates/app/callback-stub-src.zapt b/src/app/zap-templates/templates/app/callback-stub-src.zapt index 6a8d6904270753..53589de00a6578 100644 --- a/src/app/zap-templates/templates/app/callback-stub-src.zapt +++ b/src/app/zap-templates/templates/app/callback-stub-src.zapt @@ -323,7 +323,7 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback( * @param status Ver.: always */ bool __attribute__((weak)) emberAfMessageSentCallback( - EmberOutgoingMessageType type, MessageSendDestination destination, + const MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status) { diff --git a/src/app/zap-templates/templates/app/callback.zapt b/src/app/zap-templates/templates/app/callback.zapt index 2bd1de9c3866be..391267d6d5821b 100644 --- a/src/app/zap-templates/templates/app/callback.zapt +++ b/src/app/zap-templates/templates/app/callback.zapt @@ -81,7 +81,7 @@ void emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}Manufac * @param message The message that was sent * @param status The status of the sent message */ -void emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}MessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}MessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief {{name}} Cluster {{asCamelCased side false}} Pre Attribute Changed * @@ -372,7 +372,7 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change diff --git a/src/channel/Channel.cpp b/src/channel/Channel.cpp index 151b10ab78ed74..7e7118a347c6d8 100644 --- a/src/channel/Channel.cpp +++ b/src/channel/Channel.cpp @@ -30,7 +30,7 @@ ChannelState ChannelHandle::GetState() const return mAssociation->mChannelContext->GetState(); } -ExchangeContext * ChannelHandle::NewExchange(ExchangeDelegate * delegate) +ExchangeHandle ChannelHandle::NewExchange(ExchangeDelegate * delegate) { assert(mAssociation != nullptr); return mAssociation->mChannelContext->NewExchange(delegate); diff --git a/src/channel/Channel.h b/src/channel/Channel.h index 2d6821ec1ef711..d311159575376c 100644 --- a/src/channel/Channel.h +++ b/src/channel/Channel.h @@ -45,6 +45,7 @@ #include #include +#include #include namespace chip { @@ -187,7 +188,7 @@ class ChannelHandle * * @pre GetState() == ChannelState::kReady */ - ExchangeContext * NewExchange(ExchangeDelegate * delegate); + ExchangeHandle NewExchange(ExchangeDelegate * delegate); void Release(); diff --git a/src/channel/ChannelContext.cpp b/src/channel/ChannelContext.cpp index 97798f604b72c7..33e5c98458bc09 100644 --- a/src/channel/ChannelContext.cpp +++ b/src/channel/ChannelContext.cpp @@ -35,7 +35,7 @@ void ChannelContext::Start(const ChannelBuilder & builder) EnterPreparingState(builder); } -ExchangeContext * ChannelContext::NewExchange(ExchangeDelegate * delegate) +ExchangeHandle ChannelContext::NewExchange(ExchangeDelegate * delegate) { assert(GetState() == ChannelState::kReady); return mExchangeManager->NewContext(GetReadyVars().mSession, delegate); @@ -258,8 +258,8 @@ void ChannelContext::EnterCasePairingState() auto & prepare = GetPrepareVars(); prepare.mCasePairingSession = Platform::New(); - ExchangeContext * ctxt = mExchangeManager->NewContext(SecureSessionHandle(), prepare.mCasePairingSession); - VerifyOrReturn(ctxt != nullptr); + ExchangeHandle ctxt = mExchangeManager->NewContext(SecureSessionHandle(), prepare.mCasePairingSession); + VerifyOrReturn(ctxt.HasValue()); // TODO: currently only supports IP/UDP paring Transport::PeerAddress addr; diff --git a/src/channel/ChannelContext.h b/src/channel/ChannelContext.h index 393c1cbad2c97a..d99aece95a27a9 100644 --- a/src/channel/ChannelContext.h +++ b/src/channel/ChannelContext.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -90,7 +91,7 @@ class ChannelContext : public ReferenceCounted gTransportMgr; class MockAppDelegate : public ExchangeDelegate { public: - void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && buffer) override { IsOnMessageReceivedCalled = true; } - void OnResponseTimeout(ExchangeContext * ec) override {} + void OnResponseTimeout(ExchangeHandle ec) override {} bool IsOnMessageReceivedCalled = false; }; @@ -118,7 +118,7 @@ void CheckExchangeChannels(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, channelHandle.GetState() == ChannelState::kReady); MockAppDelegate mockAppDelegate; - ExchangeContext * ec1 = channelHandle.NewExchange(&mockAppDelegate); + ExchangeHandle ec1 = channelHandle.NewExchange(&mockAppDelegate); // send a malicious packet ec1->SendMessage(0x0001, 0x0002, System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize)); diff --git a/src/controller/CHIPDevice.cpp b/src/controller/CHIPDevice.cpp index 41bd381dd6ca14..105bb47b939783 100644 --- a/src/controller/CHIPDevice.cpp +++ b/src/controller/CHIPDevice.cpp @@ -66,8 +66,8 @@ CHIP_ERROR Device::SendMessage(Protocols::Id protocolId, uint8_t msgType, System ReturnErrorOnFailure(LoadSecureSessionParametersIfNeeded(loadedSecureSession)); - Messaging::ExchangeContext * exchange = mExchangeMgr->NewContext(mSecureSession, nullptr); - VerifyOrReturnError(exchange != nullptr, CHIP_ERROR_NO_MEMORY); + Messaging::ExchangeHandle exchange = mExchangeMgr->NewContext(mSecureSession, nullptr); + VerifyOrReturnError(exchange.HasValue(), CHIP_ERROR_NO_MEMORY); if (!loadedSecureSession) { @@ -270,7 +270,7 @@ void Device::OnConnectionExpired(SecureSessionHandle session) mSecureSession = SecureSessionHandle{}; } -void Device::OnMessageReceived(Messaging::ExchangeContext * exchange, const PacketHeader & header, +void Device::OnMessageReceived(Messaging::ExchangeHandle exchange, const PacketHeader & header, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf) { if (mState == ConnectionState::SecureConnected) @@ -287,7 +287,7 @@ void Device::OnMessageReceived(Messaging::ExchangeContext * exchange, const Pack exchange->Close(); } -void Device::OnResponseTimeout(Messaging::ExchangeContext * ec) +void Device::OnResponseTimeout(Messaging::ExchangeHandle ec) { ec->Close(); } @@ -403,8 +403,8 @@ bool Device::GetAddress(Inet::IPAddress & addr, uint16_t & port) const CHIP_ERROR Device::EstablishCASESession() { - Messaging::ExchangeContext * exchange = mExchangeMgr->NewContext(SecureSessionHandle(), &mCASESession); - VerifyOrReturnError(exchange != nullptr, CHIP_ERROR_INTERNAL); + Messaging::ExchangeHandle exchange = mExchangeMgr->NewContext(SecureSessionHandle(), &mCASESession); + VerifyOrReturnError(exchange.HasValue(), CHIP_ERROR_INTERNAL); ReturnErrorOnFailure(mCASESession.MessageDispatch().Init(mSessionManager->GetTransportManager())); mCASESession.MessageDispatch().SetPeerAddress(mDeviceAddress); diff --git a/src/controller/CHIPDevice.h b/src/controller/CHIPDevice.h index 41b54d8d5f1868..aaf64117bcee46 100644 --- a/src/controller/CHIPDevice.h +++ b/src/controller/CHIPDevice.h @@ -258,13 +258,13 @@ class DLL_EXPORT Device : public Messaging::ExchangeDelegate, public SessionEsta * @param[in] payloadHeader Reference to payload header in the message * @param[in] msgBuf The message buffer */ - void OnMessageReceived(Messaging::ExchangeContext * exchange, const PacketHeader & header, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle exchange, const PacketHeader & header, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf) override; /** * @brief ExchangeDelegate implementation of OnResponseTimeout. */ - void OnResponseTimeout(Messaging::ExchangeContext * exchange) override; + void OnResponseTimeout(Messaging::ExchangeHandle exchange) override; /** * @brief diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 07a84217c3504b..79d1dfbf6e6ef4 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -525,7 +525,7 @@ CHIP_ERROR DeviceController::ServiceEventSignal() return CHIP_NO_ERROR; } -void DeviceController::OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, +void DeviceController::OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf) { uint16_t index; @@ -549,9 +549,9 @@ void DeviceController::OnMessageReceived(Messaging::ExchangeContext * ec, const } } -void DeviceController::OnResponseTimeout(Messaging::ExchangeContext * ec) +void DeviceController::OnResponseTimeout(Messaging::ExchangeHandle ec) { - ChipLogProgress(Controller, "Time out! failed to receive response from Exchange: %p", ec); + ChipLogProgress(Controller, "Time out! failed to receive response from Exchange: %d", ec->GetExchangeId()); } void DeviceController::OnNewConnection(SecureSessionHandle session, Messaging::ExchangeManager * mgr) @@ -829,7 +829,7 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam Device * device = nullptr; Transport::PeerAddress peerAddress = Transport::PeerAddress::UDP(Inet::IPAddress::Any); - Messaging::ExchangeContext * exchangeCtxt = nullptr; + Messaging::ExchangeHandle exchangeCtxt; Transport::AdminPairingInfo * admin = mAdmins.FindAdminWithId(mAdminId); @@ -897,7 +897,7 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam } #endif exchangeCtxt = mExchangeMgr->NewContext(SecureSessionHandle(), &mPairingSession); - VerifyOrExit(exchangeCtxt != nullptr, err = CHIP_ERROR_INTERNAL); + VerifyOrExit(exchangeCtxt.HasValue(), err = CHIP_ERROR_INTERNAL); err = mPairingSession.Pair(params.GetPeerAddress(), params.GetSetupPINCode(), mNextKeyId++, exchangeCtxt, this); // Immediately persist the updted mNextKeyID value diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 55dc13371fcd10..7617a2fd5577b6 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -290,9 +290,9 @@ class DLL_EXPORT DeviceController : public Messaging::ExchangeDelegate, private: //////////// ExchangeDelegate Implementation /////////////// - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf) override; - void OnResponseTimeout(Messaging::ExchangeContext * ec) override; + void OnResponseTimeout(Messaging::ExchangeHandle ec) override; //////////// ExchangeMgrDelegate Implementation /////////////// void OnNewConnection(SecureSessionHandle session, Messaging::ExchangeManager * mgr) override; diff --git a/src/controller/data_model/gen/callback-stub.cpp b/src/controller/data_model/gen/callback-stub.cpp index 58d58c62d107d3..f0b671d386930d 100644 --- a/src/controller/data_model/gen/callback-stub.cpp +++ b/src/controller/data_model/gen/callback-stub.cpp @@ -630,9 +630,8 @@ bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * * @param message Ver.: always * @param status Ver.: always */ -bool __attribute__((weak)) -emberAfMessageSentCallback(EmberOutgoingMessageType type, 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; } diff --git a/src/controller/data_model/gen/callback.h b/src/controller/data_model/gen/callback.h index bf6b91512cdd0e..666739020ee04c 100644 --- a/src/controller/data_model/gen/callback.h +++ b/src/controller/data_model/gen/callback.h @@ -398,9 +398,8 @@ void emberAfAccountLoginClusterClientManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfAccountLoginClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfAccountLoginClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Account Login Cluster Client Pre Attribute Changed * @@ -468,9 +467,9 @@ void emberAfApplicationBasicClusterClientManufacturerSpecificAttributeChangedCal * @param message The message that was sent * @param status The status of the sent message */ -void emberAfApplicationBasicClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfApplicationBasicClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Application Basic Cluster Client Pre Attribute Changed * @@ -539,9 +538,9 @@ void emberAfApplicationLauncherClusterClientManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfApplicationLauncherClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfApplicationLauncherClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Application Launcher Cluster Client Pre Attribute Changed * @@ -610,9 +609,8 @@ void emberAfAudioOutputClusterClientManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfAudioOutputClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfAudioOutputClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Audio Output Cluster Client Pre Attribute Changed * @@ -680,7 +678,7 @@ void emberAfBarrierControlClusterClientManufacturerSpecificAttributeChangedCallb * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBarrierControlClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfBarrierControlClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -750,8 +748,8 @@ void emberAfBasicClusterClientManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBasicClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBasicClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Basic Cluster Client Pre Attribute Changed * @@ -819,9 +817,8 @@ void emberAfBindingClusterClientManufacturerSpecificAttributeChangedCallback(chi * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBindingClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfBindingClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Binding Cluster Client Pre Attribute Changed * @@ -889,9 +886,9 @@ void emberAfBridgedDeviceBasicClusterClientManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfBridgedDeviceBasicClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfBridgedDeviceBasicClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Bridged Device Basic Cluster Client Pre Attribute Changed * @@ -960,9 +957,8 @@ void emberAfColorControlClusterClientManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfColorControlClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfColorControlClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Color Control Cluster Client Pre Attribute Changed * @@ -1030,7 +1026,7 @@ void emberAfContentLaunchClusterClientManufacturerSpecificAttributeChangedCallba * @param message The message that was sent * @param status The status of the sent message */ -void emberAfContentLaunchClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfContentLaunchClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1100,9 +1096,8 @@ void emberAfDescriptorClusterClientManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfDescriptorClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfDescriptorClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Descriptor Cluster Client Pre Attribute Changed * @@ -1170,9 +1165,8 @@ void emberAfDoorLockClusterClientManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfDoorLockClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfDoorLockClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Door Lock Cluster Client Pre Attribute Changed * @@ -1241,8 +1235,7 @@ void emberAfEthernetNetworkDiagnosticsClusterClientManufacturerSpecificAttribute * @param message The message that was sent * @param status The status of the sent message */ -void emberAfEthernetNetworkDiagnosticsClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfEthernetNetworkDiagnosticsClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -1313,9 +1306,8 @@ void emberAfFixedLabelClusterClientManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfFixedLabelClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfFixedLabelClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Fixed Label Cluster Client Pre Attribute Changed * @@ -1383,9 +1375,9 @@ void emberAfGeneralCommissioningClusterClientManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralCommissioningClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralCommissioningClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Commissioning Cluster Client Pre Attribute Changed * @@ -1454,9 +1446,9 @@ void emberAfGeneralDiagnosticsClusterClientManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGeneralDiagnosticsClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGeneralDiagnosticsClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief General Diagnostics Cluster Client Pre Attribute Changed * @@ -1525,9 +1517,9 @@ void emberAfGroupKeyManagementClusterClientManufacturerSpecificAttributeChangedC * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGroupKeyManagementClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfGroupKeyManagementClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Group Key Management Cluster Client Pre Attribute Changed * @@ -1596,9 +1588,8 @@ void emberAfGroupsClusterClientManufacturerSpecificAttributeChangedCallback(chip * @param message The message that was sent * @param status The status of the sent message */ -void emberAfGroupsClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfGroupsClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Groups Cluster Client Pre Attribute Changed * @@ -1666,9 +1657,8 @@ void emberAfIdentifyClusterClientManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfIdentifyClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfIdentifyClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Identify Cluster Client Pre Attribute Changed * @@ -1736,9 +1726,8 @@ void emberAfKeypadInputClusterClientManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfKeypadInputClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfKeypadInputClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Keypad Input Cluster Client Pre Attribute Changed * @@ -1806,9 +1795,8 @@ void emberAfLevelControlClusterClientManufacturerSpecificAttributeChangedCallbac * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLevelControlClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLevelControlClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Level Control Cluster Client Pre Attribute Changed * @@ -1876,9 +1864,8 @@ void emberAfLowPowerClusterClientManufacturerSpecificAttributeChangedCallback(ch * @param message The message that was sent * @param status The status of the sent message */ -void emberAfLowPowerClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfLowPowerClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Low Power Cluster Client Pre Attribute Changed * @@ -1946,9 +1933,8 @@ void emberAfMediaInputClusterClientManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfMediaInputClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfMediaInputClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Media Input Cluster Client Pre Attribute Changed * @@ -2016,7 +2002,7 @@ void emberAfMediaPlaybackClusterClientManufacturerSpecificAttributeChangedCallba * @param message The message that was sent * @param status The status of the sent message */ -void emberAfMediaPlaybackClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfMediaPlaybackClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2086,9 +2072,9 @@ void emberAfNetworkCommissioningClusterClientManufacturerSpecificAttributeChange * @param message The message that was sent * @param status The status of the sent message */ -void emberAfNetworkCommissioningClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfNetworkCommissioningClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Network Commissioning Cluster Client Pre Attribute Changed * @@ -2156,8 +2142,8 @@ void emberAfOnOffClusterClientManufacturerSpecificAttributeChangedCallback(chip: * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOnOffClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfOnOffClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief On/off Cluster Client Pre Attribute Changed * @@ -2225,8 +2211,7 @@ void emberAfOperationalCredentialsClusterClientManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfOperationalCredentialsClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfOperationalCredentialsClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2298,8 +2283,7 @@ void emberAfPumpConfigurationAndControlClusterClientManufacturerSpecificAttribut * @param message The message that was sent * @param status The status of the sent message */ -void emberAfPumpConfigurationAndControlClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfPumpConfigurationAndControlClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2370,9 +2354,8 @@ void emberAfScenesClusterClientManufacturerSpecificAttributeChangedCallback(chip * @param message The message that was sent * @param status The status of the sent message */ -void emberAfScenesClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfScenesClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Scenes Cluster Client Pre Attribute Changed * @@ -2440,9 +2423,9 @@ void emberAfSoftwareDiagnosticsClusterClientManufacturerSpecificAttributeChanged * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSoftwareDiagnosticsClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +void emberAfSoftwareDiagnosticsClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); /** @brief Software Diagnostics Cluster Client Pre Attribute Changed * @@ -2511,9 +2494,8 @@ void emberAfSwitchClusterClientManufacturerSpecificAttributeChangedCallback(chip * @param message The message that was sent * @param status The status of the sent message */ -void emberAfSwitchClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfSwitchClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Switch Cluster Client Pre Attribute Changed * @@ -2581,9 +2563,8 @@ void emberAfTvChannelClusterClientManufacturerSpecificAttributeChangedCallback(c * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTvChannelClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfTvChannelClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief TV Channel Cluster Client Pre Attribute Changed * @@ -2651,7 +2632,7 @@ void emberAfTargetNavigatorClusterClientManufacturerSpecificAttributeChangedCall * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTargetNavigatorClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfTargetNavigatorClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2722,8 +2703,7 @@ void emberAfTemperatureMeasurementClusterClientManufacturerSpecificAttributeChan * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTemperatureMeasurementClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTemperatureMeasurementClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -2794,9 +2774,8 @@ void emberAfTestClusterClusterClientManufacturerSpecificAttributeChangedCallback * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTestClusterClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfTestClusterClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Test Cluster Cluster Client Pre Attribute Changed * @@ -2864,9 +2843,8 @@ void emberAfThermostatClusterClientManufacturerSpecificAttributeChangedCallback( * @param message The message that was sent * @param status The status of the sent message */ -void emberAfThermostatClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfThermostatClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Thermostat Cluster Client Pre Attribute Changed * @@ -2934,8 +2912,7 @@ void emberAfTrustedRootCertificatesClusterClientManufacturerSpecificAttributeCha * @param message The message that was sent * @param status The status of the sent message */ -void emberAfTrustedRootCertificatesClusterClientMessageSentCallback(EmberOutgoingMessageType type, - chip::MessageSendDestination destination, +void emberAfTrustedRootCertificatesClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3006,9 +2983,8 @@ void emberAfWakeOnLanClusterClientManufacturerSpecificAttributeChangedCallback(c * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWakeOnLanClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, - EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, - EmberStatus status); +void emberAfWakeOnLanClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status); /** @brief Wake on LAN Cluster Client Pre Attribute Changed * @@ -3076,7 +3052,7 @@ void emberAfWindowCoveringClusterClientManufacturerSpecificAttributeChangedCallb * @param message The message that was sent * @param status The status of the sent message */ -void emberAfWindowCoveringClusterClientMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, +void emberAfWindowCoveringClusterClientMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); @@ -3793,8 +3769,8 @@ bool emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberSt * @param message Ver.: always * @param status Ver.: always */ -bool emberAfMessageSentCallback(EmberOutgoingMessageType type, chip::MessageSendDestination destination, EmberApsFrame * apsFrame, - uint16_t msgLen, uint8_t * message, EmberStatus status); +bool emberAfMessageSentCallback(const chip::MessageSendDestination & destination, EmberApsFrame * apsFrame, uint16_t msgLen, + uint8_t * message, EmberStatus status); /** @brief Pre Attribute Change * diff --git a/src/lib/support/Variant.h b/src/lib/support/Variant.h index 168840ea49c17d..c6003b039232a9 100644 --- a/src/lib/support/Variant.h +++ b/src/lib/support/Variant.h @@ -70,6 +70,15 @@ struct VariantCurry<> inline static void Copy(std::size_t that_t, const void * that_v, void * this_v) {} }; +// Using assert inside template will encoded template name into the assert +// error message, which cost lots of flash space, this function can strip the +// type name, and the function name should be as short as possible to save +// space. +inline void AssertStrip(bool exp) +{ + assert(exp); +} + } // namespace Internal /** @@ -96,8 +105,8 @@ template struct Variant { private: - static constexpr std::size_t kDataSize = std::max(sizeof(Ts)...); - static constexpr std::size_t kDataAlign = std::max(alignof(Ts)...); + static constexpr std::size_t kDataSize = std::max({ sizeof(Ts)... }); + static constexpr std::size_t kDataAlign = std::max({ alignof(Ts)... }); static constexpr std::size_t kInvalidType = SIZE_MAX; using Data = typename std::aligned_storage::type; @@ -118,7 +127,7 @@ struct Variant that.mTypeId = kInvalidType; } - Variant & operator=(Variant & that) + Variant & operator=(const Variant & that) { Curry::Destroy(mTypeId, &mData); mTypeId = that.mTypeId; @@ -137,12 +146,14 @@ struct Variant } template - bool Is() + bool Is() const { return (mTypeId == T::VariantId); } - bool Valid() { return (mTypeId != kInvalidType); } + std::size_t GetType() const { return mTypeId; } + + bool Valid() const { return (mTypeId != kInvalidType); } template void Set(Args &&... args) @@ -155,29 +166,15 @@ struct Variant template T & Get() { - if (mTypeId == T::VariantId) - { - return *reinterpret_cast(&mData); - } - else - { - assert(false); - return *static_cast(nullptr); - } + Internal::AssertStrip(mTypeId == T::VariantId); + return *reinterpret_cast(&mData); } template const T & Get() const { - if (mTypeId == T::VariantId) - { - return *reinterpret_cast(&mData); - } - else - { - assert(false); - return *static_cast(nullptr); - } + Internal::AssertStrip(mTypeId == T::VariantId); + return *reinterpret_cast(&mData); } ~Variant() { Curry::Destroy(mTypeId, &mData); } diff --git a/src/messaging/BUILD.gn b/src/messaging/BUILD.gn index 76966ef817eb4b..e12ec2a7e6a99b 100644 --- a/src/messaging/BUILD.gn +++ b/src/messaging/BUILD.gn @@ -26,6 +26,8 @@ static_library("messaging") { "ExchangeContext.cpp", "ExchangeContext.h", "ExchangeDelegate.h", + "ExchangeHandle.cpp", + "ExchangeHandle.h", "ExchangeMessageDispatch.cpp", "ExchangeMessageDispatch.h", "ExchangeMgr.cpp", diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index 6dd1bf49db73b6..a517bcb87d8d3a 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -49,7 +49,7 @@ using namespace chip::System; namespace chip { namespace Messaging { -static void DefaultOnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, Protocols::Id protocolId, +static void DefaultOnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, Protocols::Id protocolId, uint8_t msgType, PacketBufferHandle && payload) { ChipLogError(ExchangeManager, "Dropping unexpected message %08" PRIX32 ":%d %04" PRIX16 " MsgId:%08" PRIX32, @@ -87,10 +87,7 @@ CHIP_ERROR ExchangeContext::SendMessage(Protocols::Id protocolId, uint8_t msgTyp // Don't let method get called on a freed object. VerifyOrDie(mExchangeMgr != nullptr && GetReferenceCount() > 0); - // we hold the exchange context here in case the entity that - // originally generated it tries to close it as a result of - // an error arising below. at the end, we have to close it. - Retain(); + ExchangeHandle ec(this); bool reliableTransmissionRequested = true; @@ -121,7 +118,7 @@ CHIP_ERROR ExchangeContext::SendMessage(Protocols::Id protocolId, uint8_t msgTyp } } - err = mDispatch->SendMessage(mSecureSession, mExchangeId, IsInitiator(), GetReliableMessageContext(), + err = mDispatch->SendMessage(mSecureSession, mExchangeId, IsInitiator(), ExchangeHandle(this), reliableTransmissionRequested, protocolId, msgType, std::move(msgBuf)); exit: @@ -131,13 +128,6 @@ CHIP_ERROR ExchangeContext::SendMessage(Protocols::Id protocolId, uint8_t msgTyp SetResponseExpected(false); } - // Release the reference to the exchange context acquired above. Under normal circumstances - // this will merely decrement the reference count, without actually freeing the exchange context. - // However if one of the function calls in this method resulted in a callback to the protocol, - // the protocol may have released its reference, resulting in the exchange context actually - // being freed here. - Release(); - return err; } @@ -160,7 +150,7 @@ void ExchangeContext::DoClose(bool clearRetransTable) // needs to clear the CRMP retransmission table immediately. if (clearRetransTable) { - mExchangeMgr->GetReliableMessageMgr()->ClearRetransTable(static_cast(this)); + mExchangeMgr->GetReliableMessageMgr()->ClearRetransTable(ExchangeHandle(this)); } // Cancel the response timer. @@ -183,7 +173,6 @@ void ExchangeContext::Close() #endif DoClose(false); - Release(); } /** * Abort the Exchange context immediately and release all @@ -200,7 +189,6 @@ void ExchangeContext::Abort() #endif DoClose(true); - Release(); } void ExchangeContextDeletor::Release(ExchangeContext * ec) @@ -326,10 +314,9 @@ void ExchangeContext::CancelResponseTimer() void ExchangeContext::HandleResponseTimeout(System::Layer * aSystemLayer, void * aAppState, System::Error aError) { - ExchangeContext * ec = reinterpret_cast(aAppState); + if (aAppState == nullptr) return; - if (ec == nullptr) - return; + ExchangeHandle ec(reinterpret_cast(aAppState)); // NOTE: we don't set mResponseExpected to false here because the response could still arrive. If the user // wants to never receive the response, they must close the exchange context. @@ -348,10 +335,10 @@ CHIP_ERROR ExchangeContext::HandleMessage(const PacketHeader & packetHeader, con // guard against Close() calls(decrementing the reference // count) by the protocol before the CHIP Exchange // layer has completed its work on the ExchangeContext. - Retain(); + ExchangeHandle ec(this); CHIP_ERROR err = - mDispatch->OnMessageReceived(payloadHeader, packetHeader.GetMessageId(), peerAddress, GetReliableMessageContext()); + mDispatch->OnMessageReceived(payloadHeader, packetHeader.GetMessageId(), peerAddress, ExchangeHandle(this)); SuccessOrExit(err); // The SecureChannel::StandaloneAck message type is only used for CRMP; do not pass such messages to the application layer. @@ -369,20 +356,15 @@ CHIP_ERROR ExchangeContext::HandleMessage(const PacketHeader & packetHeader, con if (mDelegate != nullptr) { - mDelegate->OnMessageReceived(this, packetHeader, payloadHeader, std::move(msgBuf)); + mDelegate->OnMessageReceived(ExchangeHandle(this), packetHeader, payloadHeader, std::move(msgBuf)); } else { - DefaultOnMessageReceived(this, packetHeader, payloadHeader.GetProtocolID(), payloadHeader.GetMessageType(), + DefaultOnMessageReceived(ExchangeHandle(this), packetHeader, payloadHeader.GetProtocolID(), payloadHeader.GetMessageType(), std::move(msgBuf)); } exit: - // Release the reference to the ExchangeContext that was held at the beginning of this function. - // This call should also do the needful of closing the ExchangeContext if the protocol has - // already made a prior call to Close(). - Release(); - return err; } diff --git a/src/messaging/ExchangeContext.h b/src/messaging/ExchangeContext.h index c2aa6ea944b62a..79769ac76446d7 100644 --- a/src/messaging/ExchangeContext.h +++ b/src/messaging/ExchangeContext.h @@ -54,7 +54,7 @@ class ExchangeContextDeletor * It defines methods for encoding and communicating CHIP messages within an ExchangeContext * over various transport mechanisms, for example, TCP, UDP, or CHIP Reliable Messaging. */ -class DLL_EXPORT ExchangeContext : public ReliableMessageContext, public ReferenceCounted +class DLL_EXPORT ExchangeContext : public ReliableMessageContext, public ReferenceCounted { friend class ExchangeManager; friend class ExchangeContextDeletor; @@ -133,7 +133,7 @@ class DLL_EXPORT ExchangeContext : public ReliableMessageContext, public Referen ExchangeManager * GetExchangeMgr() const { return mExchangeMgr; } - ReliableMessageContext * GetReliableMessageContext() { return static_cast(this); }; + ReliableMessageContext & GetReliableMessageContext() { return *static_cast(this); }; ExchangeMessageDispatch * GetMessageDispatch() { return mDispatch; } @@ -155,11 +155,6 @@ class DLL_EXPORT ExchangeContext : public ReliableMessageContext, public Referen uint16_t GetExchangeId() const { return mExchangeId; } - /* - * In order to use reference counting (see refCount below) we use a hold/free paradigm where users of the exchange - * can hold onto it while it's out of their direct control to make sure it isn't closed before everyone's ready. - * A customized version of reference counting is used since there are some extra stuff to do within Release. - */ void Close(); void Abort(); diff --git a/src/messaging/ExchangeDelegate.h b/src/messaging/ExchangeDelegate.h index 7656e83c460de1..a10b930cf12d9d 100644 --- a/src/messaging/ExchangeDelegate.h +++ b/src/messaging/ExchangeDelegate.h @@ -24,6 +24,7 @@ #pragma once #include +#include #include #include #include @@ -56,7 +57,7 @@ class DLL_EXPORT ExchangeDelegate * @param[in] payloadHeader A reference to the PayloadHeader object. * @param[in] payload A handle to the PacketBuffer object holding the message payload. */ - virtual void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + virtual void OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) = 0; /** @@ -66,7 +67,7 @@ class DLL_EXPORT ExchangeDelegate * * @param[in] ec A pointer to the ExchangeContext object. */ - virtual void OnResponseTimeout(ExchangeContext * ec) = 0; + virtual void OnResponseTimeout(ExchangeHandle ec) = 0; /** * @brief diff --git a/src/messaging/ExchangeHandle.cpp b/src/messaging/ExchangeHandle.cpp new file mode 100644 index 00000000000000..c8334206108aff --- /dev/null +++ b/src/messaging/ExchangeHandle.cpp @@ -0,0 +1,58 @@ +/* + * + * 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. + */ + +#include + +#include + +namespace chip { +namespace Messaging { + +ExchangeHandle::ExchangeHandle(ExchangeContext * context) : mContext(context) +{ + if (mContext != nullptr) mContext->Retain(); +} + +ExchangeHandle::ExchangeHandle(const ExchangeHandle & that) : mContext(that.mContext) +{ + if (mContext != nullptr) mContext->Retain(); +} + +ExchangeHandle::~ExchangeHandle() +{ + if (mContext != nullptr) mContext->Release(); +} + +ExchangeHandle & ExchangeHandle::operator=(const ExchangeHandle & that) +{ + if (this == &that) return *this; + mContext = that.mContext; + if (mContext != nullptr) mContext->Retain(); + return *this; +} + +void ExchangeHandle::Release() +{ + if (mContext != nullptr) + { + mContext->Release(); + mContext = nullptr; + } +} + +} // namespace Messaging +} // namespace chip diff --git a/src/messaging/ExchangeHandle.h b/src/messaging/ExchangeHandle.h new file mode 100644 index 00000000000000..768f42f416d1a3 --- /dev/null +++ b/src/messaging/ExchangeHandle.h @@ -0,0 +1,62 @@ +/* + * + * Copyright (c) 2020-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. + */ + +#pragma once + +namespace chip { + +namespace Messaging { + +class ExchangeContext; + +/** + * ExchangeHandle acts like a unique_ptr to an ExchangeContext, to help managing the life cycle of the ExchangeContext + */ +class ExchangeHandle +{ +public: + explicit ExchangeHandle() : mContext(nullptr) {} + ~ExchangeHandle(); + + ExchangeHandle(const ExchangeHandle & that); + ExchangeHandle(ExchangeHandle && that) : mContext(that.mContext) { that.mContext = nullptr; } + + ExchangeHandle & operator=(const ExchangeHandle & that); + ExchangeHandle & operator=(ExchangeHandle && that) + { + if (this == &that) return *this; + mContext = that.mContext; + that.mContext = nullptr; + return *this; + } + + bool HasValue() const { return mContext != nullptr; } + void Release(); + + ExchangeContext * operator->() const { return mContext; } + bool operator==(const ExchangeHandle & that) const { return mContext == that.mContext; } + bool operator!=(const ExchangeHandle & that) const { return !(*this == that); } +private: + friend class ExchangeContext; + friend class ExchangeManager; + explicit ExchangeHandle(ExchangeContext * context); + ExchangeContext * mContext; +}; + +} // namespace Messaging +} // namespace chip + diff --git a/src/messaging/ExchangeMessageDispatch.cpp b/src/messaging/ExchangeMessageDispatch.cpp index c998ef6968864e..7d2c95f1b430d9 100644 --- a/src/messaging/ExchangeMessageDispatch.cpp +++ b/src/messaging/ExchangeMessageDispatch.cpp @@ -40,32 +40,33 @@ namespace chip { namespace Messaging { CHIP_ERROR ExchangeMessageDispatch::SendMessage(SecureSessionHandle session, uint16_t exchangeId, bool isInitiator, - ReliableMessageContext * reliableMessageContext, bool isReliableTransmission, + ExchangeHandle exchangeContext, bool isReliableTransmission, Protocols::Id protocol, uint8_t type, System::PacketBufferHandle && message) { + ReliableMessageContext & reliableMessageContext = exchangeContext->GetReliableMessageContext(); ReturnErrorCodeIf(!MessagePermitted(protocol.GetProtocolId(), type), CHIP_ERROR_INVALID_ARGUMENT); PayloadHeader payloadHeader; payloadHeader.SetExchangeID(exchangeId).SetMessageType(protocol, type).SetInitiator(isInitiator); // If there is a pending acknowledgment piggyback it on this message. - if (reliableMessageContext->HasPeerRequestedAck()) + if (reliableMessageContext.HasPeerRequestedAck()) { - payloadHeader.SetAckId(reliableMessageContext->GetPendingPeerAckId()); + payloadHeader.SetAckId(reliableMessageContext.GetPendingPeerAckId()); // Set AckPending flag to false since current outgoing message is going to serve as the ack on this exchange. - reliableMessageContext->SetAckPending(false); + reliableMessageContext.SetAckPending(false); #if !defined(NDEBUG) if (!payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::StandaloneAck)) { ChipLogDetail(ExchangeManager, "Piggybacking Ack for MsgId:%08" PRIX32 " with msg", - reliableMessageContext->GetPendingPeerAckId()); + reliableMessageContext.GetPendingPeerAckId()); } #endif } - if (IsReliableTransmissionAllowed() && reliableMessageContext->AutoRequestAck() && mReliableMessageMgr != nullptr && + if (IsReliableTransmissionAllowed() && reliableMessageContext.AutoRequestAck() && mReliableMessageMgr != nullptr && isReliableTransmission) { payloadHeader.SetNeedsAck(true); @@ -73,7 +74,7 @@ CHIP_ERROR ExchangeMessageDispatch::SendMessage(SecureSessionHandle session, uin ReliableMessageMgr::RetransTableEntry * entry = nullptr; // Add to Table for subsequent sending - ReturnErrorOnFailure(mReliableMessageMgr->AddToRetransTable(reliableMessageContext, &entry)); + ReturnErrorOnFailure(mReliableMessageMgr->AddToRetransTable(exchangeContext, &entry)); CHIP_ERROR err = SendMessageImpl(session, payloadHeader, std::move(message), &entry->retainedBuf); if (err != CHIP_NO_ERROR) @@ -85,6 +86,7 @@ CHIP_ERROR ExchangeMessageDispatch::SendMessage(SecureSessionHandle session, uin } else { + VerifyOrDie(!entry->retainedBuf.IsNull()); mReliableMessageMgr->StartRetransmision(entry); } } @@ -100,16 +102,17 @@ CHIP_ERROR ExchangeMessageDispatch::SendMessage(SecureSessionHandle session, uin CHIP_ERROR ExchangeMessageDispatch::OnMessageReceived(const PayloadHeader & payloadHeader, uint32_t messageId, const Transport::PeerAddress & peerAddress, - ReliableMessageContext * reliableMessageContext) + ExchangeHandle exchangeContext) { ReturnErrorCodeIf(!MessagePermitted(payloadHeader.GetProtocolID().GetProtocolId(), payloadHeader.GetMessageType()), CHIP_ERROR_INVALID_ARGUMENT); + ReliableMessageContext & reliableMessageContext = exchangeContext->GetReliableMessageContext(); if (IsReliableTransmissionAllowed()) { if (payloadHeader.IsAckMsg() && payloadHeader.GetAckId().HasValue()) { - ReturnErrorOnFailure(reliableMessageContext->HandleRcvdAck(payloadHeader.GetAckId().Value())); + ReturnErrorOnFailure(reliableMessageContext.HandleRcvdAck(exchangeContext, payloadHeader.GetAckId().Value())); } if (payloadHeader.NeedsAck()) @@ -121,9 +124,9 @@ CHIP_ERROR ExchangeMessageDispatch::OnMessageReceived(const PayloadHeader & payl msgFlags.Set(MessageFlagValues::kPeerRequestedAck); // Also set the flag in the exchange context indicating an ack requested; - reliableMessageContext->SetPeerRequestedAck(true); + reliableMessageContext.SetPeerRequestedAck(true); - ReturnErrorOnFailure(reliableMessageContext->HandleNeedsAck(messageId, msgFlags)); + ReturnErrorOnFailure(reliableMessageContext.HandleNeedsAck(exchangeContext, messageId, msgFlags)); } } diff --git a/src/messaging/ExchangeMessageDispatch.h b/src/messaging/ExchangeMessageDispatch.h index 57179710d84017..731d3e24ab11b8 100644 --- a/src/messaging/ExchangeMessageDispatch.h +++ b/src/messaging/ExchangeMessageDispatch.h @@ -25,6 +25,7 @@ #include #include +#include namespace chip { namespace Messaging { @@ -45,7 +46,7 @@ class ExchangeMessageDispatch : public ReferenceCounted } CHIP_ERROR SendMessage(SecureSessionHandle session, uint16_t exchangeId, bool isInitiator, - ReliableMessageContext * reliableMessageContext, bool isReliableTransmission, Protocols::Id protocol, + ExchangeHandle exchangeContext, bool isReliableTransmission, Protocols::Id protocol, uint8_t type, System::PacketBufferHandle && message); virtual CHIP_ERROR ResendMessage(SecureSessionHandle session, EncryptedPacketBufferHandle && message, @@ -56,7 +57,7 @@ class ExchangeMessageDispatch : public ReferenceCounted virtual CHIP_ERROR OnMessageReceived(const PayloadHeader & payloadHeader, uint32_t messageId, const Transport::PeerAddress & peerAddress, - ReliableMessageContext * reliableMessageContext); + ExchangeHandle exchangeContext); protected: virtual bool MessagePermitted(uint16_t protocol, uint8_t type) = 0; diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp index 1215751347af48..441df5591f3278 100644 --- a/src/messaging/ExchangeMgr.cpp +++ b/src/messaging/ExchangeMgr.cpp @@ -114,9 +114,9 @@ CHIP_ERROR ExchangeManager::Shutdown() return CHIP_NO_ERROR; } -ExchangeContext * ExchangeManager::NewContext(SecureSessionHandle session, ExchangeDelegate * delegate) +ExchangeHandle ExchangeManager::NewContext(SecureSessionHandle session, ExchangeDelegate * delegate) { - return mContextPool.CreateObject(this, mNextExchangeId++, session, true, delegate); + return ExchangeHandle(mContextPool.CreateObject(this, mNextExchangeId++, session, true, delegate)); } CHIP_ERROR ExchangeManager::RegisterUnsolicitedMessageHandlerForProtocol(Protocols::Id protocolId, ExchangeDelegate * delegate) @@ -264,21 +264,14 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const // If we found a handler or we need to create a new exchange context (EC). if (matchingUMH != nullptr || sendAckAndCloseExchange) { - ExchangeContext * ec = nullptr; - - if (sendAckAndCloseExchange) - { // If rcvd msg is from initiator then this exchange is created as not Initiator. // If rcvd msg is not from initiator then this exchange is created as Initiator. // TODO: Figure out which channel to use for the received message - ec = mContextPool.CreateObject(this, payloadHeader.GetExchangeID(), session, !payloadHeader.IsInitiator(), nullptr); - } - else - { - ec = mContextPool.CreateObject(this, payloadHeader.GetExchangeID(), session, false, matchingUMH->Delegate); - } + ExchangeHandle ec(mContextPool.CreateObject(this, payloadHeader.GetExchangeID(), session, + sendAckAndCloseExchange && !payloadHeader.IsInitiator(), + sendAckAndCloseExchange ? nullptr : matchingUMH->Delegate)); - VerifyOrExit(ec != nullptr, err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(ec.HasValue(), err = CHIP_ERROR_NO_MEMORY); ChipLogDetail(ExchangeManager, "ec id: %d, Delegate: 0x%x", ec->GetExchangeId(), ec->GetDelegate()); diff --git a/src/messaging/ExchangeMgr.h b/src/messaging/ExchangeMgr.h index 25ede5e4901836..b71b516d10b722 100644 --- a/src/messaging/ExchangeMgr.h +++ b/src/messaging/ExchangeMgr.h @@ -99,7 +99,7 @@ class DLL_EXPORT ExchangeManager : public SecureSessionMgrDelegate, public Trans * @return A pointer to the created ExchangeContext object On success. Otherwise NULL if no object * can be allocated or is available. */ - ExchangeContext * NewContext(SecureSessionHandle session, ExchangeDelegate * delegate); + ExchangeHandle NewContext(SecureSessionHandle session, ExchangeDelegate * delegate); void ReleaseContext(ExchangeContext * ec) { mContextPool.ReleaseObject(ec); } diff --git a/src/messaging/ReliableMessageContext.cpp b/src/messaging/ReliableMessageContext.cpp index 91220a995bbd81..2078a0f030fb99 100644 --- a/src/messaging/ReliableMessageContext.cpp +++ b/src/messaging/ReliableMessageContext.cpp @@ -42,15 +42,6 @@ ReliableMessageContext::ReliableMessageContext() : mConfig(gDefaultReliableMessageProtocolConfig), mNextAckTimeTick(0), mPendingPeerAckId(0) {} -void ReliableMessageContext::RetainContext() -{ - GetExchangeContext()->Retain(); -} - -void ReliableMessageContext::ReleaseContext() -{ - GetExchangeContext()->Release(); -} bool ReliableMessageContext::AutoRequestAck() const { @@ -165,12 +156,12 @@ uint64_t ReliableMessageContext::GetActiveRetransmitTimeoutTick() * @retval #CHIP_NO_ERROR if the context was removed. * */ -CHIP_ERROR ReliableMessageContext::HandleRcvdAck(uint32_t AckMsgId) +CHIP_ERROR ReliableMessageContext::HandleRcvdAck(ExchangeHandle exchangeContext, uint32_t AckMsgId) { CHIP_ERROR err = CHIP_NO_ERROR; // Msg is an Ack; Check Retrans Table and remove message context - if (!GetReliableMessageMgr()->CheckAndRemRetransTable(this, AckMsgId)) + if (!GetReliableMessageMgr()->CheckAndRemRetransTable(exchangeContext, AckMsgId)) { #if !defined(NDEBUG) ChipLogError(ExchangeManager, "CHIP MsgId:%08" PRIX32 " not in RetransTable", AckMsgId); @@ -188,7 +179,7 @@ CHIP_ERROR ReliableMessageContext::HandleRcvdAck(uint32_t AckMsgId) return err; } -CHIP_ERROR ReliableMessageContext::HandleNeedsAck(uint32_t MessageId, BitFlags MsgFlags) +CHIP_ERROR ReliableMessageContext::HandleNeedsAck(ExchangeHandle exchangeContext, uint32_t MessageId, BitFlags MsgFlags) { CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/src/messaging/ReliableMessageContext.h b/src/messaging/ReliableMessageContext.h index f8fe36d454e8df..4cb3196d0715d8 100644 --- a/src/messaging/ReliableMessageContext.h +++ b/src/messaging/ReliableMessageContext.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -224,10 +225,8 @@ class ReliableMessageContext BitFlags mFlags; // Internal state flags private: - void RetainContext(); - void ReleaseContext(); - CHIP_ERROR HandleRcvdAck(uint32_t AckMsgId); - CHIP_ERROR HandleNeedsAck(uint32_t MessageId, BitFlags Flags); + CHIP_ERROR HandleRcvdAck(ExchangeHandle exchangeContext, uint32_t AckMsgId); + CHIP_ERROR HandleNeedsAck(ExchangeHandle exchangeContext, uint32_t MessageId, BitFlags Flags); ExchangeContext * GetExchangeContext(); ReliableMessageMgr * GetReliableMessageMgr(); diff --git a/src/messaging/ReliableMessageMgr.cpp b/src/messaging/ReliableMessageMgr.cpp index 97457252632ef1..e3824d3943a6b7 100644 --- a/src/messaging/ReliableMessageMgr.cpp +++ b/src/messaging/ReliableMessageMgr.cpp @@ -37,7 +37,7 @@ namespace chip { namespace Messaging { -ReliableMessageMgr::RetransTableEntry::RetransTableEntry() : rc(nullptr), nextRetransTimeTick(0), sendCount(0) {} +ReliableMessageMgr::RetransTableEntry::RetransTableEntry() : nextRetransTimeTick(0), sendCount(0) {} ReliableMessageMgr::ReliableMessageMgr(BitMapObjectPool & contextPool) : mContextPool(contextPool), mSystemLayer(nullptr), mSessionMgr(nullptr), mCurrentTimerExpiry(0), @@ -86,9 +86,9 @@ void ReliableMessageMgr::TicklessDebugDumpRetransTable(const char * log) for (RetransTableEntry & entry : mRetransTable) { - if (entry.rc) + if (entry.ec.HasValue()) { - ChipLogDetail(ExchangeManager, "EC:%04" PRIX16 " MsgId:%08" PRIX32 " NextRetransTimeCtr:%04" PRIX16, entry.rc, + ChipLogDetail(ExchangeManager, "EC:%04" PRIX16 " MsgId:%08" PRIX32 " NextRetransTimeCtr:%04" PRIX16, entry.ec->GetExchangeId(), entry.msgId, entry.nextRetransTimeTick); } } @@ -106,17 +106,17 @@ void ReliableMessageMgr::ExecuteActions() ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExecuteActions"); #endif - ExecuteForAllContext([](ReliableMessageContext * rc) { - if (rc->IsAckPending()) + ExecuteForAllContext([](ReliableMessageContext & rc) { + if (rc.IsAckPending()) { - if (0 == rc->mNextAckTimeTick) + if (0 == rc.mNextAckTimeTick) { #if defined(RMP_TICKLESS_DEBUG) ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExecuteActions sending ACK"); #endif // Send the Ack in a SecureChannel::StandaloneAck message - rc->SendStandaloneAckMessage(); - rc->SetAckPending(false); + rc.SendStandaloneAckMessage(); + rc.SetAckPending(false); } } }); @@ -127,12 +127,12 @@ void ReliableMessageMgr::ExecuteActions() // has expired for (RetransTableEntry & entry : mRetransTable) { - ReliableMessageContext * rc = entry.rc; - CHIP_ERROR err = CHIP_NO_ERROR; - - if (!rc || entry.nextRetransTimeTick != 0) + if (!entry.ec.HasValue() || entry.nextRetransTimeTick != 0) continue; + CHIP_ERROR err = CHIP_NO_ERROR; + ReliableMessageContext & rc = entry.ec->GetReliableMessageContext(); + uint8_t sendCount = entry.sendCount; uint32_t msgId = entry.retainedBuf.GetMsgId(); @@ -154,7 +154,7 @@ void ReliableMessageMgr::ExecuteActions() if (err == CHIP_NO_ERROR) { // If the retransmission was successful, update the passive timer - entry.nextRetransTimeTick = static_cast(rc->GetActiveRetransmitTimeoutTick()); + entry.nextRetransTimeTick = static_cast(rc.GetActiveRetransmitTimeoutTick()); #if !defined(NDEBUG) ChipLogDetail(ExchangeManager, "Retransmit MsgId:%08" PRIX32 " Send Cnt %d", msgId, entry.sendCount); #endif @@ -191,21 +191,20 @@ void ReliableMessageMgr::ExpireTicks() deltaTicks); #endif - ExecuteForAllContext([deltaTicks](ReliableMessageContext * rc) { - if (rc->IsAckPending()) + ExecuteForAllContext([deltaTicks](ReliableMessageContext & rc) { + if (rc.IsAckPending()) { // Decrement counter of Ack timestamp by the elapsed timer ticks - TickProceed(rc->mNextAckTimeTick, deltaTicks); + TickProceed(rc.mNextAckTimeTick, deltaTicks); #if defined(RMP_TICKLESS_DEBUG) - ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExpireTicks set mNextAckTimeTick to %u", rc->mNextAckTimeTick); + ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExpireTicks set mNextAckTimeTick to %u", rc.mNextAckTimeTick); #endif } }); for (RetransTableEntry & entry : mRetransTable) { - ReliableMessageContext * rc = entry.rc; - if (rc) + if (entry.ec.HasValue()) { // Decrement Retransmit timeout by elapsed timeticks TickProceed(entry.nextRetransTimeTick, deltaTicks); @@ -213,7 +212,7 @@ void ReliableMessageMgr::ExpireTicks() ChipLogDetail(ExchangeManager, "ReliableMessageMgr::ExpireTicks set nextRetransTimeTick to %u", entry.nextRetransTimeTick); #endif - } // rc entry is allocated + } } // Re-Adjust the base time stamp to the most recent tick boundary @@ -244,30 +243,29 @@ void ReliableMessageMgr::Timeout(System::Layer * aSystemLayer, void * aAppState, manager->StartTimer(); } -CHIP_ERROR ReliableMessageMgr::AddToRetransTable(ReliableMessageContext * rc, RetransTableEntry ** rEntry) +CHIP_ERROR ReliableMessageMgr::AddToRetransTable(ExchangeHandle exchangeContext, RetransTableEntry ** rEntry) { bool added = false; CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrDie(rc != nullptr && !rc->IsOccupied()); + VerifyOrDie(!exchangeContext->GetReliableMessageContext().IsOccupied()); for (RetransTableEntry & entry : mRetransTable) { // Check the exchContext pointer for finding an empty slot in Table - if (!entry.rc) + if (!entry.ec.HasValue()) { // Expire any virtual ticks that have expired so all wakeup sources reflect the current time ExpireTicks(); - entry.rc = rc; + entry.ec = exchangeContext; entry.sendCount = 0; entry.retainedBuf = EncryptedPacketBufferHandle(); *rEntry = &entry; // Increment the reference count - rc->RetainContext(); - rc->SetOccupied(true); + exchangeContext->GetReliableMessageContext().SetOccupied(true); added = true; break; @@ -285,20 +283,20 @@ CHIP_ERROR ReliableMessageMgr::AddToRetransTable(ReliableMessageContext * rc, Re void ReliableMessageMgr::StartRetransmision(RetransTableEntry * entry) { - VerifyOrDie(entry != nullptr && entry->rc != nullptr); + VerifyOrDie(entry != nullptr && entry->ec.HasValue()); - entry->nextRetransTimeTick = static_cast(entry->rc->GetInitialRetransmitTimeoutTick() + + entry->nextRetransTimeTick = static_cast(entry->ec->GetReliableMessageContext().GetInitialRetransmitTimeoutTick() + GetTickCounterFromTimeDelta(System::Timer::GetCurrentEpoch())); // Check if the timer needs to be started and start it. StartTimer(); } -void ReliableMessageMgr::PauseRetransmision(ReliableMessageContext * rc, uint32_t PauseTimeMillis) +void ReliableMessageMgr::PauseRetransmision(ExchangeHandle exchangeContext, uint32_t PauseTimeMillis) { for (RetransTableEntry & entry : mRetransTable) { - if (entry.rc == rc) + if (entry.ec == exchangeContext) { entry.nextRetransTimeTick = static_cast(entry.nextRetransTimeTick + (PauseTimeMillis >> mTimerIntervalShift)); break; @@ -306,11 +304,11 @@ void ReliableMessageMgr::PauseRetransmision(ReliableMessageContext * rc, uint32_ } } -void ReliableMessageMgr::ResumeRetransmision(ReliableMessageContext * rc) +void ReliableMessageMgr::ResumeRetransmision(ExchangeHandle exchangeContext) { for (RetransTableEntry & entry : mRetransTable) { - if (entry.rc == rc) + if (entry.ec == exchangeContext) { entry.nextRetransTimeTick = 0; break; @@ -318,11 +316,11 @@ void ReliableMessageMgr::ResumeRetransmision(ReliableMessageContext * rc) } } -bool ReliableMessageMgr::CheckAndRemRetransTable(ReliableMessageContext * rc, uint32_t ackMsgId) +bool ReliableMessageMgr::CheckAndRemRetransTable(ExchangeHandle exchangeContext, uint32_t ackMsgId) { for (RetransTableEntry & entry : mRetransTable) { - if ((entry.rc == rc) && entry.retainedBuf.GetMsgId() == ackMsgId) + if ((entry.ec == exchangeContext) && entry.retainedBuf.GetMsgId() == ackMsgId) { // Clear the entry from the retransmision table. ClearRetransTable(entry); @@ -340,22 +338,21 @@ bool ReliableMessageMgr::CheckAndRemRetransTable(ReliableMessageContext * rc, ui CHIP_ERROR ReliableMessageMgr::SendFromRetransTable(RetransTableEntry * entry) { CHIP_ERROR err = CHIP_NO_ERROR; - ReliableMessageContext * rc = entry->rc; + ExchangeHandle exchangeContext = entry->ec; uint32_t msgId = 0; // Not actually used unless we reach the // line that initializes it properly. - VerifyOrReturnError(rc != nullptr, err); + VerifyOrDie(exchangeContext.HasValue()); // Now that we know this is a valid entry, grab the message id from the // retained buffer. We need to do that now, because we're about to hand it // over to someone else, and on failure it will no longer be available. msgId = entry->retainedBuf.GetMsgId(); - const ExchangeMessageDispatch * dispatcher = rc->GetExchangeContext()->GetMessageDispatch(); + const ExchangeMessageDispatch * dispatcher = exchangeContext->GetMessageDispatch(); VerifyOrExit(dispatcher != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - err = - dispatcher->ResendMessage(rc->GetExchangeContext()->GetSecureSession(), std::move(entry->retainedBuf), &entry->retainedBuf); + err = dispatcher->ResendMessage(exchangeContext->GetSecureSession(), std::move(entry->retainedBuf), &entry->retainedBuf); SuccessOrExit(err); // Update the counters @@ -373,11 +370,11 @@ CHIP_ERROR ReliableMessageMgr::SendFromRetransTable(RetransTableEntry * entry) return err; } -void ReliableMessageMgr::ClearRetransTable(ReliableMessageContext * rc) +void ReliableMessageMgr::ClearRetransTable(ExchangeHandle exchangeContext) { for (RetransTableEntry & entry : mRetransTable) { - if (entry.rc == rc) + if (entry.ec == exchangeContext) { // Clear the retransmit table entry. ClearRetransTable(entry); @@ -387,16 +384,16 @@ void ReliableMessageMgr::ClearRetransTable(ReliableMessageContext * rc) void ReliableMessageMgr::ClearRetransTable(RetransTableEntry & rEntry) { - if (rEntry.rc) + if (rEntry.ec.HasValue()) { - VerifyOrDie(rEntry.rc->IsOccupied() == true); + ReliableMessageContext & rc = rEntry.ec->GetReliableMessageContext(); + VerifyOrDie(rc.IsOccupied() == true); // Expire any virtual ticks that have expired so all wakeup sources reflect the current time ExpireTicks(); - rEntry.rc->ReleaseContext(); - rEntry.rc->SetOccupied(false); - rEntry.rc = nullptr; + rc.SetOccupied(false); + rEntry.ec.Release(); // Clear all other fields rEntry = RetransTableEntry(); @@ -407,18 +404,6 @@ void ReliableMessageMgr::ClearRetransTable(RetransTableEntry & rEntry) } } -void ReliableMessageMgr::FailRetransTableEntries(ReliableMessageContext * rc, CHIP_ERROR err) -{ - for (RetransTableEntry & entry : mRetransTable) - { - if (entry.rc == rc) - { - // Remove the entry from the retransmission table. - ClearRetransTable(entry); - } - } -} - void ReliableMessageMgr::StartTimer() { CHIP_ERROR res = CHIP_NO_ERROR; @@ -427,10 +412,10 @@ void ReliableMessageMgr::StartTimer() // When do we need to next wake up to send an ACK? - ExecuteForAllContext([&nextWakeTimeTick, &foundWake](ReliableMessageContext * rc) { - if (rc->IsAckPending() && rc->mNextAckTimeTick < nextWakeTimeTick) + ExecuteForAllContext([&nextWakeTimeTick, &foundWake](ReliableMessageContext & rc) { + if (rc.IsAckPending() && rc.mNextAckTimeTick < nextWakeTimeTick) { - nextWakeTimeTick = rc->mNextAckTimeTick; + nextWakeTimeTick = rc.mNextAckTimeTick; foundWake = true; #if defined(RMP_TICKLESS_DEBUG) ChipLogDetail(ExchangeManager, "ReliableMessageMgr::StartTimer next ACK time %u", nextWakeTimeTick); @@ -440,8 +425,7 @@ void ReliableMessageMgr::StartTimer() for (RetransTableEntry & entry : mRetransTable) { - ReliableMessageContext * rc = entry.rc; - if (rc) + if (entry.ec.HasValue()) { // When do we need to next wake up for ReliableMessageProtocol retransmit? if (entry.nextRetransTimeTick < nextWakeTimeTick) @@ -510,8 +494,7 @@ int ReliableMessageMgr::TestGetCountRetransTable() for (RetransTableEntry & entry : mRetransTable) { - ReliableMessageContext * rc = entry.rc; - if (rc) + if (entry.ec.HasValue()) count++; } diff --git a/src/messaging/ReliableMessageMgr.h b/src/messaging/ReliableMessageMgr.h index 29dde3dd2a1076..5508ee91d25c6c 100644 --- a/src/messaging/ReliableMessageMgr.h +++ b/src/messaging/ReliableMessageMgr.h @@ -60,7 +60,7 @@ class ReliableMessageMgr { RetransTableEntry(); - ReliableMessageContext * rc; /**< The context for the stored CHIP message. */ + ExchangeHandle ec; /**< The context for the stored CHIP message. */ EncryptedPacketBufferHandle retainedBuf; /**< The packet buffer holding the CHIP message. */ uint16_t nextRetransTimeTick; /**< A counter representing the next retransmission time for the message. */ uint8_t sendCount; /**< A counter representing the number of times the message has been sent. */ @@ -115,7 +115,7 @@ class ReliableMessageMgr * @retval #CHIP_ERROR_RETRANS_TABLE_FULL If there is no empty slot left in the table for addition. * @retval #CHIP_NO_ERROR On success. */ - CHIP_ERROR AddToRetransTable(ReliableMessageContext * rc, RetransTableEntry ** rEntry); + CHIP_ERROR AddToRetransTable(ExchangeHandle exchangeContext, RetransTableEntry ** rEntry); /** * Start retranmisttion of cached encryped packet for current entry. @@ -135,7 +135,7 @@ class ReliableMessageMgr * * @retval #CHIP_NO_ERROR On success. */ - void PauseRetransmision(ReliableMessageContext * rc, uint32_t PauseTimeMillis); + void PauseRetransmision(ExchangeHandle exchangeContext, uint32_t PauseTimeMillis); /** * Re-start retranmisttion of cached encryped packets for the given ReliableMessageContext. @@ -144,7 +144,7 @@ class ReliableMessageMgr * * @retval #CHIP_NO_ERROR On success. */ - void ResumeRetransmision(ReliableMessageContext * rc); + void ResumeRetransmision(ExchangeHandle exchangeContext); /** * Iterate through active exchange contexts and retrans table entries. Clear the entry matching @@ -156,7 +156,7 @@ class ReliableMessageMgr * * @retval #CHIP_NO_ERROR On success. */ - bool CheckAndRemRetransTable(ReliableMessageContext * rc, uint32_t msgId); + bool CheckAndRemRetransTable(ExchangeHandle exchangeContext, uint32_t msgId); /** * Send the specified entry from the retransmission table. @@ -173,7 +173,7 @@ class ReliableMessageMgr * @param[in] rc A pointer to the ExchangeContext object. * */ - void ClearRetransTable(ReliableMessageContext * rc); + void ClearRetransTable(ExchangeHandle exchangeContext); /** * Clear an entry in the retransmission table. @@ -183,16 +183,6 @@ class ReliableMessageMgr */ void ClearRetransTable(RetransTableEntry & rEntry); - /** - * Fail entries matching a specified ExchangeContext. - * - * @param[in] rc A pointer to the ExchangeContext object. - * - * @param[in] err The error for failing table entries. - * - */ - void FailRetransTableEntries(ReliableMessageContext * rc, CHIP_ERROR err); - /** * Iterate through active exchange contexts and retrans table entries. * Determine how many ReliableMessageProtocol ticks we need to sleep before we diff --git a/src/messaging/tests/MessagingContext.cpp b/src/messaging/tests/MessagingContext.cpp index fdd44dfdf0225c..1377fa8fb0beb1 100644 --- a/src/messaging/tests/MessagingContext.cpp +++ b/src/messaging/tests/MessagingContext.cpp @@ -67,13 +67,13 @@ SecureSessionHandle MessagingContext::GetSessionPeerToLocal() return { GetSourceNodeId(), GetLocalKeyId(), GetAdminId() }; } -Messaging::ExchangeContext * MessagingContext::NewExchangeToPeer(Messaging::ExchangeDelegate * delegate) +Messaging::ExchangeHandle MessagingContext::NewExchangeToPeer(Messaging::ExchangeDelegate * delegate) { // TODO: temprary create a SecureSessionHandle from node id, will be fix in PR 3602 return mExchangeManager.NewContext(GetSessionLocalToPeer(), delegate); } -Messaging::ExchangeContext * MessagingContext::NewExchangeToLocal(Messaging::ExchangeDelegate * delegate) +Messaging::ExchangeHandle MessagingContext::NewExchangeToLocal(Messaging::ExchangeDelegate * delegate) { // TODO: temprary create a SecureSessionHandle from node id, will be fix in PR 3602 return mExchangeManager.NewContext(GetSessionPeerToLocal(), delegate); diff --git a/src/messaging/tests/MessagingContext.h b/src/messaging/tests/MessagingContext.h index 79a5286ae17f1c..8a735a71da6b43 100644 --- a/src/messaging/tests/MessagingContext.h +++ b/src/messaging/tests/MessagingContext.h @@ -79,8 +79,8 @@ class MessagingContext : public IOContext SecureSessionHandle GetSessionLocalToPeer(); SecureSessionHandle GetSessionPeerToLocal(); - Messaging::ExchangeContext * NewExchangeToPeer(Messaging::ExchangeDelegate * delegate); - Messaging::ExchangeContext * NewExchangeToLocal(Messaging::ExchangeDelegate * delegate); + Messaging::ExchangeHandle NewExchangeToPeer(Messaging::ExchangeDelegate * delegate); + Messaging::ExchangeHandle NewExchangeToLocal(Messaging::ExchangeDelegate * delegate); Credentials::OperationalCredentialSet & GetOperationalCredentialSet() { return mOperationalCredentialSet; } diff --git a/src/messaging/tests/TestExchangeMgr.cpp b/src/messaging/tests/TestExchangeMgr.cpp index 7c491c524f3f11..d35006a144cd43 100644 --- a/src/messaging/tests/TestExchangeMgr.cpp +++ b/src/messaging/tests/TestExchangeMgr.cpp @@ -77,14 +77,14 @@ TransportMgr gTransportMgr; class MockAppDelegate : public ExchangeDelegate { public: - void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && buffer) override { IsOnMessageReceivedCalled = true; ec->Close(); } - void OnResponseTimeout(ExchangeContext * ec) override {} + void OnResponseTimeout(ExchangeHandle ec) override {} bool IsOnMessageReceivedCalled = false; }; @@ -94,8 +94,8 @@ void CheckNewContextTest(nlTestSuite * inSuite, void * inContext) TestContext & ctx = *reinterpret_cast(inContext); MockAppDelegate mockAppDelegate; - ExchangeContext * ec1 = ctx.NewExchangeToLocal(&mockAppDelegate); - NL_TEST_ASSERT(inSuite, ec1 != nullptr); + ExchangeHandle ec1 = ctx.NewExchangeToLocal(&mockAppDelegate); + NL_TEST_ASSERT(inSuite, ec1.HasValue()); NL_TEST_ASSERT(inSuite, ec1->IsInitiator() == true); NL_TEST_ASSERT(inSuite, ec1->GetExchangeId() != 0); auto sessionPeerToLocal = ctx.GetSecureSessionManager().GetPeerConnectionState(ec1->GetSecureSession()); @@ -103,8 +103,8 @@ void CheckNewContextTest(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, sessionPeerToLocal->GetPeerKeyID() == ctx.GetLocalKeyId()); NL_TEST_ASSERT(inSuite, ec1->GetDelegate() == &mockAppDelegate); - ExchangeContext * ec2 = ctx.NewExchangeToPeer(&mockAppDelegate); - NL_TEST_ASSERT(inSuite, ec2 != nullptr); + ExchangeHandle ec2 = ctx.NewExchangeToPeer(&mockAppDelegate); + NL_TEST_ASSERT(inSuite, ec2.HasValue()); NL_TEST_ASSERT(inSuite, ec2->GetExchangeId() > ec1->GetExchangeId()); auto sessionLocalToPeer = ctx.GetSecureSessionManager().GetPeerConnectionState(ec2->GetSecureSession()); NL_TEST_ASSERT(inSuite, sessionLocalToPeer->GetPeerNodeId() == ctx.GetDestinationNodeId()); @@ -148,7 +148,7 @@ void CheckExchangeMessages(nlTestSuite * inSuite, void * inContext) // create solicited exchange MockAppDelegate mockSolicitedAppDelegate; - ExchangeContext * ec1 = ctx.NewExchangeToPeer(&mockSolicitedAppDelegate); + ExchangeHandle ec1 = ctx.NewExchangeToPeer(&mockSolicitedAppDelegate); // create unsolicited exchange MockAppDelegate mockUnsolicitedAppDelegate; diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index 818335e3c46fa3..684ffb7b6ee9c8 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -91,13 +91,13 @@ OutgoingTransport gLoopback; class MockAppDelegate : public ExchangeDelegate { public: - void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && buffer) override { IsOnMessageReceivedCalled = true; } - void OnResponseTimeout(ExchangeContext * ec) override {} + void OnResponseTimeout(ExchangeHandle ec) override {} bool IsOnMessageReceivedCalled = false; }; @@ -119,17 +119,15 @@ void CheckAddClearRetrans(nlTestSuite * inSuite, void * inContext) TestContext & ctx = *reinterpret_cast(inContext); MockAppDelegate mockAppDelegate; - ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockAppDelegate); - NL_TEST_ASSERT(inSuite, exchange != nullptr); + ExchangeHandle exchange = ctx.NewExchangeToPeer(&mockAppDelegate); + NL_TEST_ASSERT(inSuite, exchange.HasValue()); ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); - ReliableMessageContext * rc = exchange->GetReliableMessageContext(); NL_TEST_ASSERT(inSuite, rm != nullptr); - NL_TEST_ASSERT(inSuite, rc != nullptr); ReliableMessageMgr::RetransTableEntry * entry; - rm->AddToRetransTable(rc, &entry); + rm->AddToRetransTable(exchange, &entry); NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1); rm->ClearRetransTable(*entry); NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 0); @@ -137,30 +135,6 @@ void CheckAddClearRetrans(nlTestSuite * inSuite, void * inContext) exchange->Close(); } -void CheckFailRetrans(nlTestSuite * inSuite, void * inContext) -{ - TestContext & ctx = *reinterpret_cast(inContext); - - ctx.GetInetLayer().SystemLayer()->Init(nullptr); - - MockAppDelegate mockAppDelegate; - ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockAppDelegate); - NL_TEST_ASSERT(inSuite, exchange != nullptr); - - ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); - ReliableMessageContext * rc = exchange->GetReliableMessageContext(); - NL_TEST_ASSERT(inSuite, rm != nullptr); - NL_TEST_ASSERT(inSuite, rc != nullptr); - - ReliableMessageMgr::RetransTableEntry * entry; - rm->AddToRetransTable(rc, &entry); - NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 1); - rm->FailRetransTableEntries(rc, CHIP_NO_ERROR); - NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 0); - - exchange->Close(); -} - void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) { TestContext & ctx = *reinterpret_cast(inContext); @@ -174,15 +148,14 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) MockAppDelegate mockSender; // TODO: temporarily create a SecureSessionHandle from node id, will be fix in PR 3602 - ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockSender); - NL_TEST_ASSERT(inSuite, exchange != nullptr); + ExchangeHandle exchange = ctx.NewExchangeToPeer(&mockSender); + NL_TEST_ASSERT(inSuite, exchange.HasValue()); ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); - ReliableMessageContext * rc = exchange->GetReliableMessageContext(); + ReliableMessageContext & rc = exchange->GetReliableMessageContext(); NL_TEST_ASSERT(inSuite, rm != nullptr); - NL_TEST_ASSERT(inSuite, rc != nullptr); - rc->SetConfig({ + rc.SetConfig({ 1, // CHIP_CONFIG_RMP_DEFAULT_INITIAL_RETRY_INTERVAL 1, // CHIP_CONFIG_RMP_DEFAULT_ACTIVE_RETRY_INTERVAL }); @@ -222,8 +195,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, gLoopback.mDroppedMessageCount == 2); NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 0); - rm->ClearRetransTable(rc); - exchange->Close(); + rm->ClearRetransTable(exchange); } void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void * inContext) @@ -238,16 +210,14 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void * CHIP_ERROR err = CHIP_NO_ERROR; MockAppDelegate mockSender; - // TODO: temporarily create a SecureSessionHandle from node id, will be fixed in PR 3602 - ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockSender); - NL_TEST_ASSERT(inSuite, exchange != nullptr); + ExchangeHandle exchange = ctx.NewExchangeToPeer(&mockSender); + NL_TEST_ASSERT(inSuite, exchange.HasValue()); ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); - ReliableMessageContext * rc = exchange->GetReliableMessageContext(); + ReliableMessageContext & rc = exchange->GetReliableMessageContext(); NL_TEST_ASSERT(inSuite, rm != nullptr); - NL_TEST_ASSERT(inSuite, rc != nullptr); - rc->SetConfig({ + rc.SetConfig({ 1, // CHIP_CONFIG_RMP_DEFAULT_INITIAL_RETRY_INTERVAL 1, // CHIP_CONFIG_RMP_DEFAULT_ACTIVE_RETRY_INTERVAL }); @@ -288,7 +258,7 @@ void CheckCloseExchangeAndResendApplicationMessage(nlTestSuite * inSuite, void * NL_TEST_ASSERT(inSuite, gLoopback.mDroppedMessageCount == 2); NL_TEST_ASSERT(inSuite, rm->TestGetCountRetransTable() == 0); - rm->ClearRetransTable(rc); + rm->ClearRetransTable(exchange); } void CheckSendStandaloneAckMessage(nlTestSuite * inSuite, void * inContext) @@ -298,15 +268,14 @@ void CheckSendStandaloneAckMessage(nlTestSuite * inSuite, void * inContext) ctx.GetInetLayer().SystemLayer()->Init(nullptr); MockAppDelegate mockAppDelegate; - ExchangeContext * exchange = ctx.NewExchangeToPeer(&mockAppDelegate); - NL_TEST_ASSERT(inSuite, exchange != nullptr); + ExchangeHandle exchange = ctx.NewExchangeToPeer(&mockAppDelegate); + NL_TEST_ASSERT(inSuite, exchange.HasValue()); ReliableMessageMgr * rm = ctx.GetExchangeManager().GetReliableMessageMgr(); - ReliableMessageContext * rc = exchange->GetReliableMessageContext(); + ReliableMessageContext & rc = exchange->GetReliableMessageContext(); NL_TEST_ASSERT(inSuite, rm != nullptr); - NL_TEST_ASSERT(inSuite, rc != nullptr); - NL_TEST_ASSERT(inSuite, rc->SendStandaloneAckMessage() == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, rc.SendStandaloneAckMessage() == CHIP_NO_ERROR); exchange->Close(); } @@ -320,7 +289,6 @@ void CheckSendStandaloneAckMessage(nlTestSuite * inSuite, void * inContext) const nlTest sTests[] = { NL_TEST_DEF("Test ReliableMessageMgr::CheckAddClearRetrans", CheckAddClearRetrans), - NL_TEST_DEF("Test ReliableMessageMgr::CheckFailRetrans", CheckFailRetrans), NL_TEST_DEF("Test ReliableMessageMgr::CheckResendApplicationMessage", CheckResendApplicationMessage), NL_TEST_DEF("Test ReliableMessageMgr::CheckCloseExchangeAndResendApplicationMessage", CheckCloseExchangeAndResendApplicationMessage), NL_TEST_DEF("Test ReliableMessageMgr::CheckSendStandaloneAckMessage", CheckSendStandaloneAckMessage), diff --git a/src/messaging/tests/echo/echo_requester.cpp b/src/messaging/tests/echo/echo_requester.cpp index 2e100386b97d3b..e98691e9774232 100644 --- a/src/messaging/tests/echo/echo_requester.cpp +++ b/src/messaging/tests/echo/echo_requester.cpp @@ -154,7 +154,7 @@ CHIP_ERROR EstablishSecureSession() return err; } -void HandleEchoResponseReceived(chip::Messaging::ExchangeContext * ec, chip::System::PacketBufferHandle && payload) +void HandleEchoResponseReceived(chip::Messaging::ExchangeHandle ec, chip::System::PacketBufferHandle && payload) { uint32_t respTime = chip::System::Timer::GetCurrentEpoch(); uint32_t transitTime = respTime - gLastEchoTime; diff --git a/src/messaging/tests/echo/echo_responder.cpp b/src/messaging/tests/echo/echo_responder.cpp index 32dff139291017..795b410b3101f0 100644 --- a/src/messaging/tests/echo/echo_responder.cpp +++ b/src/messaging/tests/echo/echo_responder.cpp @@ -49,7 +49,7 @@ chip::SecureSessionMgr gSessionManager; chip::SecurePairingUsingTestSecret gTestPairing; // Callback handler when a CHIP EchoRequest is received. -void HandleEchoRequestReceived(chip::Messaging::ExchangeContext * ec, chip::System::PacketBufferHandle && payload) +void HandleEchoRequestReceived(chip::Messaging::ExchangeHandle ec, chip::System::PacketBufferHandle && payload) { printf("Echo Request, len=%u ... sending response.\n", payload->DataLength()); } diff --git a/src/protocols/echo/Echo.h b/src/protocols/echo/Echo.h index 9a095aaf374325..558c2353ab39ab 100644 --- a/src/protocols/echo/Echo.h +++ b/src/protocols/echo/Echo.h @@ -47,7 +47,7 @@ enum class MsgType : uint8_t EchoResponse = 0x02 }; -using EchoFunct = void (*)(Messaging::ExchangeContext * ec, System::PacketBufferHandle && payload); +using EchoFunct = void (*)(Messaging::ExchangeHandle ec, System::PacketBufferHandle && payload); class DLL_EXPORT EchoClient : public Messaging::ExchangeDelegate { @@ -99,13 +99,13 @@ class DLL_EXPORT EchoClient : public Messaging::ExchangeDelegate private: Messaging::ExchangeManager * mExchangeMgr = nullptr; - Messaging::ExchangeContext * mExchangeCtx = nullptr; + Messaging::ExchangeHandle mExchangeCtx; EchoFunct OnEchoResponseReceived = nullptr; SecureSessionHandle mSecureSession; - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override; - void OnResponseTimeout(Messaging::ExchangeContext * ec) override; + void OnResponseTimeout(Messaging::ExchangeHandle ec) override; }; class DLL_EXPORT EchoServer : public Messaging::ExchangeDelegate @@ -145,9 +145,9 @@ class DLL_EXPORT EchoServer : public Messaging::ExchangeDelegate Messaging::ExchangeManager * mExchangeMgr = nullptr; EchoFunct OnEchoRequestReceived = nullptr; - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override; - void OnResponseTimeout(Messaging::ExchangeContext * ec) override {} + void OnResponseTimeout(Messaging::ExchangeHandle ec) override {} }; } // namespace Echo diff --git a/src/protocols/echo/EchoClient.cpp b/src/protocols/echo/EchoClient.cpp index aae35841ee9431..8bf8a14cee0bbb 100644 --- a/src/protocols/echo/EchoClient.cpp +++ b/src/protocols/echo/EchoClient.cpp @@ -38,17 +38,16 @@ CHIP_ERROR EchoClient::Init(Messaging::ExchangeManager * exchangeMgr, SecureSess mExchangeMgr = exchangeMgr; mSecureSession = session; OnEchoResponseReceived = nullptr; - mExchangeCtx = nullptr; return CHIP_NO_ERROR; } void EchoClient::Shutdown() { - if (mExchangeCtx != nullptr) + if (mExchangeCtx.HasValue()) { mExchangeCtx->Abort(); - mExchangeCtx = nullptr; + mExchangeCtx.Release(); } OnEchoResponseReceived = nullptr; @@ -61,15 +60,15 @@ CHIP_ERROR EchoClient::SendEchoRequest(System::PacketBufferHandle && payload, co // Discard any existing exchange context. Effectively we can only have one Echo exchange with // a single node at any one time. - if (mExchangeCtx != nullptr) + if (mExchangeCtx.HasValue()) { mExchangeCtx->Abort(); - mExchangeCtx = nullptr; + mExchangeCtx.Release(); } // Create a new exchange context. mExchangeCtx = mExchangeMgr->NewContext(mSecureSession, this); - if (mExchangeCtx == nullptr) + if (!mExchangeCtx.HasValue()) { return CHIP_ERROR_NO_MEMORY; } @@ -80,13 +79,13 @@ CHIP_ERROR EchoClient::SendEchoRequest(System::PacketBufferHandle && payload, co if (err != CHIP_NO_ERROR) { mExchangeCtx->Abort(); - mExchangeCtx = nullptr; + mExchangeCtx.Release(); } return err; } -void EchoClient::OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, +void EchoClient::OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) { // Assert that the exchange context matches the client's current context. @@ -99,8 +98,8 @@ void EchoClient::OnMessageReceived(Messaging::ExchangeContext * ec, const Packet // If not, close the exchange and free the payload. if (!payloadHeader.HasMessageType(MsgType::EchoResponse)) { - ec->Close(); - mExchangeCtx = nullptr; + ec.Release(); + mExchangeCtx.Release(); return; } @@ -109,7 +108,7 @@ void EchoClient::OnMessageReceived(Messaging::ExchangeContext * ec, const Packet // because we no longer care whether the echo request message has been // acknowledged at the transport layer. mExchangeCtx->Abort(); - mExchangeCtx = nullptr; + mExchangeCtx.Release(); // Call the registered OnEchoResponseReceived handler, if any. if (OnEchoResponseReceived != nullptr) @@ -118,9 +117,9 @@ void EchoClient::OnMessageReceived(Messaging::ExchangeContext * ec, const Packet } } -void EchoClient::OnResponseTimeout(Messaging::ExchangeContext * ec) +void EchoClient::OnResponseTimeout(Messaging::ExchangeHandle ec) { - ChipLogProgress(Echo, "Time out! failed to receive echo response from Exchange: %p", ec); + ChipLogProgress(Echo, "Time out! failed to receive echo response from Exchange: %d", ec->GetExchangeId()); } } // namespace Echo diff --git a/src/protocols/echo/EchoServer.cpp b/src/protocols/echo/EchoServer.cpp index 5f3a6ec525dc9d..33887611818ac3 100644 --- a/src/protocols/echo/EchoServer.cpp +++ b/src/protocols/echo/EchoServer.cpp @@ -53,7 +53,7 @@ void EchoServer::Shutdown() } } -void EchoServer::OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, +void EchoServer::OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) { System::PacketBufferHandle response; @@ -84,7 +84,7 @@ void EchoServer::OnMessageReceived(Messaging::ExchangeContext * ec, const Packet ec->SendMessage(MsgType::EchoResponse, std::move(response)); // Discard the exchange context. - ec->Close(); + ec.Release(); } } // namespace Echo diff --git a/src/protocols/secure_channel/CASEServer.cpp b/src/protocols/secure_channel/CASEServer.cpp index 25adca9cbf1794..9156e114390cb7 100644 --- a/src/protocols/secure_channel/CASEServer.cpp +++ b/src/protocols/secure_channel/CASEServer.cpp @@ -49,9 +49,9 @@ CHIP_ERROR CASEServer::ListenForSessionEstablishment(Messaging::ExchangeManager return CHIP_NO_ERROR; } -CHIP_ERROR CASEServer::InitCASEHandshake(Messaging::ExchangeContext * ec) +CHIP_ERROR CASEServer::InitCASEHandshake(Messaging::ExchangeHandle ec) { - ReturnErrorCodeIf(ec == nullptr, CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!ec.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); // TODO - Use PK of the root CA for the initiator to figure out the admin. mAdminId = ec->GetSecureSession().GetAdminId(); @@ -76,10 +76,10 @@ CHIP_ERROR CASEServer::InitCASEHandshake(Messaging::ExchangeContext * ec) return CHIP_NO_ERROR; } -void CASEServer::OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, +void CASEServer::OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) { - ChipLogProgress(Inet, "CASE Server received SigmaR1 message. Starting handshake. EC %p", ec); + ChipLogProgress(Inet, "CASE Server received SigmaR1 message. Starting handshake. EC %d", ec->GetExchangeId()); ReturnOnFailure(InitCASEHandshake(ec)); mPairingSession.OnMessageReceived(ec, packetHeader, payloadHeader, std::move(payload)); diff --git a/src/protocols/secure_channel/CASEServer.h b/src/protocols/secure_channel/CASEServer.h index 5a976b79558525..d782e096b52618 100644 --- a/src/protocols/secure_channel/CASEServer.h +++ b/src/protocols/secure_channel/CASEServer.h @@ -45,9 +45,9 @@ class CASEServer : public SessionEstablishmentDelegate, public Messaging::Exchan void OnSessionEstablished() override; //// ExchangeDelegate Implementation //// - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override; - void OnResponseTimeout(Messaging::ExchangeContext * ec) override {} + void OnResponseTimeout(Messaging::ExchangeHandle ec) override {} Messaging::ExchangeMessageDispatch * GetMessageDispatch(Messaging::ReliableMessageMgr * reliableMessageManager, SecureSessionMgr * sessionMgr) override { @@ -68,7 +68,7 @@ class CASEServer : public SessionEstablishmentDelegate, public Messaging::Exchan Credentials::OperationalCredentialSet mCredentials; Credentials::CertificateKeyId mRootKeyId; - CHIP_ERROR InitCASEHandshake(Messaging::ExchangeContext * ec); + CHIP_ERROR InitCASEHandshake(Messaging::ExchangeHandle ec); void Cleanup(); }; diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp index fa0ff9b0333364..54f90e2b5814c2 100644 --- a/src/protocols/secure_channel/CASESession.cpp +++ b/src/protocols/secure_channel/CASESession.cpp @@ -103,10 +103,10 @@ void CASESession::Clear() mTrustedRootId.mId = nullptr; } - if (mExchangeCtxt != nullptr) + if (mExchangeCtxt.HasValue()) { mExchangeCtxt->Close(); - mExchangeCtxt = nullptr; + mExchangeCtxt.Release(); } } @@ -227,11 +227,11 @@ CASESession::ListenForSessionEstablishment(OperationalCredentialSet * operationa CHIP_ERROR CASESession::EstablishSession(const Transport::PeerAddress peerAddress, OperationalCredentialSet * operationalCredentialSet, NodeId peerNodeId, uint16_t myKeyId, - ExchangeContext * exchangeCtxt, SessionEstablishmentDelegate * delegate) + ExchangeHandle exchangeCtxt, SessionEstablishmentDelegate * delegate) { CHIP_ERROR err = CHIP_NO_ERROR; - ReturnErrorCodeIf(exchangeCtxt == nullptr, CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!exchangeCtxt.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); err = Init(operationalCredentialSet, myKeyId, delegate); @@ -255,9 +255,9 @@ CHIP_ERROR CASESession::EstablishSession(const Transport::PeerAddress peerAddres return err; } -void CASESession::OnResponseTimeout(ExchangeContext * ec) +void CASESession::OnResponseTimeout(ExchangeHandle ec) { - VerifyOrReturn(ec != nullptr, ChipLogError(Inet, "CASESession::OnResponseTimeout was called by null exchange")); + VerifyOrReturn(ec.HasValue(), ChipLogError(Inet, "CASESession::OnResponseTimeout was called by null exchange")); VerifyOrReturn(mExchangeCtxt == ec, ChipLogError(Inet, "CASESession::OnResponseTimeout exchange doesn't match")); ChipLogError(Inet, "CASESession timed out while waiting for a response from the peer. Expected message type was %d", mNextExpectedMsg); @@ -1109,15 +1109,15 @@ void CASESession::HandleErrorMsg(const System::PacketBufferHandle & msg) Clear(); } -CHIP_ERROR CASESession::ValidateReceivedMessage(ExchangeContext * ec, const PacketHeader & packetHeader, +CHIP_ERROR CASESession::ValidateReceivedMessage(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle & msg) { - VerifyOrReturnError(ec != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(ec.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); // mExchangeCtxt can be nullptr if this is the first message (CASE_SigmaR1) received by CASESession // via UnsolicitedMessageHandler. The exchange context is allocated by exchange manager and provided // to the handler (CASESession object). - if (mExchangeCtxt != nullptr) + if (mExchangeCtxt.HasValue()) { if (mExchangeCtxt != ec) { @@ -1153,7 +1153,7 @@ CHIP_ERROR CASESession::ValidateReceivedMessage(ExchangeContext * ec, const Pack return CHIP_NO_ERROR; } -void CASESession::OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, +void CASESession::OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msg) { CHIP_ERROR err = ValidateReceivedMessage(ec, packetHeader, payloadHeader, msg); diff --git a/src/protocols/secure_channel/CASESession.h b/src/protocols/secure_channel/CASESession.h index 47afdddb0e49dd..f623b9ca90ef56 100644 --- a/src/protocols/secure_channel/CASESession.h +++ b/src/protocols/secure_channel/CASESession.h @@ -111,7 +111,7 @@ class DLL_EXPORT CASESession : public Messaging::ExchangeDelegate, public Pairin * @return CHIP_ERROR The result of initialization */ CHIP_ERROR EstablishSession(const Transport::PeerAddress peerAddress, OperationalCredentialSet * operationalCredentialSet, - NodeId peerNodeId, uint16_t myKeyId, Messaging::ExchangeContext * exchangeCtxt, + NodeId peerNodeId, uint16_t myKeyId, Messaging::ExchangeHandle exchangeCtxt, SessionEstablishmentDelegate * delegate); /** @@ -179,9 +179,9 @@ class DLL_EXPORT CASESession : public Messaging::ExchangeDelegate, public Pairin SessionEstablishmentExchangeDispatch & MessageDispatch() { return mMessageDispatch; } //// ExchangeDelegate Implementation //// - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override; - void OnResponseTimeout(Messaging::ExchangeContext * ec) override; + void OnResponseTimeout(Messaging::ExchangeHandle ec) override; Messaging::ExchangeMessageDispatch * GetMessageDispatch(Messaging::ReliableMessageMgr * rmMgr, SecureSessionMgr * sessionMgr) override { @@ -231,7 +231,7 @@ class DLL_EXPORT CASESession : public Messaging::ExchangeDelegate, public Pairin void Clear(); - CHIP_ERROR ValidateReceivedMessage(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, + CHIP_ERROR ValidateReceivedMessage(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle & msg); SessionEstablishmentDelegate * mDelegate = nullptr; @@ -250,7 +250,7 @@ class DLL_EXPORT CASESession : public Messaging::ExchangeDelegate, public Pairin uint8_t mIPK[kIPKSize]; uint8_t mRemoteIPK[kIPKSize]; - Messaging::ExchangeContext * mExchangeCtxt = nullptr; + Messaging::ExchangeHandle mExchangeCtxt; SessionEstablishmentExchangeDispatch mMessageDispatch; struct SigmaErrorMsg diff --git a/src/protocols/secure_channel/MessageCounterManager.cpp b/src/protocols/secure_channel/MessageCounterManager.cpp index eff8b77b770095..281726b7ad7ab7 100644 --- a/src/protocols/secure_channel/MessageCounterManager.cpp +++ b/src/protocols/secure_channel/MessageCounterManager.cpp @@ -85,7 +85,7 @@ CHIP_ERROR MessageCounterManager::QueueReceivedMessageAndStartSync(const PacketH return CHIP_NO_ERROR; } -void MessageCounterManager::OnMessageReceived(Messaging::ExchangeContext * exchangeContext, const PacketHeader & packetHeader, +void MessageCounterManager::OnMessageReceived(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf) { if (payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::MsgCounterSyncReq)) @@ -98,7 +98,7 @@ void MessageCounterManager::OnMessageReceived(Messaging::ExchangeContext * excha } } -void MessageCounterManager::OnResponseTimeout(Messaging::ExchangeContext * exchangeContext) +void MessageCounterManager::OnResponseTimeout(Messaging::ExchangeHandle exchangeContext) { Transport::PeerConnectionState * state = mExchangeMgr->GetSessionMgr()->GetPeerConnectionState(exchangeContext->GetSecureSession()); @@ -178,12 +178,12 @@ CHIP_ERROR MessageCounterManager::SendMsgCounterSyncReq(SecureSessionHandle sess { CHIP_ERROR err = CHIP_NO_ERROR; - Messaging::ExchangeContext * exchangeContext = nullptr; + Messaging::ExchangeHandle exchangeContext; System::PacketBufferHandle msgBuf; Messaging::SendFlags sendFlags; exchangeContext = mExchangeMgr->NewContext(session, this); - VerifyOrExit(exchangeContext != nullptr, err = CHIP_ERROR_NO_MEMORY); + VerifyOrExit(exchangeContext.HasValue(), err = CHIP_ERROR_NO_MEMORY); msgBuf = MessagePacketBuffer::New(kChallengeSize); VerifyOrExit(!msgBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY); @@ -215,7 +215,7 @@ CHIP_ERROR MessageCounterManager::SendMsgCounterSyncReq(SecureSessionHandle sess return err; } -CHIP_ERROR MessageCounterManager::SendMsgCounterSyncResp(Messaging::ExchangeContext * exchangeContext, +CHIP_ERROR MessageCounterManager::SendMsgCounterSyncResp(Messaging::ExchangeHandle exchangeContext, FixedByteSpan challenge) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -253,7 +253,7 @@ CHIP_ERROR MessageCounterManager::SendMsgCounterSyncResp(Messaging::ExchangeCont return err; } -void MessageCounterManager::HandleMsgCounterSyncReq(Messaging::ExchangeContext * exchangeContext, const PacketHeader & packetHeader, +void MessageCounterManager::HandleMsgCounterSyncReq(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, System::PacketBufferHandle && msgBuf) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -280,7 +280,7 @@ void MessageCounterManager::HandleMsgCounterSyncReq(Messaging::ExchangeContext * return; } -void MessageCounterManager::HandleMsgCounterSyncResp(Messaging::ExchangeContext * exchangeContext, +void MessageCounterManager::HandleMsgCounterSyncResp(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, System::PacketBufferHandle && msgBuf) { CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/src/protocols/secure_channel/MessageCounterManager.h b/src/protocols/secure_channel/MessageCounterManager.h index 42672564983a83..6c88375215c698 100644 --- a/src/protocols/secure_channel/MessageCounterManager.h +++ b/src/protocols/secure_channel/MessageCounterManager.h @@ -101,18 +101,18 @@ class MessageCounterManager : public Messaging::ExchangeDelegate, public Transpo void ProcessPendingMessages(NodeId peerNodeId); - CHIP_ERROR SendMsgCounterSyncResp(Messaging::ExchangeContext * exchangeContext, FixedByteSpan challenge); + CHIP_ERROR SendMsgCounterSyncResp(Messaging::ExchangeHandle exchangeContext, FixedByteSpan challenge); - void HandleMsgCounterSyncReq(Messaging::ExchangeContext * exchangeContext, const PacketHeader & packetHeader, + void HandleMsgCounterSyncReq(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, System::PacketBufferHandle && msgBuf); - void HandleMsgCounterSyncResp(Messaging::ExchangeContext * exchangeContext, const PacketHeader & packetHeader, + void HandleMsgCounterSyncResp(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, System::PacketBufferHandle && msgBuf); - void OnMessageReceived(Messaging::ExchangeContext * exchangeContext, const PacketHeader & packetHeader, + void OnMessageReceived(Messaging::ExchangeHandle exchangeContext, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override; - void OnResponseTimeout(Messaging::ExchangeContext * exchangeContext) override; + void OnResponseTimeout(Messaging::ExchangeHandle exchangeContext) override; }; } // namespace secure_channel diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp index 433e027bdeb14a..d45ec13913e281 100644 --- a/src/protocols/secure_channel/PASESession.cpp +++ b/src/protocols/secure_channel/PASESession.cpp @@ -104,10 +104,10 @@ void PASESession::Clear() void PASESession::CloseExchange() { - if (mExchangeCtxt != nullptr) + if (mExchangeCtxt.HasValue()) { mExchangeCtxt->Close(); - mExchangeCtxt = nullptr; + mExchangeCtxt.Release(); } } @@ -301,9 +301,9 @@ CHIP_ERROR PASESession::WaitForPairing(const PASEVerifier & verifier, uint16_t m } CHIP_ERROR PASESession::Pair(const Transport::PeerAddress peerAddress, uint32_t peerSetUpPINCode, uint16_t myKeyId, - Messaging::ExchangeContext * exchangeCtxt, SessionEstablishmentDelegate * delegate) + Messaging::ExchangeHandle exchangeCtxt, SessionEstablishmentDelegate * delegate) { - ReturnErrorCodeIf(exchangeCtxt == nullptr, CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!exchangeCtxt.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); CHIP_ERROR err = Init(myKeyId, peerSetUpPINCode, delegate); SuccessOrExit(err); @@ -323,10 +323,10 @@ CHIP_ERROR PASESession::Pair(const Transport::PeerAddress peerAddress, uint32_t return err; } -void PASESession::OnResponseTimeout(ExchangeContext * ec) +void PASESession::OnResponseTimeout(ExchangeHandle ec) { - VerifyOrReturn(ec != nullptr, ChipLogError(SecureChannel, "PASESession::OnResponseTimeout was called by null exchange")); - VerifyOrReturn(mExchangeCtxt == nullptr || mExchangeCtxt == ec, + VerifyOrReturn(ec.HasValue(), ChipLogError(SecureChannel, "PASESession::OnResponseTimeout was called by null exchange")); + VerifyOrReturn(!mExchangeCtxt.HasValue() || mExchangeCtxt == ec, ChipLogError(SecureChannel, "PASESession::OnResponseTimeout exchange doesn't match")); ChipLogError(SecureChannel, "PASESession timed out while waiting for a response from the peer. Expected message type was %d", mNextExpectedMsg); @@ -751,15 +751,15 @@ CHIP_ERROR PASESession::HandleErrorMsg(const System::PacketBufferHandle & msg) return err; } -CHIP_ERROR PASESession::ValidateReceivedMessage(ExchangeContext * exchange, const PacketHeader & packetHeader, +CHIP_ERROR PASESession::ValidateReceivedMessage(ExchangeHandle exchange, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msg) { - VerifyOrReturnError(exchange != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(exchange.HasValue(), CHIP_ERROR_INVALID_ARGUMENT); // mExchangeCtxt can be nullptr if this is the first message (PBKDFParamRequest) received by PASESession // via UnsolicitedMessageHandler. The exchange context is allocated by exchange manager and provided // to the handler (PASESession object). - if (mExchangeCtxt != nullptr) + if (mExchangeCtxt.HasValue()) { if (mExchangeCtxt != exchange) { @@ -782,7 +782,7 @@ CHIP_ERROR PASESession::ValidateReceivedMessage(ExchangeContext * exchange, cons return CHIP_NO_ERROR; } -void PASESession::OnMessageReceived(ExchangeContext * exchange, const PacketHeader & packetHeader, +void PASESession::OnMessageReceived(ExchangeHandle exchange, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msg) { CHIP_ERROR err = ValidateReceivedMessage(exchange, packetHeader, payloadHeader, std::move(msg)); diff --git a/src/protocols/secure_channel/PASESession.h b/src/protocols/secure_channel/PASESession.h index c9781040e52ac5..1c9cb2fca1b059 100644 --- a/src/protocols/secure_channel/PASESession.h +++ b/src/protocols/secure_channel/PASESession.h @@ -123,7 +123,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin * @return CHIP_ERROR The result of initialization */ CHIP_ERROR Pair(const Transport::PeerAddress peerAddress, uint32_t peerSetUpPINCode, uint16_t myKeyId, - Messaging::ExchangeContext * exchangeCtxt, SessionEstablishmentDelegate * delegate); + Messaging::ExchangeHandle exchangeCtxt, SessionEstablishmentDelegate * delegate); /** * @brief @@ -216,7 +216,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin * @param[in] payloadHeader A reference to the PayloadHeader object. * @param[in] payload A handle to the PacketBuffer object holding the message payload. */ - void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(Messaging::ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload) override; /** @@ -226,7 +226,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin * * @param[in] ec A pointer to the ExchangeContext object. */ - void OnResponseTimeout(Messaging::ExchangeContext * ec) override; + void OnResponseTimeout(Messaging::ExchangeHandle ec) override; Messaging::ExchangeMessageDispatch * GetMessageDispatch(Messaging::ReliableMessageMgr * rmMgr, SecureSessionMgr * sessionMgr) override @@ -243,7 +243,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin CHIP_ERROR Init(uint16_t myKeyId, uint32_t setupCode, SessionEstablishmentDelegate * delegate); - CHIP_ERROR ValidateReceivedMessage(Messaging::ExchangeContext * exchange, const PacketHeader & packetHeader, + CHIP_ERROR ValidateReceivedMessage(Messaging::ExchangeHandle exchange, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msg); static CHIP_ERROR ComputePASEVerifier(uint32_t mySetUpPINCode, uint32_t pbkdf2IterCount, const uint8_t * salt, size_t saltLen, @@ -291,7 +291,7 @@ class DLL_EXPORT PASESession : public Messaging::ExchangeDelegate, public Pairin uint16_t mSaltLength = 0; uint8_t * mSalt = nullptr; - Messaging::ExchangeContext * mExchangeCtxt = nullptr; + Messaging::ExchangeHandle mExchangeCtxt; SessionEstablishmentExchangeDispatch mMessageDispatch; diff --git a/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.cpp b/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.cpp index e0b38323325c2b..f88bf272453d75 100644 --- a/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.cpp +++ b/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.cpp @@ -47,10 +47,10 @@ CHIP_ERROR SessionEstablishmentExchangeDispatch::SendMessageImpl(SecureSessionHa CHIP_ERROR SessionEstablishmentExchangeDispatch::OnMessageReceived(const PayloadHeader & payloadHeader, uint32_t messageId, const Transport::PeerAddress & peerAddress, - ReliableMessageContext * reliableMessageContext) + ExchangeHandle exchangeContext) { mPeerAddress = peerAddress; - return ExchangeMessageDispatch::OnMessageReceived(payloadHeader, messageId, peerAddress, reliableMessageContext); + return ExchangeMessageDispatch::OnMessageReceived(payloadHeader, messageId, peerAddress, exchangeContext); } bool SessionEstablishmentExchangeDispatch::MessagePermitted(uint16_t protocol, uint8_t type) diff --git a/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.h b/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.h index b222d7b318ab7b..4ed96cb67b547a 100644 --- a/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.h +++ b/src/protocols/secure_channel/SessionEstablishmentExchangeDispatch.h @@ -45,7 +45,7 @@ class SessionEstablishmentExchangeDispatch : public Messaging::ExchangeMessageDi CHIP_ERROR OnMessageReceived(const PayloadHeader & payloadHeader, uint32_t messageId, const Transport::PeerAddress & peerAddress, - Messaging::ReliableMessageContext * reliableMessageContext) override; + Messaging::ExchangeHandle exchangeContext) override; const Transport::PeerAddress & GetPeerAddress() const { return mPeerAddress; } diff --git a/src/protocols/secure_channel/tests/TestCASESession.cpp b/src/protocols/secure_channel/tests/TestCASESession.cpp index 57d5b6f41a4b48..a7a51c40d8e2b1 100644 --- a/src/protocols/secure_channel/tests/TestCASESession.cpp +++ b/src/protocols/secure_channel/tests/TestCASESession.cpp @@ -121,10 +121,10 @@ void CASE_SecurePairingStartTest(nlTestSuite * inSuite, void * inContext) CASESession pairing; NL_TEST_ASSERT(inSuite, pairing.MessageDispatch().Init(&gTransportMgr) == CHIP_NO_ERROR); - ExchangeContext * context = ctx.NewExchangeToLocal(&pairing); + ExchangeHandle context = ctx.NewExchangeToLocal(&pairing); NL_TEST_ASSERT(inSuite, - pairing.EstablishSession(Transport::PeerAddress(Transport::Type::kBle), &commissionerDevOpCred, 2, 0, nullptr, + pairing.EstablishSession(Transport::PeerAddress(Transport::Type::kBle), &commissionerDevOpCred, 2, 0, ExchangeHandle(), nullptr) != CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, pairing.EstablishSession(Transport::PeerAddress(Transport::Type::kBle), &commissionerDevOpCred, 2, 0, context, @@ -139,7 +139,7 @@ void CASE_SecurePairingStartTest(nlTestSuite * inSuite, void * inContext) gLoopback.mSentMessageCount = 0; gLoopback.mMessageSendError = CHIP_ERROR_BAD_REQUEST; - ExchangeContext * context1 = ctx.NewExchangeToLocal(&pairing1); + ExchangeHandle context1 = ctx.NewExchangeToLocal(&pairing1); NL_TEST_ASSERT(inSuite, pairing1.EstablishSession(Transport::PeerAddress(Transport::Type::kBle), &commissionerDevOpCred, 2, 0, context1, @@ -166,7 +166,7 @@ void CASE_SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inConte ctx.GetExchangeManager().RegisterUnsolicitedMessageHandlerForType( Protocols::SecureChannel::MsgType::CASE_SigmaR1, &pairingAccessory) == CHIP_NO_ERROR); - ExchangeContext * contextCommissioner = ctx.NewExchangeToLocal(&pairingCommissioner); + ExchangeHandle contextCommissioner = ctx.NewExchangeToLocal(&pairingCommissioner); NL_TEST_ASSERT(inSuite, pairingAccessory.ListenForSessionEstablishment(&accessoryDevOpCred, 0, &delegateAccessory) == CHIP_NO_ERROR); diff --git a/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp b/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp index 3010fd3a8237a1..aa16aa8567d2cd 100644 --- a/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp +++ b/src/protocols/secure_channel/tests/TestMessageCounterManager.cpp @@ -73,14 +73,14 @@ const char PAYLOAD[] = "Hello!"; class MockAppDelegate : public ExchangeDelegate { public: - void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && msgBuf) override { ++ReceiveHandlerCallCount; ec->Close(); } - void OnResponseTimeout(ExchangeContext * ec) override {} + void OnResponseTimeout(ExchangeHandle ec) override {} int ReceiveHandlerCallCount = 0; }; @@ -123,8 +123,8 @@ void CheckReceiveMessage(nlTestSuite * inSuite, void * inContext) System::PacketBufferHandle msgBuf = MessagePacketBuffer::NewWithData(PAYLOAD, payload_len); NL_TEST_ASSERT(inSuite, !msgBuf.IsNull()); - Messaging::ExchangeContext * ec = ctx.NewExchangeToPeer(nullptr); - NL_TEST_ASSERT(inSuite, ec != nullptr); + Messaging::ExchangeHandle ec = ctx.NewExchangeToPeer(nullptr); + NL_TEST_ASSERT(inSuite, ec.HasValue()); err = ec->SendMessage(chip::Protocols::Echo::MsgType::EchoRequest, std::move(msgBuf), Messaging::SendFlags{ Messaging::SendMessageFlags::kNoAutoRequestAck }); diff --git a/src/protocols/secure_channel/tests/TestPASESession.cpp b/src/protocols/secure_channel/tests/TestPASESession.cpp index e58b57ad24a958..41a13ecaa30221 100644 --- a/src/protocols/secure_channel/tests/TestPASESession.cpp +++ b/src/protocols/secure_channel/tests/TestPASESession.cpp @@ -76,13 +76,13 @@ class TestSecurePairingDelegate : public SessionEstablishmentDelegate class MockAppDelegate : public ExchangeDelegate { public: - void OnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, + void OnMessageReceived(ExchangeHandle ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader, System::PacketBufferHandle && buffer) override { ec->Close(); } - void OnResponseTimeout(ExchangeContext * ec) override {} + void OnResponseTimeout(ExchangeHandle ec) override {} }; void SecurePairingWaitTest(nlTestSuite * inSuite, void * inContext) @@ -107,10 +107,10 @@ void SecurePairingStartTest(nlTestSuite * inSuite, void * inContext) PASESession pairing; NL_TEST_ASSERT(inSuite, pairing.MessageDispatch().Init(&gTransportMgr) == CHIP_NO_ERROR); - ExchangeContext * context = ctx.NewExchangeToLocal(&pairing); + ExchangeHandle context = ctx.NewExchangeToLocal(&pairing); NL_TEST_ASSERT(inSuite, - pairing.Pair(Transport::PeerAddress(Transport::Type::kBle), 1234, 0, nullptr, nullptr) != CHIP_NO_ERROR); + pairing.Pair(Transport::PeerAddress(Transport::Type::kBle), 1234, 0, ExchangeHandle(), nullptr) != CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, pairing.Pair(Transport::PeerAddress(Transport::Type::kBle), 1234, 0, context, &delegate) == CHIP_NO_ERROR); @@ -121,7 +121,7 @@ void SecurePairingStartTest(nlTestSuite * inSuite, void * inContext) PASESession pairing1; NL_TEST_ASSERT(inSuite, pairing1.MessageDispatch().Init(&gTransportMgr) == CHIP_NO_ERROR); - ExchangeContext * context1 = ctx.NewExchangeToLocal(&pairing1); + ExchangeHandle context1 = ctx.NewExchangeToLocal(&pairing1); NL_TEST_ASSERT(inSuite, pairing1.Pair(Transport::PeerAddress(Transport::Type::kBle), 1234, 0, context1, &delegate) == CHIP_ERROR_BAD_REQUEST); @@ -145,7 +145,7 @@ void SecurePairingHandshakeTestCommon(nlTestSuite * inSuite, void * inContext, P ctx.GetExchangeManager().RegisterUnsolicitedMessageHandlerForType( Protocols::SecureChannel::MsgType::PBKDFParamRequest, &pairingAccessory) == CHIP_NO_ERROR); - ExchangeContext * contextCommissioner = ctx.NewExchangeToLocal(&pairingCommissioner); + ExchangeHandle contextCommissioner = ctx.NewExchangeToLocal(&pairingCommissioner); NL_TEST_ASSERT(inSuite, pairingAccessory.WaitForPairing(1234, 500, (const uint8_t *) "saltSALT", 8, 0, &delegateAccessory) == diff --git a/src/transport/SecureSessionMgr.h b/src/transport/SecureSessionMgr.h index a716a408c6936a..413b2ce8abd8c3 100644 --- a/src/transport/SecureSessionMgr.h +++ b/src/transport/SecureSessionMgr.h @@ -63,6 +63,8 @@ class EncryptedPacketBufferHandle final : private System::PacketBufferHandle uint32_t GetMsgId() const; + bool IsNull() { return System::PacketBufferHandle::IsNull(); } + /** * Creates a copy of the data in this packet. *