-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SetUpCodePairer] Add an API to list the discovered devices if any
- Loading branch information
1 parent
d6a783e
commit 8fa70f1
Showing
15 changed files
with
218 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
examples/chip-tool/commands/pairing/DiscoverDevicesCommand.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#include "DiscoverDevicesCommand.h" | ||
|
||
using namespace chip; | ||
|
||
CHIP_ERROR DiscoverDevicesCommand::RunCommand() | ||
{ | ||
return CurrentCommissioner().DiscoverDevices(this); | ||
} | ||
|
||
void DiscoverDevicesCommand::OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) | ||
{ | ||
auto discriminator = nodeData.commissionData.longDiscriminator; | ||
auto vendorId = static_cast<chip::VendorId>(nodeData.commissionData.vendorId); | ||
auto productId = nodeData.commissionData.productId; | ||
|
||
ChipLogDetail(chipTool, "IP:: OnDeviceDiscovered: discriminator: %u, vendorId: %u, productId: %u", discriminator, vendorId, | ||
productId); | ||
|
||
nodeData.LogDetail(); | ||
} | ||
|
||
#if CHIP_DEVICE_LAYER_TARGET_DARWIN | ||
void DiscoverDevicesCommand::OnNodeDiscovered(uint16_t discriminator, chip::VendorId vendorId, uint16_t productId) | ||
{ | ||
ChipLogDetail(chipTool, "BLE:: OnDeviceDiscovered: discriminator: %u, vendorId: %u, productId: %u", discriminator, vendorId, | ||
productId); | ||
} | ||
#endif // CHIP_DEVICE_LAYER_TARGET_DARWIN |
37 changes: 37 additions & 0 deletions
37
examples/chip-tool/commands/pairing/DiscoverDevicesCommand.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "../common/CHIPCommand.h" | ||
|
||
class DiscoverDevicesCommand : public CHIPCommand, public chip::Controller::SetUpCodePairerDiscoveryDelegate | ||
{ | ||
public: | ||
DiscoverDevicesCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("discover", credIssuerCommands) {} | ||
|
||
/////////// CHIPCommand Interface ///////// | ||
CHIP_ERROR RunCommand() override; | ||
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(120); } | ||
|
||
/////////// DiscoverCommissionablesDelegate Interface ///////// | ||
void OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) override; | ||
#if CHIP_DEVICE_LAYER_TARGET_DARWIN | ||
void OnNodeDiscovered(uint16_t discriminator, chip::VendorId vendorId, uint16_t productId) override; | ||
#endif // CHIP_DEVICE_LAYER_TARGET_DARWIN | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.