Loading src/app/prototest/Makefile.inc +1 −2 Original line number Diff line number Diff line loop ?= 1 TARGETS += src/lib/ubjson/ubjr.c src/lib/ubjson/ubjw.c TARGETS += src/os/object/xdrstream.cc src/app/prototest/main.cc +29 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,11 @@ #include "driver/gpio.h" #include "driver/stdout.h" #include "lib/ArduinoJson.h" #include "lib/modernjson/json.h" #include "object/stdbuf.h" #include "object/xdrstream.h" char buf[128]; void loop(void) { Loading @@ -10,6 +15,30 @@ void loop(void) ArduinoJson::JsonObject& root = jsonBuffer.parseObject(json); const char *sensor = root["sensor"]; kout << "sensor: " << sensor << endl; nlohmann::json j = R"({"compact": true, "schema": 0})"_json; std::vector<std::uint8_t> v_cbor = nlohmann::json::to_cbor(j); kout << "CBOR vector is " << hex; for (unsigned int i = 0; i < v_cbor.size(); i++) { kout << v_cbor[i] << " "; } kout << endl; kout << "manual JSON: {\"sensor\":\"gps\",\"time\":" << dec << 1351824120; kout << ",\"data\":[" << 48.756080 << "," << 2.302038 << "]}" << endl; BufferOutput<XDRStream> foostream(buf); foostream << 123 << 0 << 12345678; kout << "foostream is " << hex; for (unsigned int i = 0; i < 32; i += 4) { kout << (unsigned char)buf[i] << (unsigned char)buf[i+1]; kout << (unsigned char)buf[i+2] << (unsigned char)buf[i+3] << " "; } kout << endl; gpio.led_toggle(1); #ifdef TIMER_S kout << dec << uptime.get_s() << endl; Loading Loading
src/app/prototest/Makefile.inc +1 −2 Original line number Diff line number Diff line loop ?= 1 TARGETS += src/lib/ubjson/ubjr.c src/lib/ubjson/ubjw.c TARGETS += src/os/object/xdrstream.cc
src/app/prototest/main.cc +29 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,11 @@ #include "driver/gpio.h" #include "driver/stdout.h" #include "lib/ArduinoJson.h" #include "lib/modernjson/json.h" #include "object/stdbuf.h" #include "object/xdrstream.h" char buf[128]; void loop(void) { Loading @@ -10,6 +15,30 @@ void loop(void) ArduinoJson::JsonObject& root = jsonBuffer.parseObject(json); const char *sensor = root["sensor"]; kout << "sensor: " << sensor << endl; nlohmann::json j = R"({"compact": true, "schema": 0})"_json; std::vector<std::uint8_t> v_cbor = nlohmann::json::to_cbor(j); kout << "CBOR vector is " << hex; for (unsigned int i = 0; i < v_cbor.size(); i++) { kout << v_cbor[i] << " "; } kout << endl; kout << "manual JSON: {\"sensor\":\"gps\",\"time\":" << dec << 1351824120; kout << ",\"data\":[" << 48.756080 << "," << 2.302038 << "]}" << endl; BufferOutput<XDRStream> foostream(buf); foostream << 123 << 0 << 12345678; kout << "foostream is " << hex; for (unsigned int i = 0; i < 32; i += 4) { kout << (unsigned char)buf[i] << (unsigned char)buf[i+1]; kout << (unsigned char)buf[i+2] << (unsigned char)buf[i+3] << " "; } kout << endl; gpio.led_toggle(1); #ifdef TIMER_S kout << dec << uptime.get_s() << endl; Loading