Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle Use ephemeral ports for chip-tool by default. #16453

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ CHIP_ERROR CHIPCommand::Run()

chip::Controller::FactoryInitParams factoryInitParams;
factoryInitParams.fabricIndependentStorage = &mDefaultStorage;
factoryInitParams.listenPort = static_cast<uint16_t>(mDefaultStorage.GetListenPort() + CurrentCommissionerId());
uint16_t port = mDefaultStorage.GetListenPort();
if (port != 0)
{
// Make sure different commissioners run on different ports.
port += CurrentCommissionerId();
}
factoryInitParams.listenPort = port;
ReturnLogErrorOnFailure(DeviceControllerFactory::GetInstance().Init(factoryInitParams));

// TODO(issue #15209): Replace this trust store with file-based trust store
Expand Down
5 changes: 2 additions & 3 deletions examples/chip-tool/config/PersistentStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ uint16_t PersistentStorage::GetListenPort()
{
CHIP_ERROR err = CHIP_NO_ERROR;

// By default chip-tool listens on CHIP_PORT + 1. This is done in order to avoid
// having 2 servers listening on CHIP_PORT when one runs an accessory server locally.
uint16_t chipListenPort = static_cast<uint16_t>(CHIP_PORT + 1);
// By default chip-tool listens on an ephemeral port.
uint16_t chipListenPort = 0;

char value[6];
uint16_t size = static_cast<uint16_t>(sizeof(value));
Expand Down