Skip to content

Commit

Permalink
Remove DeviceAddressUpdateDelegate and corresponding chip-tool discov…
Browse files Browse the repository at this point in the history
…ery update (#15865)

* Remove DeviceAddressUpdateDelegate and corresponding chip-tool discovery update

* Restyle
  • Loading branch information
andy31415 authored Mar 7, 2022
1 parent 999aeae commit 474cc20
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 88 deletions.
31 changes: 0 additions & 31 deletions examples/chip-tool/commands/discover/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "DiscoverCommand.h"
#include "DiscoverCommissionablesCommand.h"
#include "DiscoverCommissionersCommand.h"
#include <controller/DeviceAddressUpdateDelegate.h>
#include <lib/address_resolve/AddressResolve.h>

class Resolve : public DiscoverCommand, public chip::AddressResolve::NodeListener
Expand Down Expand Up @@ -65,42 +64,12 @@ class Resolve : public DiscoverCommand, public chip::AddressResolve::NodeListene
chip::AddressResolve::NodeLookupHandle mNodeLookupHandle;
};

class Update : public DiscoverCommand
{
public:
Update(CredentialIssuerCommands * credsIssuerConfig) : DiscoverCommand("update", credsIssuerConfig) {}

/////////// DiscoverCommand Interface /////////
CHIP_ERROR RunCommand(NodeId remoteId, uint64_t fabricId) override
{
ChipLogProgress(chipTool, "Mdns: Updating NodeId: %" PRIx64 " Compressed FabricId: %" PRIx64 " ...", remoteId,
CurrentCommissioner().GetCompressedFabricId());
return CurrentCommissioner().UpdateDevice(remoteId);
}

/////////// DeviceAddressUpdateDelegate Interface /////////
void OnAddressUpdateComplete(NodeId nodeId, CHIP_ERROR error) override
{
if (CHIP_NO_ERROR == error)
{
ChipLogProgress(chipTool, "Device address updated successfully");
}
else
{
ChipLogError(chipTool, "Failed to update the device address: %s", chip::ErrorStr(error));
}

SetCommandExitStatus(error);
}
};

void registerCommandsDiscover(Commands & commands, CredentialIssuerCommands * credsIssuerConfig)
{
const char * clusterName = "Discover";

commands_list clusterCommands = {
make_unique<Resolve>(credsIssuerConfig),
make_unique<Update>(credsIssuerConfig),
make_unique<DiscoverCommissionablesCommand>(credsIssuerConfig),
make_unique<DiscoverCommissionersCommand>(credsIssuerConfig),
};
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/discover/DiscoverCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@

CHIP_ERROR DiscoverCommand::RunCommand()
{
CurrentCommissioner().RegisterDeviceAddressUpdateDelegate(this);
return RunCommand(mNodeId, mFabricId);
}
5 changes: 1 addition & 4 deletions examples/chip-tool/commands/discover/DiscoverCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "../../config/PersistentStorage.h"
#include "../common/CHIPCommand.h"

class DiscoverCommand : public CHIPCommand, public chip::Controller::DeviceAddressUpdateDelegate
class DiscoverCommand : public CHIPCommand
{
public:
DiscoverCommand(const char * commandName, CredentialIssuerCommands * credsIssuerConfig) :
Expand All @@ -31,9 +31,6 @@ class DiscoverCommand : public CHIPCommand, public chip::Controller::DeviceAddre
AddArgument("fabricid", 0, UINT64_MAX, &mFabricId);
}

/////////// DeviceAddressUpdateDelegate Interface /////////
void OnAddressUpdateComplete(NodeId nodeId, CHIP_ERROR error) override{};

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(30); }
Expand Down
1 change: 0 additions & 1 deletion src/controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static_library("controller") {
"CommissioneeDeviceProxy.h",
"CommissionerDiscoveryController.cpp",
"CommissionerDiscoveryController.h",
"DeviceAddressUpdateDelegate.h",
"DeviceDiscoveryDelegate.h",
"EmptyDataModelHandler.cpp",
"ExampleOperationalCredentialsIssuer.cpp",
Expand Down
12 changes: 1 addition & 11 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ CHIP_ERROR DeviceController::Shutdown()
mSystemState = nullptr;

mDNSResolver.Shutdown();
mDeviceAddressUpdateDelegate = nullptr;
mDeviceDiscoveryDelegate = nullptr;
mDeviceDiscoveryDelegate = nullptr;

chip::Platform::Delete(mCASESessionManager);
mCASESessionManager = nullptr;
Expand Down Expand Up @@ -565,10 +564,6 @@ void DeviceController::OnOperationalNodeResolved(const chip::Dnssd::ResolvedNode
VerifyOrReturn(mState == State::Initialized,
ChipLogError(Controller, "OnOperationalNodeResolved was called in incorrect state"));
mCASESessionManager->OnOperationalNodeResolved(nodeData);
if (mDeviceAddressUpdateDelegate != nullptr)
{
mDeviceAddressUpdateDelegate->OnAddressUpdateComplete(nodeData.mPeerId.GetNodeId(), CHIP_NO_ERROR);
}
}

void DeviceController::OnOperationalNodeResolutionFailed(const chip::PeerId & peer, CHIP_ERROR error)
Expand All @@ -577,11 +572,6 @@ void DeviceController::OnOperationalNodeResolutionFailed(const chip::PeerId & pe
VerifyOrReturn(mState == State::Initialized,
ChipLogError(Controller, "OnOperationalNodeResolutionFailed was called in incorrect state"));
mCASESessionManager->OnOperationalNodeResolutionFailed(peer, error);

if (mDeviceAddressUpdateDelegate != nullptr)
{
mDeviceAddressUpdateDelegate->OnAddressUpdateComplete(peer.GetNodeId(), error);
}
}

ControllerDeviceInitParams DeviceController::GetControllerDeviceInitParams()
Expand Down
5 changes: 1 addition & 4 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
#if CONFIG_NETWORK_LAYER_BLE
#include <ble/BleLayer.h>
#endif
#include <controller/DeviceAddressUpdateDelegate.h>
#include <controller/DeviceDiscoveryDelegate.h>
#include <lib/dnssd/Resolver.h>
#include <lib/dnssd/ResolverProxy.h>
Expand Down Expand Up @@ -307,7 +306,6 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate,
Callback::Callback<OnOpenCommissioningWindow> * callback,
bool readVIDPIDAttributes = false);

void RegisterDeviceAddressUpdateDelegate(DeviceAddressUpdateDelegate * delegate) { mDeviceAddressUpdateDelegate = delegate; }
void RegisterDeviceDiscoveryDelegate(DeviceDiscoveryDelegate * delegate) { mDeviceDiscoveryDelegate = delegate; }

/**
Expand Down Expand Up @@ -358,8 +356,7 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate,
FabricId mFabricId = kUndefinedFabricId;
FabricInfo * mFabricInfo = nullptr;

PersistentStorageDelegate * mStorageDelegate = nullptr;
DeviceAddressUpdateDelegate * mDeviceAddressUpdateDelegate = nullptr;
PersistentStorageDelegate * mStorageDelegate = nullptr;
// TODO(cecille): Make this configuarable.
static constexpr int kMaxCommissionableNodes = 10;
Dnssd::DiscoveredNodeData mCommissionableNodes[kMaxCommissionableNodes];
Expand Down
36 changes: 0 additions & 36 deletions src/controller/DeviceAddressUpdateDelegate.h

This file was deleted.

0 comments on commit 474cc20

Please sign in to comment.