From b3f9b25d53b1bd1fc83e8a291ae40b84d02a4478 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Nov 2018 15:33:56 +0100 Subject: prototest: add ubjson --- src/app/prototest/main.cc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/app/prototest/main.cc') diff --git a/src/app/prototest/main.cc b/src/app/prototest/main.cc index aebfaea..c1d8359 100644 --- a/src/app/prototest/main.cc +++ b/src/app/prototest/main.cc @@ -17,6 +17,9 @@ #include #include #endif +#ifdef PROTOTEST_UBJSON +#include "ubj.h" +#endif #ifdef PROTOTEST_XDR #include "object/stdbuf.h" #include "object/xdrstream.h" @@ -146,6 +149,33 @@ void loop(void) } kout << endl; +#endif + + /* + * UBJSON + */ + +#ifdef PROTOTEST_UBJSON + + uint8_t buf[128]; + for (unsigned int i = 0; i < 128; i++) { + buf[i] = 0; + } + + ubjw_context_t* ctx = ubjw_open_memory(buf, buf + sizeof(buf)); + ubjw_begin_array(ctx, UBJ_MIXED, 0); + ubjw_write_int16(ctx, ts); + ubjw_write_string(ctx, "Noot Noot"); + ubjw_end(ctx); + + kout << "ubjr_close_context: " << ubjw_close_context(ctx) << endl; + + kout << "ubjr is " << hex; + for (unsigned int i = 0; i < 128; i++) { + kout << (uint8_t)buf[i]; + } + kout << endl; + #endif /* -- cgit v1.2.3