mirror of
https://github.com/espressif/openthread.git
synced 2026-09-16 14:10:09 +00:00
Default Logging Support (#1054)
* Add support for NCP passing logs up in the SPINEL_PROP_STREAM_DEBUG command.
This commit is contained in:
+13
-13
@@ -657,34 +657,34 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_LEGACY], [test "${enable_legacy}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_LEGACY],[${OPENTHREAD_ENABLE_LEGACY}],[Define to 1 if you want to use legacy network support])
|
||||
|
||||
#
|
||||
# Cli Logging
|
||||
# Default Logging
|
||||
#
|
||||
|
||||
AC_ARG_ENABLE(cli_logging,
|
||||
[AS_HELP_STRING([--enable-cli-logging],[Enable cli logging support @<:@default=no@:>@.])],
|
||||
AC_ARG_ENABLE(default_logging,
|
||||
[AS_HELP_STRING([--enable-default-logging],[Enable default logging support @<:@default=no@:>@.])],
|
||||
[
|
||||
case "${enableval}" in
|
||||
|
||||
no|yes)
|
||||
enable_cli_logging=${enableval}
|
||||
enable_default_logging=${enableval}
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid value ${enable_cli_logging} for --enable-cli-logging])
|
||||
AC_MSG_ERROR([Invalid value ${enable_default_logging} for --enable-default-logging])
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[enable_cli_logging=no])
|
||||
[enable_default_logging=no])
|
||||
|
||||
if test "$enable_cli_logging" = "yes"; then
|
||||
OPENTHREAD_ENABLE_CLI_LOGGING=1
|
||||
if test "$enable_default_logging" = "yes"; then
|
||||
OPENTHREAD_ENABLE_DEFAULT_LOGGING=1
|
||||
else
|
||||
OPENTHREAD_ENABLE_CLI_LOGGING=0
|
||||
OPENTHREAD_ENABLE_DEFAULT_LOGGING=0
|
||||
fi
|
||||
|
||||
AC_SUBST(OPENTHREAD_ENABLE_CLI_LOGGING)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_CLI_LOGGING], [test "${enable_cli_logging}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_CLI_LOGGING],[${OPENTHREAD_ENABLE_CLI_LOGGING}],[Define to 1 if you want to enable cli logging])
|
||||
AC_SUBST(OPENTHREAD_ENABLE_DEFAULT_LOGGING)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_DEFAULT_LOGGING], [test "${enable_default_logging}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_DEFAULT_LOGGING],[${OPENTHREAD_ENABLE_DEFAULT_LOGGING}],[Define to 1 if you want to enable default logging])
|
||||
|
||||
#
|
||||
# Log for certification test
|
||||
@@ -1066,7 +1066,7 @@ AC_MSG_NOTICE([
|
||||
OpenThread MAC Whitelist support : ${enable_mac_whitelist}
|
||||
OpenThread Diagnostics support : ${enable_diag}
|
||||
OpenThread Legacy network support : ${enable_legacy}
|
||||
OpenThread Cli logging support : ${enable_cli_logging}
|
||||
OpenThread Default logging support : ${enable_default_logging}
|
||||
OpenThread Certification log support : ${enable_cert_log}
|
||||
OpenThread DHCPv6 Server support : ${enable_dhcp6_server}
|
||||
OpenThread DHCPv6 Client support : ${enable_dhcp6_client}
|
||||
|
||||
@@ -45,14 +45,11 @@ configure_OPTIONS = \
|
||||
--enable-cli \
|
||||
--enable-ncp \
|
||||
--enable-diag \
|
||||
--enable-default-logging \
|
||||
--with-examples=cc2538 \
|
||||
--with-platform-info=CC2538 \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(CLI_LOGGING),1)
|
||||
configure_OPTIONS += --enable-cli-logging
|
||||
endif
|
||||
|
||||
ifeq ($(CERT_LOG),1)
|
||||
configure_OPTIONS += --enable-cert-log
|
||||
endif
|
||||
|
||||
@@ -39,7 +39,6 @@ libopenthread_cc2538_a_CPPFLAGS = \
|
||||
libopenthread_cc2538_a_SOURCES = \
|
||||
alarm.c \
|
||||
flash.c \
|
||||
logging.c \
|
||||
misc.c \
|
||||
platform.c \
|
||||
radio.c \
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements the OpenThread platform abstraction for logging.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_FILE
|
||||
#include OPENTHREAD_CONFIG_FILE
|
||||
#else
|
||||
#include <openthread-config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <platform/logging.h>
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <cli/cli-uart.h>
|
||||
#endif
|
||||
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
va_list args;
|
||||
va_start(args, aFormat);
|
||||
otCliLog(aLogLevel, aLogRegion, aFormat, args);
|
||||
va_end(args);
|
||||
#else
|
||||
(void)aLogLevel;
|
||||
(void)aLogRegion;
|
||||
(void)aFormat;
|
||||
#endif // OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
}
|
||||
@@ -62,79 +62,6 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
|
||||
|
||||
LOG_PRINTF("%s.%06d ", timeString, (uint32_t)tv.tv_usec);
|
||||
|
||||
switch (aLogLevel)
|
||||
{
|
||||
case kLogLevelNone:
|
||||
LOG_PRINTF("NONE ");
|
||||
break;
|
||||
|
||||
case kLogLevelCrit:
|
||||
LOG_PRINTF("CRIT ");
|
||||
break;
|
||||
|
||||
case kLogLevelWarn:
|
||||
LOG_PRINTF("WARN ");
|
||||
break;
|
||||
|
||||
case kLogLevelInfo:
|
||||
LOG_PRINTF("INFO ");
|
||||
break;
|
||||
|
||||
case kLogLevelDebg:
|
||||
LOG_PRINTF("DEBG ");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (aLogRegion)
|
||||
{
|
||||
case kLogRegionApi:
|
||||
LOG_PRINTF("API ");
|
||||
break;
|
||||
|
||||
case kLogRegionMle:
|
||||
LOG_PRINTF("MLE ");
|
||||
break;
|
||||
|
||||
case kLogRegionArp:
|
||||
LOG_PRINTF("ARP ");
|
||||
break;
|
||||
|
||||
case kLogRegionNetData:
|
||||
LOG_PRINTF("NETD ");
|
||||
break;
|
||||
|
||||
case kLogRegionIp6:
|
||||
LOG_PRINTF("IPV6 ");
|
||||
break;
|
||||
|
||||
case kLogRegionIcmp:
|
||||
LOG_PRINTF("ICMP ");
|
||||
break;
|
||||
|
||||
case kLogRegionMac:
|
||||
LOG_PRINTF("MAC ");
|
||||
break;
|
||||
|
||||
case kLogRegionMem:
|
||||
LOG_PRINTF("MEM ");
|
||||
break;
|
||||
|
||||
case kLogRegionNcp:
|
||||
LOG_PRINTF("NCP ");
|
||||
break;
|
||||
|
||||
case kLogRegionMeshCoP:
|
||||
LOG_PRINTF("MCOP ");
|
||||
break;
|
||||
|
||||
case kLogRegionNetDiag:
|
||||
LOG_PRINTF("NDG ");
|
||||
break;
|
||||
|
||||
case kLogRegionPlatform:
|
||||
LOG_PRINTF("PLAT ");
|
||||
}
|
||||
|
||||
va_start(args, aFormat);
|
||||
charsWritten = vsnprintf(&logString[offset], sizeof(logString) - offset, aFormat, args);
|
||||
va_end(args);
|
||||
@@ -143,5 +70,8 @@ void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat
|
||||
|
||||
exit:
|
||||
fprintf(stderr, "%s\r\n", logString);
|
||||
|
||||
(void)aLogLevel;
|
||||
(void)aLogRegion;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <openthread-types.h>
|
||||
#include <platform/logging.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -51,19 +50,6 @@ extern "C" {
|
||||
*/
|
||||
void otCliUartInit(otInstance *aInstance);
|
||||
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
/**
|
||||
* This method delivers formatted log to the client.
|
||||
*
|
||||
* @param[in] aLogLevel The log level.
|
||||
* @param[in] aLogRegion The log region.
|
||||
* @param[in] aFormat A pointer to the format string.
|
||||
* @param[in] aAp Arguments pointer for the format specification.
|
||||
*
|
||||
*/
|
||||
void otCliLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aAp);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Define to 1 if you want to enable default logging */
|
||||
#define OPENTHREAD_ENABLE_DEFAULT_LOGGING 1
|
||||
|
||||
/* Define to 1 to enable the commissioner role. */
|
||||
#define OPENTHREAD_ENABLE_COMMISSIONER 1
|
||||
|
||||
|
||||
+10
-76
@@ -228,96 +228,30 @@ void Uart::SendDoneTask(void)
|
||||
Send();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
#if OPENTHREAD_ENABLE_DEFAULT_LOGGING
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void otCliLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aAp)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
if (NULL == Uart::sUartServer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aLogLevel)
|
||||
{
|
||||
case kLogLevelNone:
|
||||
Uart::sUartServer->OutputFormat("NONE ");
|
||||
break;
|
||||
|
||||
case kLogLevelCrit:
|
||||
Uart::sUartServer->OutputFormat("CRIT ");
|
||||
break;
|
||||
|
||||
case kLogLevelWarn:
|
||||
Uart::sUartServer->OutputFormat("WARN ");
|
||||
break;
|
||||
|
||||
case kLogLevelInfo:
|
||||
Uart::sUartServer->OutputFormat("INFO ");
|
||||
break;
|
||||
|
||||
case kLogLevelDebg:
|
||||
Uart::sUartServer->OutputFormat("DEBG ");
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aLogRegion)
|
||||
{
|
||||
case kLogRegionApi:
|
||||
Uart::sUartServer->OutputFormat("API ");
|
||||
break;
|
||||
|
||||
case kLogRegionMle:
|
||||
Uart::sUartServer->OutputFormat("MLE ");
|
||||
break;
|
||||
|
||||
case kLogRegionArp:
|
||||
Uart::sUartServer->OutputFormat("ARP ");
|
||||
break;
|
||||
|
||||
case kLogRegionNetData:
|
||||
Uart::sUartServer->OutputFormat("NETD ");
|
||||
break;
|
||||
|
||||
case kLogRegionIp6:
|
||||
Uart::sUartServer->OutputFormat("IPV6 ");
|
||||
break;
|
||||
|
||||
case kLogRegionIcmp:
|
||||
Uart::sUartServer->OutputFormat("ICMP ");
|
||||
break;
|
||||
|
||||
case kLogRegionMac:
|
||||
Uart::sUartServer->OutputFormat("MAC ");
|
||||
break;
|
||||
|
||||
case kLogRegionMem:
|
||||
Uart::sUartServer->OutputFormat("MEM ");
|
||||
break;
|
||||
|
||||
case kLogRegionNcp:
|
||||
Uart::sUartServer->OutputFormat("NCP ");
|
||||
break;
|
||||
|
||||
case kLogRegionMeshCoP:
|
||||
Uart::sUartServer->OutputFormat("MCOP ");
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
Uart::sUartServer->OutputFormatV(aFormat, aAp);
|
||||
va_list args;
|
||||
va_start(args, aFormat);
|
||||
Uart::sUartServer->OutputFormatV(aFormat, args);
|
||||
Uart::sUartServer->OutputFormat("\r\n");
|
||||
va_end(args);
|
||||
|
||||
(void)aLogLevel;
|
||||
(void)aLogRegion;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
#endif // OPENTHREAD_ENABLE_DEFAULT_LOGGING
|
||||
|
||||
} // namespace Cli
|
||||
} // namespace Thread
|
||||
|
||||
@@ -148,6 +148,42 @@ void otDump(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aId, const
|
||||
otLogDump("%s", buf);
|
||||
}
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
const char *otLogLevelToString(otLogLevel aLevel)
|
||||
{
|
||||
const char *retval;
|
||||
|
||||
switch (aLevel)
|
||||
{
|
||||
case kLogLevelNone:
|
||||
retval = "NONE";
|
||||
break;
|
||||
|
||||
case kLogLevelCrit:
|
||||
retval = "CRIT";
|
||||
break;
|
||||
|
||||
case kLogLevelWarn:
|
||||
retval = "WARN";
|
||||
break;
|
||||
|
||||
case kLogLevelInfo:
|
||||
retval = "INFO";
|
||||
break;
|
||||
|
||||
case kLogLevelDebg:
|
||||
retval = "DEBG";
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = "----";
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
#endif // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
const char *otLogRegionToString(otLogRegion aRegion)
|
||||
{
|
||||
|
||||
@@ -1197,6 +1197,18 @@ extern "C" {
|
||||
*/
|
||||
void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void *aBuf, const size_t aLength);
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
/**
|
||||
* This method converts the log level value into a string
|
||||
*
|
||||
* @param[in] aLevel The log level.
|
||||
*
|
||||
* @returns A const char pointer to the C string corresponding to the log level.
|
||||
*
|
||||
*/
|
||||
const char *otLogLevelToString(otLogLevel aLevel);
|
||||
#endif
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
/**
|
||||
* This method converts the log region value into a string
|
||||
@@ -1207,10 +1219,48 @@ void otDump(otLogLevel aLevel, otLogRegion aRegion, const char *aId, const void
|
||||
*
|
||||
*/
|
||||
const char *otLogRegionToString(otLogRegion aRegion);
|
||||
#endif
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
/**
|
||||
* Local/private macro to format the log message
|
||||
*/
|
||||
#define _otLogFormatter(aLogLevel, aRegion, aFormat, ...) \
|
||||
otPlatLog( \
|
||||
aLogLevel, \
|
||||
aRegion, \
|
||||
"[%s]%s: " aFormat OPENTHREAD_CONFIG_LOG_SUFFIX, \
|
||||
otLogLevelToString(aLogLevel), \
|
||||
otLogRegionToString(aRegion), \
|
||||
## __VA_ARGS__ \
|
||||
)
|
||||
|
||||
#else // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
/**
|
||||
* Local/private macro to format the log message
|
||||
*/
|
||||
#define _otLogFormatter(aLogLevel, aRegion, aFormat, ...) \
|
||||
otPlatLog( \
|
||||
aLogLevel, \
|
||||
aRegion, \
|
||||
"[%s]: " aFormat OPENTHREAD_CONFIG_LOG_SUFFIX, \
|
||||
otLogLevelToString(aLogLevel), \
|
||||
## __VA_ARGS__ \
|
||||
)
|
||||
|
||||
#endif
|
||||
|
||||
#else // OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
|
||||
#ifdef OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
/**
|
||||
* Local/private macro to format the log message
|
||||
*/
|
||||
#define _otLogFormatter(aLogLevel, aRegion, aFormat, ...) \
|
||||
otPlatLog( \
|
||||
aLogLevel, \
|
||||
@@ -1223,8 +1273,8 @@ const char *otLogRegionToString(otLogRegion aRegion);
|
||||
#else // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
/**
|
||||
* Local/private macro to format the log message
|
||||
*/
|
||||
* Local/private macro to format the log message
|
||||
*/
|
||||
#define _otLogFormatter(aLogLevel, aRegion, aFormat, ...) \
|
||||
otPlatLog( \
|
||||
aLogLevel, \
|
||||
@@ -1233,6 +1283,8 @@ const char *otLogRegionToString(otLogRegion aRegion);
|
||||
## __VA_ARGS__ \
|
||||
)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -390,11 +390,19 @@
|
||||
//#define OPENTHREAD_CONFIG_LOG_PLATFORM
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPREND_REGION
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPREND_LEVEL
|
||||
*
|
||||
* Define to prepend the log region to all log messages
|
||||
* Define to prepend the log level to all log messages
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
|
||||
|
||||
/**
|
||||
* @def OPENTHREAD_CONFIG_LOG_PREPREND_REGION
|
||||
*
|
||||
* Define to prepend the log region to all log messages
|
||||
*
|
||||
*/
|
||||
#define OPENTHREAD_CONFIG_LOG_PREPEND_REGION
|
||||
|
||||
/**
|
||||
|
||||
+14
-7
@@ -5376,13 +5376,20 @@ ThreadError otNcpStreamWrite(int aStreamId, const uint8_t* aDataPtr, int aDataLe
|
||||
aStreamId = SPINEL_PROP_STREAM_DEBUG;
|
||||
}
|
||||
|
||||
return Thread::sNcpContext->SendPropertyUpdate(
|
||||
SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
static_cast<spinel_prop_key_t>(aStreamId),
|
||||
aDataPtr,
|
||||
static_cast<uint16_t>(aDataLen)
|
||||
);
|
||||
if (Thread::sNcpContext)
|
||||
{
|
||||
return Thread::sNcpContext->SendPropertyUpdate(
|
||||
SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0,
|
||||
SPINEL_CMD_PROP_VALUE_IS,
|
||||
static_cast<spinel_prop_key_t>(aStreamId),
|
||||
aDataPtr,
|
||||
static_cast<uint16_t>(aDataLen)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return kThreadError_InvalidState;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
+13
-4
@@ -266,16 +266,25 @@ void NcpUart::HandleError(ThreadError aError, uint8_t *aBuf, uint16_t aBufLength
|
||||
otNcpStreamWrite(0, reinterpret_cast<uint8_t*>(hexbuf + 1), static_cast<int>(strlen(hexbuf) - 1));
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
#if OPENTHREAD_ENABLE_DEFAULT_LOGGING
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void otCliLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aAp)
|
||||
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
char logString[128];
|
||||
int charsWritten;
|
||||
va_list args;
|
||||
|
||||
va_start(args, aFormat);
|
||||
if ((charsWritten = vsnprintf(logString, sizeof(logString), aFormat, args)) > 0)
|
||||
{
|
||||
otNcpStreamWrite(0, reinterpret_cast<uint8_t*>(logString), charsWritten);
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
(void)aLogLevel;
|
||||
(void)aLogRegion;
|
||||
(void)aFormat;
|
||||
(void)aAp;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
||||
Reference in New Issue
Block a user