From 2338568a67b9555a0928c9aa18a5c52f4df1255d Mon Sep 17 00:00:00 2001 From: Sharad Binjola <31142146+sharadb-amazon@users.noreply.github.com> Date: Thu, 11 Nov 2021 12:55:36 -0800 Subject: [PATCH] Add CHIPTool cmd to start UDC server and listen for UDC requests (#11655) --- examples/chip-tool/BUILD.gn | 1 + examples/chip-tool/args.gni | 7 ++ .../chip-tool/commands/pairing/Commands.h | 17 +++++ .../chip-tool/include/CHIPProjectAppConfig.h | 75 +++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 examples/chip-tool/include/CHIPProjectAppConfig.h diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 67551c0617e951..fa8c67c090012c 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -52,6 +52,7 @@ executable("chip-tool") { defines = [ "CONFIG_USE_SEPARATE_EVENTLOOP=${config_use_separate_eventloop}" ] deps = [ + "${chip_root}/src/app/server", "${chip_root}/src/controller/data_model", "${chip_root}/src/lib", "${chip_root}/src/platform", diff --git a/examples/chip-tool/args.gni b/examples/chip-tool/args.gni index 311ddab32d5fe5..a76f3e8996ce3c 100644 --- a/examples/chip-tool/args.gni +++ b/examples/chip-tool/args.gni @@ -15,3 +15,10 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") + +chip_device_project_config_include = "" +chip_project_config_include = "" +chip_system_project_config_include = "" + +chip_project_config_include_dirs = [ "${chip_root}/examples/chip-tool/include" ] +chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index 696171e06fa2d3..de72e392167703 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -22,6 +22,9 @@ #include "ConfigureFabricCommand.h" #include "PairingCommand.h" +#include +#include + class Unpair : public PairingCommand { public: @@ -149,6 +152,19 @@ class OpenCommissioningWindow : public PairingCommand {} }; +class StartUdcServerCommand : public CHIPCommand +{ +public: + StartUdcServerCommand() : CHIPCommand("start-udc-server") {} + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(300); } + + CHIP_ERROR RunCommand() override + { + chip::app::DnssdServer::Instance().StartServer(chip::Dnssd::CommissioningMode::kDisabled); + return CHIP_NO_ERROR; + } +}; + void registerCommandsPairing(Commands & commands) { const char * clusterName = "Pairing"; @@ -174,6 +190,7 @@ void registerCommandsPairing(Commands & commands) // TODO - enable CommissionedListCommand once DNS Cache is implemented // make_unique(), make_unique(), + make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/include/CHIPProjectAppConfig.h b/examples/chip-tool/include/CHIPProjectAppConfig.h new file mode 100644 index 00000000000000..0d5aee9f4135cf --- /dev/null +++ b/examples/chip-tool/include/CHIPProjectAppConfig.h @@ -0,0 +1,75 @@ +/* + * + * Copyright (c) 2020-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. + */ + +/** + * @file + * Project configuration for CHIP Tool. + * + */ +#ifndef CHIPPROJECTCONFIG_H +#define CHIPPROJECTCONFIG_H + +#define CHIP_CONFIG_ENABLE_EPHEMERAL_UDP_PORT 1 + +#define CHIP_CONFIG_EVENT_LOGGING_UTC_TIMESTAMPS 1 + +#define CHIP_CONFIG_EVENT_LOGGING_NUM_EXTERNAL_CALLBACKS 2 + +#define CHIP_CONFIG_EVENT_LOGGING_EXTERNAL_EVENT_SUPPORT 1 + +// Uncomment this for a large Tunnel MTU. +//#define CHIP_CONFIG_TUNNEL_INTERFACE_MTU (9000) + +// Enable support functions for parsing command-line arguments +#define CHIP_CONFIG_ENABLE_ARG_PARSER 1 + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Enable reading DRBG seed data from /dev/(u)random. +// This is needed for test applications and the CHIP device manager to function +// properly when CHIP_CONFIG_RNG_IMPLEMENTATION_CHIPDRBG is enabled. +#define CHIP_CONFIG_DEV_RANDOM_DRBG_SEED 1 + +// For convenience, Chip Security Test Mode can be enabled and the +// requirement for authentication in various protocols can be disabled. +// +// WARNING: These options make it possible to circumvent basic Chip security functionality, +// including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. +// +#define CHIP_CONFIG_SECURITY_TEST_MODE 0 +#define CHIP_CONFIG_REQUIRE_AUTH 1 + +// Increase session idle timeout in stand-alone builds for the convenience of developers. +#define CHIP_CONFIG_DEFAULT_SECURITY_SESSION_IDLE_TIMEOUT 120000 + +#define CHIP_CONFIG_ENABLE_UPDATE 1 + +#define CHIP_CONFIG_LEGACY_CASE_AUTH_DELEGATE 0 + +#define CHIP_CONFIG_LEGACY_KEY_EXPORT_DELEGATE 0 + +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 + +#define CHIP_CONFIG_DATA_MANAGEMENT_CLIENT_EXPERIMENTAL 1 + +#define CHIP_DEVICE_CONFIG_ENABLE_TEST_DEVICE_IDENTITY 1 + +#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 1 + +#endif /* CHIPPROJECTCONFIG_H */