Skip to content

Commit

Permalink
[Controller] Update CHIPController to use the Invoke API instead of r… (
Browse files Browse the repository at this point in the history
#13371)

* Convert OpenPairingWindow

* Convert CertificateChainRequest

* Convert AttestationRequest

* Convert OpCSRRequest

* Convert AddNOC

* Convert AddTrustedRootCertificate

* Convert mSuccess and mFailure

* Convert CreateBindingWithCallback
  • Loading branch information
vivien-apple authored and pull[bot] committed Nov 16, 2023
1 parent b19b076 commit 4227187
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 208 deletions.
18 changes: 6 additions & 12 deletions examples/platform/linux/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<DefaultSuccessCallback> mSuccessCallback;
Callback::Callback<DefaultFailureCallback> mFailureCallback;
static void OnFailureResponse(void * context, CHIP_ERROR error);
};

PairingCommand gPairingCommand;
Expand Down Expand Up @@ -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");
}
Expand All @@ -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
{
Expand Down
Loading

0 comments on commit 4227187

Please sign in to comment.