mirror of
https://github.com/espressif/openthread.git
synced 2026-08-02 17:17:45 +00:00
@@ -543,6 +543,36 @@ AC_SUBST(OPENTHREAD_ENABLE_DIAG)
|
||||
AM_CONDITIONAL([OPENTHREAD_ENABLE_DIAG], [test "${enable_diag}" = "yes"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_ENABLE_DIAG],[${OPENTHREAD_ENABLE_DIAG}],[Define to 1 if you want to use diagnostics module])
|
||||
|
||||
#
|
||||
# Cli Logging
|
||||
#
|
||||
|
||||
AC_ARG_ENABLE(cli_logging,
|
||||
[AS_HELP_STRING([--enable-cli-logging],[Enable cli logging suport @<:@default=no@:>@.])],
|
||||
[
|
||||
case "${enableval}" in
|
||||
|
||||
no|yes)
|
||||
enable_cli_logging=${enableval}
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid value ${enable_cli_logging} for --enable-cli-logging])
|
||||
;;
|
||||
esac
|
||||
],
|
||||
[enable_cli_logging=no])
|
||||
|
||||
if test "$enable_cli_logging" = "yes"; then
|
||||
OPENTHREAD_ENABLE_CLI_LOGGING=1
|
||||
else
|
||||
OPENTHREAD_ENABLE_CLI_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])
|
||||
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
@@ -796,6 +826,7 @@ AC_MSG_NOTICE([
|
||||
OpenThread Joiner support : ${enable_joiner}
|
||||
OpenThread DTLS support : ${enable_dtls}
|
||||
OpenThread Diagnostics support : ${enable_diag}
|
||||
OpenThread Cli logging support : ${enable_cli_logging}
|
||||
OpenThread examples : ${OPENTHREAD_EXAMPLES}
|
||||
OpenThread platform information : ${PLATFORM_INFO}
|
||||
|
||||
|
||||
@@ -32,12 +32,36 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define CLI_UART_H_
|
||||
|
||||
#include <openthread-types.h>
|
||||
#include <platform/logging.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -49,6 +50,19 @@ 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] ... Arguments for the format specification.
|
||||
*
|
||||
*/
|
||||
void otCliLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <common/encoding.hpp>
|
||||
#include <common/new.hpp>
|
||||
#include <common/tasklet.hpp>
|
||||
#include <platform/logging.h>
|
||||
#include <platform/uart.h>
|
||||
|
||||
namespace Thread {
|
||||
@@ -214,5 +215,98 @@ void Uart::SendDoneTask(void)
|
||||
Send();
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void otCliLog(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;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start(args, aFormat);
|
||||
Uart::sUartServer->OutputFormat(aFormat, args);
|
||||
va_end(args);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
|
||||
} // namespace Cli
|
||||
} // namespace Thread
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <net/ip6.hpp>
|
||||
#include <ncp/ncp.h>
|
||||
#include <ncp/ncp_uart.hpp>
|
||||
#include <platform/logging.h>
|
||||
#include <platform/uart.h>
|
||||
#include <core/openthread-core-config.h>
|
||||
|
||||
@@ -258,4 +259,19 @@ 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
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void otCliLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
|
||||
{
|
||||
(void)aLogLevel;
|
||||
(void)aLogRegion;
|
||||
(void)aFormat;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // OPENTHREAD_ENABLE_CLI_LOGGING
|
||||
|
||||
} // namespace Thread
|
||||
|
||||
Reference in New Issue
Block a user