Skip to content

Commit

Permalink
CI build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecenzo committed Jul 9, 2021
1 parent 1354fd0 commit 32f829a
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 84 deletions.
3 changes: 2 additions & 1 deletion examples/platform/linux/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
#include <support/RandUtils.h>

#if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
#include <ControllerShellCommands.h>
#include <controller/CHIPDeviceController.h>
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <controller/ShellCommands.h>
#include <core/CHIPPersistentStorageDelegate.h>
#include <platform/KeyValueStoreManager.h>
#endif

#if defined(ENABLE_CHIP_SHELL)
#include <CommissioneeShellCommands.h>
#include <lib/shell/Engine.h>
#endif

Expand Down
4 changes: 4 additions & 0 deletions examples/platform/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ source_set("app-main") {
sources = [
"AppMain.cpp",
"AppMain.h",
"CommissioneeShellCommands.cpp",
"CommissioneeShellCommands.h",
"ControllerShellCommands.cpp",
"ControllerShellCommands.h",
"Options.cpp",
"Options.h",
]
Expand Down
98 changes: 98 additions & 0 deletions examples/platform/linux/CommissioneeShellCommands.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
*
* 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 <CommissioneeShellCommands.h>
#include <inttypes.h>
#include <lib/core/CHIPCore.h>
#include <lib/shell/Commands.h>
#include <lib/shell/Engine.h>
#include <lib/shell/commands/Help.h>
#include <lib/support/CHIPArgParser.hpp>
#include <lib/support/CHIPMem.h>
#include <lib/support/CodeUtils.h>
#include <platform/CHIPDeviceLayer.h>
#include <protocols/user_directed_commissioning/UserDirectedCommissioning.h>

namespace chip {
namespace Shell {

#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
static CHIP_ERROR SendUDC(bool printHeader, chip::Inet::IPAddress commissioner)
{
streamer_t * sout = streamer_get();

if (printHeader)
{
streamer_printf(sout, "SendUDC: ");
}

SendUserDirectedCommissioningRequest(commissioner, CHIP_PORT + 3);

streamer_printf(sout, "done\r\n");

return CHIP_NO_ERROR;
}
#endif

static int PrintAllCommands()
{
streamer_t * sout = streamer_get();
streamer_printf(sout, " help Usage: commissionee <subcommand>\r\n");
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
streamer_printf(sout, " sendudc <address> Send UDC message to address. Usage: commissionee sendudc 127.0.0.1\r\n");
#endif
streamer_printf(sout, "\r\n");

return CHIP_NO_ERROR;
}

static CHIP_ERROR CommissioneeHandler(int argc, char ** argv)
{
CHIP_ERROR error = CHIP_NO_ERROR;

if (argc == 0 || strcmp(argv[0], "help") == 0)
{
return PrintAllCommands();
}
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
else if (strcmp(argv[0], "sendudc") == 0)
{
chip::Inet::IPAddress commissioner;
chip::Inet::IPAddress::FromString(argv[1], commissioner);
return error = SendUDC(true, commissioner);
}
#endif
else
{
return CHIP_ERROR_INVALID_ARGUMENT;
}
return error;
}

void RegisterCommissioneeCommands()
{

static const shell_command_t sDeviceComand = { &CommissioneeHandler, "commissionee",
"Commissionee commands. Usage: commissionee [command_name]" };

// Register the root `device` command with the top-level shell.
Engine::Root().RegisterCommands(&sDeviceComand, 1);
return;
}

} // namespace Shell
} // namespace chip
33 changes: 33 additions & 0 deletions examples/platform/linux/CommissioneeShellCommands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
*
* Copyright (c) 2020 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.
*/

/**
* @file
* This file contains definitions for Device class. The objects of this
* class will be used by Controller applications to interact with CHIP
* devices. The class provides mechanism to construct, send and receive
* messages to and from the corresponding CHIP devices.
*/

namespace chip {
namespace Shell {

void RegisterCommissioneeCommands();

} // namespace Shell
} // namespace chip
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

#include <controller/ShellCommands.h>
#include <ControllerShellCommands.h>
#include <inttypes.h>
#include <lib/core/CHIPCore.h>
#include <lib/shell/Commands.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ namespace Shell {
void RegisterDiscoverCommands(chip::Controller::DeviceCommissioner * commissioner);

} // namespace Shell
} // namespace chip
} // namespace chip
74 changes: 0 additions & 74 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
#include <app/server/Mdns.h>
#endif

#include <lib/shell/Commands.h>
#include <lib/shell/Engine.h>
#include <lib/shell/commands/Help.h>

using namespace ::chip;
using namespace ::chip::Inet;
using namespace ::chip::Transport;
Expand Down Expand Up @@ -677,73 +673,3 @@ CHIP_ERROR ResetUDCStates()
return CHIP_NO_ERROR;
}
#endif

namespace chip {
namespace Shell {

#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
static CHIP_ERROR SendUDC(bool printHeader, chip::Inet::IPAddress commissioner)
{
streamer_t * sout = streamer_get();

if (printHeader)
{
streamer_printf(sout, "SendUDC: ");
}

SendUserDirectedCommissioningRequest(commissioner, CHIP_PORT + 3);

streamer_printf(sout, "done\r\n");

return CHIP_NO_ERROR;
}
#endif

static int PrintAllCommands()
{
streamer_t * sout = streamer_get();
streamer_printf(sout, " help Usage: commissionee <subcommand>\r\n");
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
streamer_printf(sout, " sendudc <address> Send UDC message to address. Usage: commissionee sendudc 127.0.0.1\r\n");
#endif
streamer_printf(sout, "\r\n");

return CHIP_NO_ERROR;
}

static CHIP_ERROR CommissioneeHandler(int argc, char ** argv)
{
CHIP_ERROR error = CHIP_NO_ERROR;

if (argc == 0 || strcmp(argv[0], "help") == 0)
{
return PrintAllCommands();
}
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT
else if (strcmp(argv[0], "sendudc") == 0)
{
chip::Inet::IPAddress commissioner;
chip::Inet::IPAddress::FromString(argv[1], commissioner);
return error = SendUDC(true, commissioner);
}
#endif
else
{
return CHIP_ERROR_INVALID_ARGUMENT;
}
return error;
}

void RegisterCommissioneeCommands()
{

static const shell_command_t sDeviceComand = { &CommissioneeHandler, "commissionee",
"Commissionee commands. Usage: commissionee [command_name]" };

// Register the root `device` command with the top-level shell.
Engine::Root().RegisterCommands(&sDeviceComand, 1);
return;
}

} // namespace Shell
} // namespace chip
5 changes: 0 additions & 5 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ enum class PairingWindowAdvertisement
kMdns,
};

namespace Shell {

void RegisterCommissioneeCommands();

} // namespace Shell
} // namespace chip

/**
Expand Down
2 changes: 0 additions & 2 deletions src/controller/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ static_library("controller") {
"EmptyDataModelHandler.cpp",
"ExampleOperationalCredentialsIssuer.cpp",
"ExampleOperationalCredentialsIssuer.h",
"ShellCommands.cpp",
"ShellCommands.h",
"data_model/gen/chip-zcl-zpro-codec-api.h",
]

Expand Down

0 comments on commit 32f829a

Please sign in to comment.