Skip to content

Commit

Permalink
Revert "Adding request-commissioning CHIPTool command (#7729)" (#8095)
Browse files Browse the repository at this point in the history
This reverts commit 355a991.
  • Loading branch information
mspang authored and pull[bot] committed Sep 21, 2021
1 parent 512c9e2 commit 1274450
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 130 deletions.
1 change: 0 additions & 1 deletion examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ executable("chip-tool") {
"commands/discover/DiscoverCommand.cpp",
"commands/discover/DiscoverCommissionersCommand.cpp",
"commands/pairing/PairingCommand.cpp",
"commands/pairing/RequestCommissioningCommand.cpp",
"commands/payload/AdditionalDataParseCommand.cpp",
"commands/payload/SetupPayloadParseCommand.cpp",
"commands/reporting/ReportingCommand.cpp",
Expand Down
8 changes: 3 additions & 5 deletions examples/chip-tool/commands/pairing/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include "PairingCommand.h"
#include "RequestCommissioningCommand.h"

class Unpair : public PairingCommand
{
public:
Expand Down Expand Up @@ -67,10 +67,8 @@ void registerCommandsPairing(Commands & commands)
const char * clusterName = "Pairing";

commands_list clusterCommands = {
make_unique<Unpair>(), make_unique<PairBypass>(),
make_unique<PairBleWiFi>(), make_unique<PairBleThread>(),
make_unique<PairSoftAP>(), make_unique<Ethernet>(),
make_unique<PairOnNetwork>(), make_unique<RequestCommissioningCommand>(),
make_unique<Unpair>(), make_unique<PairBypass>(), make_unique<PairBleWiFi>(), make_unique<PairBleThread>(),
make_unique<PairSoftAP>(), make_unique<Ethernet>(), make_unique<PairOnNetwork>(),
};

commands.Register(clusterName, clusterCommands);
Expand Down

This file was deleted.

42 changes: 0 additions & 42 deletions examples/chip-tool/commands/pairing/RequestCommissioningCommand.h

This file was deleted.

41 changes: 15 additions & 26 deletions src/app/server/Mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#include <mdns/Advertiser.h>
#include <mdns/ServiceNaming.h>
#include <messaging/ReliableMessageProtocolConfig.h>
#if CONFIG_DEVICE_LAYER
#include <platform/CHIPDeviceLayer.h>
#include <platform/ConfigurationManager.h>
#endif
#include <protocols/secure_channel/PASESession.h>
#include <setup_payload/AdditionalDataPayloadGenerator.h>
#include <support/Span.h>
Expand Down Expand Up @@ -73,13 +71,11 @@ chip::ByteSpan FillMAC(uint8_t (&mac)[8])
return chip::ByteSpan(mac, 8);
}
#endif
#if CONFIG_DEVICE_LAYER
if (DeviceLayer::ConfigurationMgr().GetPrimaryWiFiMACAddress(mac) == CHIP_NO_ERROR)
{
ChipLogDetail(Discovery, "Using wifi MAC for hostname");
return chip::ByteSpan(mac, 6);
}
#endif
ChipLogError(Discovery, "Wifi mac not known. Using a default.");
uint8_t temp[6] = { 0xEE, 0xAA, 0xBA, 0xDA, 0xBA, 0xD0 };
memcpy(mac, temp, 6);
Expand All @@ -97,14 +93,13 @@ CHIP_ERROR GetCommissionableInstanceName(char * buffer, size_t bufferLen)
/// Set MDNS operational advertisement
CHIP_ERROR AdvertiseOperational()
{
uint64_t fabricId = 5544332211; // default value
uint64_t fabricId;

#if CONFIG_DEVICE_LAYER
if (DeviceLayer::ConfigurationMgr().GetFabricId(fabricId) != CHIP_NO_ERROR)
{
ChipLogError(Discovery, "Fabric ID not known. Using a default");
fabricId = 5544332211;
}
#endif

uint8_t mac[8];

Expand Down Expand Up @@ -144,16 +139,6 @@ CHIP_ERROR Advertise(bool commissionableNode)
advertiseParameters.SetCommissionAdvertiseMode(commissionableNode ? chip::Mdns::CommssionAdvertiseMode::kCommissionableNode
: chip::Mdns::CommssionAdvertiseMode::kCommissioner);

uint8_t mac[8];
advertiseParameters.SetMac(FillMAC(mac));

#if CHIP_ENABLE_ROTATING_DEVICE_ID
char rotatingDeviceIdHexBuffer[RotatingDeviceId::kHexMaxLength];
ReturnErrorOnFailure(GenerateRotatingDeviceId(rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer)));
advertiseParameters.SetRotatingId(chip::Optional<const char *>::Value(rotatingDeviceIdHexBuffer));
#endif

#if CONFIG_DEVICE_LAYER
// TODO: device can re-enter commissioning mode after being fully provisioned
// (additionalPairing == true)
bool notYetCommissioned = !DeviceLayer::ConfigurationMgr().IsFullyProvisioned();
Expand All @@ -162,6 +147,9 @@ CHIP_ERROR Advertise(bool commissionableNode)

char pairingInst[chip::Mdns::kKeyPairingInstructionMaxLength + 1];

uint8_t mac[8];
advertiseParameters.SetMac(FillMAC(mac));

uint16_t value;
if (DeviceLayer::ConfigurationMgr().GetVendorId(value) != CHIP_NO_ERROR)
{
Expand Down Expand Up @@ -201,6 +189,12 @@ CHIP_ERROR Advertise(bool commissionableNode)
advertiseParameters.SetDeviceName(chip::Optional<const char *>::Value(deviceName));
}

#if CHIP_ENABLE_ROTATING_DEVICE_ID
char rotatingDeviceIdHexBuffer[RotatingDeviceId::kHexMaxLength];
ReturnErrorOnFailure(GenerateRotatingDeviceId(rotatingDeviceIdHexBuffer, ArraySize(rotatingDeviceIdHexBuffer)));
advertiseParameters.SetRotatingId(chip::Optional<const char *>::Value(rotatingDeviceIdHexBuffer));
#endif

if (notYetCommissioned)
{
if (DeviceLayer::ConfigurationMgr().GetInitialPairingHint(value) != CHIP_NO_ERROR)
Expand Down Expand Up @@ -241,7 +235,7 @@ CHIP_ERROR Advertise(bool commissionableNode)
advertiseParameters.SetPairingInstr(chip::Optional<const char *>::Value(pairingInst));
}
}
#endif

auto & mdnsAdvertiser = chip::Mdns::ServiceAdvertiser::Instance();

ChipLogProgress(Discovery, "Advertise commission parameter vendorID=%u productID=%u discriminator=%04u/%02u",
Expand All @@ -254,9 +248,8 @@ CHIP_ERROR Advertise(bool commissionableNode)
void StartServer()
{
ChipLogProgress(Discovery, "Start dns-sd server");
CHIP_ERROR err = CHIP_NO_ERROR;
#if CONFIG_DEVICE_LAYER
err = chip::Mdns::ServiceAdvertiser::Instance().Start(&chip::DeviceLayer::InetLayer, chip::Mdns::kMdnsPort);
CHIP_ERROR err = chip::Mdns::ServiceAdvertiser::Instance().Start(&chip::DeviceLayer::InetLayer, chip::Mdns::kMdnsPort);

// TODO: advertise this only when really operational once we support both
// operational and commisioning advertising is supported.
if (DeviceLayer::ConfigurationMgr().IsFullyProvisioned())
Expand All @@ -275,7 +268,7 @@ void StartServer()
err = app::Mdns::AdvertiseCommissionableNode();
#endif
}
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY
err = app::Mdns::AdvertiseCommisioner();
#endif
Expand All @@ -294,16 +287,12 @@ CHIP_ERROR GenerateRotatingDeviceId(char rotatingDeviceIdHexBuffer[], size_t rot
uint16_t lifetimeCounter = 0;
size_t rotatingDeviceIdValueOutputSize = 0;

#if CONFIG_DEVICE_LAYER
ReturnErrorOnFailure(
chip::DeviceLayer::ConfigurationMgr().GetSerialNumber(serialNumber, sizeof(serialNumber), serialNumberSize));
ReturnErrorOnFailure(chip::DeviceLayer::ConfigurationMgr().GetLifetimeCounter(lifetimeCounter));
return AdditionalDataPayloadGenerator().generateRotatingDeviceId(lifetimeCounter, serialNumber, serialNumberSize,
rotatingDeviceIdHexBuffer, rotatingDeviceIdHexBufferSize,
rotatingDeviceIdValueOutputSize);
#else
error = CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}
#endif

Expand Down
3 changes: 0 additions & 3 deletions src/controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ static_library("controller") {
output_name = "libChipController"

sources = [
"${chip_root}/src/app/server/Mdns.cpp",
"${chip_root}/src/app/server/Mdns.h",
"${chip_root}/src/app/server/Server.h",
"AbstractMdnsDiscoveryController.cpp",
"CHIPCluster.cpp",
"CHIPCluster.h",
Expand Down
22 changes: 0 additions & 22 deletions src/controller/CHIPCommissionableNodeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
// module header, comes first
#include <controller/CHIPCommissionableNodeController.h>

#include <app/server/Mdns.h>
#if CONFIG_DEVICE_LAYER
#include <platform/CHIPDeviceLayer.h>
#endif
#include <mdns/Advertiser.h>
#include <support/CodeUtils.h>

namespace chip {
Expand All @@ -40,22 +35,5 @@ const Mdns::DiscoveredNodeData * CommissionableNodeController::GetDiscoveredComm
return GetDiscoveredNode(idx);
}

CHIP_ERROR CommissionableNodeController::AdvertiseCommissionableNode()
{
#if CONFIG_DEVICE_LAYER
ReturnErrorOnFailure(chip::Mdns::ServiceAdvertiser::Instance().Start(&chip::DeviceLayer::InetLayer, chip::Mdns::kMdnsPort));
return app::Mdns::AdvertiseCommissionableNode();
#else
return CHIP_ERROR_NOT_IMPLEMENTED;
#endif
}

CHIP_ERROR CommissionableNodeController::SendUserDirectedCommissioningRequest(chip::Inet::IPAddress commissioner, uint16_t port)
{
// TODO: integrate with Server:SendUserDirectedCommissioningRequest()
ChipLogError(Controller, "Unsupported operation CommissionableNodeController::SendUserDirectedCommissioningRequest");
return CHIP_ERROR_NOT_IMPLEMENTED;
}

} // namespace Controller
} // namespace chip
5 changes: 1 addition & 4 deletions src/controller/CHIPCommissionableNodeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <controller/AbstractMdnsDiscoveryController.h>
#include <mdns/Resolver.h>
#include <platform/CHIPDeviceConfig.h>
#include <support/logging/CHIPLogging.h>

namespace chip {
Expand Down Expand Up @@ -53,10 +54,6 @@ class DLL_EXPORT CommissionableNodeController : public AbstractMdnsDiscoveryCont
ChipLogError(Controller, "Unsupported operation CommissionableNodeController::OnNodeIdResolutionFailed");
}

CHIP_ERROR AdvertiseCommissionableNode();

CHIP_ERROR SendUserDirectedCommissioningRequest(chip::Inet::IPAddress commissioner, uint16_t port);

protected:
Mdns::DiscoveredNodeData * GetDiscoveredNodes() override { return mDiscoveredCommissioners; }

Expand Down

0 comments on commit 1274450

Please sign in to comment.