Skip to content

Commit

Permalink
[controller] Update IM delegate after project-chip#6802
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed May 21, 2021
1 parent 7dbc566 commit d2fb25f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,17 +1455,15 @@ CHIP_ERROR DeviceControllerInteractionModelDelegate::CommandResponseStatus(
const uint32_t aProtocolId, const uint16_t aProtocolCode, chip::EndpointId aEndpointId, const chip::ClusterId aClusterId,
chip::CommandId aCommandId, uint8_t aCommandIndex)
{
// #6308, #6559: Invoking success Callbacks in `CommandResponseProcessed` is not desired, but this is used to met current
// requirement of current callback framework that we should be able to send another command once ResponseCallback is called. By
// resolving #6308, the app can wait for the right event, and by #6559 the app can send command in a now command sender.
VerifyOrReturnError(aProtocolCode != 0, CHIP_NO_ERROR);

// Generally IM has more detailed errors than ember library, here we always use the, the actual handling of the
// commands should implement full IMDelegate.
// #6308 By implement app side IM delegate, we should be able to accept detailed error codes.
// Note: The IMDefaultResponseCallback is a bridge to the old CallbackMgr before IM is landed, so it still accepts EmberAfStatus
// instead of IM status code.
IMDefaultResponseCallback(apCommandSender, EMBER_ZCL_STATUS_FAILURE);
IMDefaultResponseCallback(apCommandSender,
(aGeneralCode == Protocols::SecureChannel::GeneralStatusCode::kSuccess && aProtocolCode == 0)
? EMBER_ZCL_STATUS_SUCCESS
: EMBER_ZCL_STATUS_FAILURE);

return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -1501,7 +1499,7 @@ CHIP_ERROR DeviceControllerInteractionModelDelegate::CommandResponseProcessed(co
// #6308, #6559: Invoking Callbacks in `CommandResponseProcessed` is not desired, but this is used to met current requirement of
// current callback framework that we should be able to send another command once ResponseCallback is called.
// By resolving #6308, the app can wait for the right event, and by #6559 the app can send command in a now command sender.
IMDefaultResponseCallback(apCommandSender, EMBER_ZCL_STATUS_SUCCESS);
// This callback is left blank, since the above function should handled all possible cases.

return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit d2fb25f

Please sign in to comment.