mirror of
https://github.com/espressif/openthread.git
synced 2026-08-01 00:27:47 +00:00
Replace CLI response buffer with direct output via CLI server. (#75)
* Added new Output method that allows format strings. * Added an output FIFO to the CLI serial server.
This commit is contained in:
+16
-2
@@ -31,6 +31,7 @@
|
||||
* This file implements the CLI server on a UDP socket.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -87,7 +88,7 @@ exit:
|
||||
{}
|
||||
}
|
||||
|
||||
ThreadError Udp::Output(const char *aBuf, uint16_t aBufLength)
|
||||
int Udp::Output(const char *aBuf, uint16_t aBufLength)
|
||||
{
|
||||
ThreadError error = kThreadError_None;
|
||||
otMessage message;
|
||||
@@ -102,9 +103,22 @@ exit:
|
||||
if (error != kThreadError_None && message != NULL)
|
||||
{
|
||||
otFreeMessage(message);
|
||||
aBufLength = 0;
|
||||
}
|
||||
|
||||
return error;
|
||||
return aBufLength;
|
||||
}
|
||||
|
||||
int Udp::OutputFormat(const char *fmt, ...)
|
||||
{
|
||||
char buf[kMaxLineLength];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return Output(buf, strlen(buf));
|
||||
}
|
||||
|
||||
} // namespace Cli
|
||||
|
||||
Reference in New Issue
Block a user