diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index ff34984ec8829c..03c44bd7d1ca5f 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -323,7 +323,7 @@ CHIP_ERROR ShutdownCommissioner() class PairingCommand : public Controller::DevicePairingDelegate, public Controller::DeviceAddressUpdateDelegate { public: - PairingCommand() : mSuccessCallback(OnSuccessResponse, this), mFailureCallback(OnFailureResponse, this){}; + PairingCommand(){}; /////////// DevicePairingDelegate Interface ///////// void OnStatusUpdate(Controller::DevicePairingDelegate::Status status) override; @@ -337,12 +337,9 @@ class PairingCommand : public Controller::DevicePairingDelegate, public Controll CHIP_ERROR UpdateNetworkAddress(); /* Callback when command results in success */ - static void OnSuccessResponse(void * context); + static void OnSuccessResponse(void * context, const chip::app::DataModel::NullObjectType &); /* Callback when command results in failure */ - static void OnFailureResponse(void * context, uint8_t status); - - Callback::Callback mSuccessCallback; - Callback::Callback mFailureCallback; + static void OnFailureResponse(void * context, CHIP_ERROR error); }; PairingCommand gPairingCommand; @@ -401,12 +398,12 @@ void PairingCommand::OnPairingDeleted(CHIP_ERROR err) } } -void PairingCommand::OnSuccessResponse(void * context) +void PairingCommand::OnSuccessResponse(void * context, const chip::app::DataModel::NullObjectType &) { ChipLogProgress(Controller, "OnSuccessResponse"); } -void PairingCommand::OnFailureResponse(void * context, uint8_t status) +void PairingCommand::OnFailureResponse(void * context, CHIP_ERROR error) { ChipLogProgress(Controller, "OnFailureResponse"); } @@ -423,15 +420,12 @@ void PairingCommand::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err) // - the cluster(s) chosen should come from the App Platform constexpr EndpointId kBindingClusterEndpoint = 0; - Callback::Cancelable * successCallback = mSuccessCallback.Cancel(); - Callback::Cancelable * failureCallback = mFailureCallback.Cancel(); - GroupId groupId = kUndefinedGroupId; EndpointId endpointId = 1; ClusterId clusterId = kInvalidClusterId; gCommissioner.CreateBindingWithCallback(nodeId, kBindingClusterEndpoint, gLocalId, groupId, endpointId, clusterId, - successCallback, failureCallback); + OnSuccessResponse, OnFailureResponse); } else { diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 15c5a4c7336623..1929ac540e385b 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -561,8 +561,8 @@ CHIP_ERROR DeviceController::OpenCommissioningWindowInternal() CHIP_ERROR DeviceController::CreateBindingWithCallback(chip::NodeId deviceId, chip::EndpointId deviceEndpointId, chip::NodeId bindingNodeId, chip::GroupId bindingGroupId, chip::EndpointId bindingEndpointId, chip::ClusterId bindingClusterId, - Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) + CommandResponseSuccessCallback successCb, + CommandResponseFailureCallback failureCb) { PeerId peerId; peerId.SetNodeId(deviceId); @@ -578,8 +578,12 @@ CHIP_ERROR DeviceController::CreateBindingWithCallback(chip::NodeId deviceId, ch chip::Controller::BindingCluster cluster; cluster.Associate(device, deviceEndpointId); - ReturnErrorOnFailure( - cluster.Bind(onSuccessCallback, onFailureCallback, bindingNodeId, bindingGroupId, bindingEndpointId, bindingClusterId)); + Binding::Commands::Bind::Type request; + request.nodeId = bindingNodeId; + request.groupId = bindingGroupId; + request.endpointId = bindingEndpointId; + request.clusterId = bindingClusterId; + ReturnErrorOnFailure(cluster.InvokeCommand(request, this, successCb, failureCb)); ChipLogDetail(Controller, "Sent Bind command request, waiting for response"); return CHIP_NO_ERROR; diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 7413d2138c4f10..14071ef388db09 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -321,10 +320,11 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate, * * @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error */ - CHIP_ERROR CreateBindingWithCallback(chip::NodeId deviceId, chip::EndpointId deviceEndpointId, chip::NodeId bindingNodeId, - chip::GroupId bindingGroupId, chip::EndpointId bindingEndpointId, - chip::ClusterId bindingClusterId, Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback); + CHIP_ERROR + CreateBindingWithCallback(chip::NodeId deviceId, chip::EndpointId deviceEndpointId, chip::NodeId bindingNodeId, + chip::GroupId bindingGroupId, chip::EndpointId bindingEndpointId, chip::ClusterId bindingClusterId, + CommandResponseSuccessCallback successCb, + CommandResponseFailureCallback failureCb); #if CHIP_DEVICE_CONFIG_ENABLE_DNSSD void RegisterDeviceAddressUpdateDelegate(DeviceAddressUpdateDelegate * delegate) { mDeviceAddressUpdateDelegate = delegate; }