mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 18:07:47 +00:00
[gn] add cli_uart (#12345)
This commit adds the `cli_uart` for applications to integrate OpenThread CLI based on UART APIs. One of the example is OTNS.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2026, The OpenThread Authors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
static_library("cli_uart") {
|
||||
sources = [ "cli_uart.cpp" ]
|
||||
include_dirs = [ "../../platforms" ]
|
||||
deps = [
|
||||
"../../../src/cli:cli_config",
|
||||
"../../../src/core:libopenthread_core_headers",
|
||||
]
|
||||
}
|
||||
@@ -29,9 +29,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openthread-system.h>
|
||||
#include <openthread/cli.h>
|
||||
#include <openthread/logging.h>
|
||||
#include <openthread/platform/debug_uart.h>
|
||||
@@ -291,6 +289,9 @@ static int Output(const char *aBuf, uint16_t aBufLength)
|
||||
return sent;
|
||||
}
|
||||
|
||||
static int CliUartOutput(void *aContext, const char *aFormat, va_list aArguments)
|
||||
OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 0);
|
||||
|
||||
static int CliUartOutput(void *aContext, const char *aFormat, va_list aArguments)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aContext);
|
||||
|
||||
+11
-7
@@ -42,7 +42,6 @@ openthread_cli_sources = [
|
||||
"cli_coap_secure.hpp",
|
||||
"cli_commissioner.cpp",
|
||||
"cli_commissioner.hpp",
|
||||
"cli_config.h",
|
||||
"cli_dataset.cpp",
|
||||
"cli_dataset.hpp",
|
||||
"cli_dns.cpp",
|
||||
@@ -76,20 +75,25 @@ openthread_cli_sources = [
|
||||
"x509_cert_key.hpp",
|
||||
]
|
||||
|
||||
config("cli_config") {
|
||||
defines = []
|
||||
static_library("cli_config") {
|
||||
public = [ "cli_config.h" ]
|
||||
deps = [ "../../src/core:libopenthread_core_headers" ]
|
||||
}
|
||||
|
||||
static_library("libopenthread-cli-ftd") {
|
||||
sources = openthread_cli_sources
|
||||
public_deps = [ "../core:libopenthread-ftd" ]
|
||||
public_configs = [":cli_config"]
|
||||
public_deps = [
|
||||
":cli_config",
|
||||
"../core:libopenthread-ftd",
|
||||
]
|
||||
visibility = [ "../../*" ]
|
||||
}
|
||||
|
||||
static_library("libopenthread-cli-mtd") {
|
||||
sources = openthread_cli_sources
|
||||
public_deps = [ "../core:libopenthread-mtd" ]
|
||||
public_configs = [":cli_config"]
|
||||
public_deps = [
|
||||
":cli_config",
|
||||
"../core:libopenthread-mtd",
|
||||
]
|
||||
visibility = [ "../../*" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user