use LOG_INF
This commit is contained in:
29
src/json.cpp
29
src/json.cpp
@@ -1,6 +1,9 @@
|
||||
#include <json.hpp>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
static constexpr size_t BUF_SIZE = 64 + 1;
|
||||
LOG_MODULE_REGISTER(json);
|
||||
|
||||
static constexpr size_t BUF_SIZE = 512;
|
||||
char _buf[BUF_SIZE];
|
||||
size_t _idx;
|
||||
size_t _indent;
|
||||
@@ -15,10 +18,10 @@ JsonParser::HandlerBase::HandlerBase()
|
||||
|
||||
int JsonParser::json_printer(const char* bytes, size_t len, void* data)
|
||||
{
|
||||
// info("[[%d]]\n", len);
|
||||
// LOG_INF("[[%d]]", len);
|
||||
// for (size_t i = 0; i < len; i++)
|
||||
// {
|
||||
// info("%c", bytes[i]);
|
||||
// LOG_INF("%c", bytes[i]);
|
||||
// }
|
||||
// return 0;
|
||||
|
||||
@@ -29,13 +32,13 @@ int JsonParser::json_printer(const char* bytes, size_t len, void* data)
|
||||
{
|
||||
nl = false;
|
||||
_indent--;
|
||||
info("\n");
|
||||
LOG_INF("");
|
||||
for (size_t i = 0; i < _indent; i++)
|
||||
{
|
||||
info(" ");
|
||||
LOG_ERR(" ");
|
||||
}
|
||||
}
|
||||
info("%c", bytes[i]);
|
||||
LOG_INF("%c", bytes[i]);
|
||||
if (bytes[i] == '{' || bytes[i] == '[')
|
||||
{
|
||||
_indent++;
|
||||
@@ -44,10 +47,10 @@ int JsonParser::json_printer(const char* bytes, size_t len, void* data)
|
||||
&& (bytes[i] == ',' || bytes[i] == '{' || bytes[i] == '}'
|
||||
|| bytes[i] == '[' || bytes[i] == ']'))
|
||||
{
|
||||
info("\n");
|
||||
LOG_INF("");
|
||||
for (size_t i = 0; i < _indent; i++)
|
||||
{
|
||||
info(" ");
|
||||
LOG_INF(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,14 +74,14 @@ void commit()
|
||||
_idx = 0;
|
||||
if (!ok)
|
||||
{
|
||||
info("parse end error\n");
|
||||
LOG_INF("parse end error");
|
||||
}
|
||||
}
|
||||
|
||||
void flush_error()
|
||||
void flush_LOG_ERRR()
|
||||
{
|
||||
_idx = 0;
|
||||
error("input buffer overflow, flushing\n");
|
||||
LOG_ERR("input buffer overflow, flushing");
|
||||
}
|
||||
|
||||
void JsonParser::init()
|
||||
@@ -86,7 +89,7 @@ void JsonParser::init()
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
void JsonParser::add_text(uint8_t* buf, size_t size)
|
||||
void JsonParser::add_text(const uint8_t* buf, size_t size)
|
||||
{
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
@@ -105,7 +108,7 @@ void JsonParser::add_text(uint8_t* buf, size_t size)
|
||||
_idx++;
|
||||
if (_idx >= BUF_SIZE)
|
||||
{
|
||||
flush_error();
|
||||
flush_LOG_ERRR();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user