diff --git a/include/openthread/ncp.h b/include/openthread/ncp.h index 90a80f8d9..329013d1b 100644 --- a/include/openthread/ncp.h +++ b/include/openthread/ncp.h @@ -84,6 +84,16 @@ void otNcpInit(otInstance *aInstance); */ otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen); +/** + * Writes OpenThread Log using `otNcpStreamWrite`. + * + * @param[in] aLogLevel The log level. + * @param[in] aLogRegion The log region. + * @param[in] aFormat A pointer to the format string. + * @param[in] aArgs va_list matching aFormat. + */ +void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs); + //----------------------------------------------------------------------------------------- // Peek/Poke memory access control delegates @@ -202,16 +212,6 @@ void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix); */ void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers); -/** - * Callback to write the OpenThread Log to the NCP Spinel Tunnel. - * - * @param[in] aLogLevel The log level. - * @param[in] aLogRegion The log region. - * @param[in] aFormat A pointer to the format string. - * @param[in] aArgs va_list matching aFormat. - */ -void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs); - /** * @} * diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h index 43b3e3c6d..ad08dee8d 100644 --- a/src/core/openthread-core-default-config.h +++ b/src/core/openthread-core-default-config.h @@ -855,6 +855,16 @@ #define OPENTHREAD_CONFIG_NCP_SPINEL_ENCRYPTER_EXTRA_DATA_SIZE 0 #endif +/** + * @def OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE + * + * The maximum OpenThread log string size (number of chars) supported by NCP using Spinel `StreamWrite`. + * + */ +#ifndef OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE +#define OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE 150 +#endif + /** * @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT * diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp index b286fcbd5..87267e3d7 100644 --- a/src/ncp/ncp_base.cpp +++ b/src/ncp/ncp_base.cpp @@ -2163,7 +2163,7 @@ otError otNcpStreamWrite(int aStreamId, const uint8_t *aDataPtr, int aDataLen) extern "C" void otNcpPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list aArgs) { - char logString[128]; + char logString[OPENTHREAD_CONFIG_NCP_SPINEL_LOG_MAX_SIZE]; int charsWritten; if ((charsWritten = vsnprintf(logString, sizeof(logString), aFormat, aArgs)) > 0)