Skip to content

Commit

Permalink
[chip-tool] Add flag to enable server interactions
Browse files Browse the repository at this point in the history
Add "--advertise-operational" flag to the chip-tool's
"interactive start" command that enables server features,
including advertising operational services. This feature
is needed to test persistent subscriptions using chip-tool,
which requires that chip-tool be discoverable after the
publisher node reboots.
  • Loading branch information
Damian-Nordic committed Jan 27, 2023
1 parent 42d0ac8 commit f5678d1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/chip-tool/commands/common/CHIPCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ CHIP_ERROR CHIPCommand::MaybeSetUpStack()
factoryInitParams.fabricIndependentStorage = &mDefaultStorage;
factoryInitParams.operationalKeystore = &mOperationalKeystore;
factoryInitParams.opCertStore = &mOpCertStore;
factoryInitParams.enableServerInteractions = NeedsOperationalAdvertising();

// Init group data provider that will be used for all group keys and IPKs for the
// chip-tool-configured fabrics. This is OK to do once since the fabric tables
Expand Down
5 changes: 5 additions & 0 deletions examples/chip-tool/commands/common/CHIPCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class CHIPCommand : public Command
// use member values that Shutdown will normally reset.
virtual bool DeferInteractiveCleanup() { return false; }

// If true, the controller will be created with server capabilities enabled,
// such as advertising operational nodes over DNS-SD and accepting incoming
// CASE sessions.
virtual bool NeedsOperationalAdvertising() { return false; }

// Execute any deferred cleanups. Used when exiting interactive mode.
static void ExecuteDeferredCleanups(intptr_t ignored);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ CHIP_ERROR InteractiveStartCommand::RunCommand()
return CHIP_NO_ERROR;
}

bool InteractiveStartCommand::NeedsOperationalAdvertising()
{
return mAdvertiseOperational.ValueOr(true);
}

bool InteractiveCommand::ParseCommand(char * command, int * status)
{
if (strcmp(command, kInteractiveModeStopCommand) == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ class InteractiveStartCommand : public InteractiveCommand
public:
InteractiveStartCommand(Commands * commandsHandler, CredentialIssuerCommands * credsIssuerConfig) :
InteractiveCommand("start", commandsHandler, credsIssuerConfig)
{}
{
AddArgument("advertise-operational", 0, 1, &mAdvertiseOperational);
}

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
bool NeedsOperationalAdvertising() override;

private:
chip::Optional<bool> mAdvertiseOperational;
};

class InteractiveServerCommand : public InteractiveCommand, public WebSocketServerDelegate, public RemoteDataModelLoggerDelegate
Expand Down

0 comments on commit f5678d1

Please sign in to comment.