Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
multipass
Commits
7edc7164
Commit
7edc7164
authored
6 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
prototest: More arduinojson, ubjson, cbor
parent
a07d2385
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/prototest/main.cc
+43
-7
43 additions, 7 deletions
src/app/prototest/main.cc
with
43 additions
and
7 deletions
src/app/prototest/main.cc
+
43
−
7
View file @
7edc7164
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
#include
"prototest_global.cc.inc"
#include
"prototest_global.cc.inc"
#endif
#endif
#ifdef PROTOTEST_ARDUINOJSON
char
buf
[
256
];
#endif
#ifdef PROTOTEST_XDR
#ifdef PROTOTEST_XDR
char
buf
[
256
];
char
buf
[
256
];
#endif
#endif
...
@@ -99,11 +102,30 @@ void loop(void)
...
@@ -99,11 +102,30 @@ void loop(void)
*/
*/
#ifdef PROTOTEST_ARDUINOJSON
#ifdef PROTOTEST_ARDUINOJSON
char
json
[]
=
"{
\"
sensor
\"
:
\"
gps
\"
,
\"
time
\"
:1351824120,
\"
data
\"
:[48.756080,2.302038]}"
;
for
(
unsigned
int
i
=
0
;
i
<
128
;
i
++
)
{
ArduinoJson
::
StaticJsonBuffer
<
200
>
jsonBuffer
;
buf
[
i
]
=
0
;
ArduinoJson
::
JsonObject
&
root
=
jsonBuffer
.
parseObject
(
json
);
}
const
char
*
sensor
=
root
[
"sensor"
];
kout
<<
"sensor: "
<<
sensor
<<
endl
;
{
ArduinoJson
::
StaticJsonBuffer
<
200
>
jsonBuffer
;
ArduinoJson
::
JsonObject
&
root
=
jsonBuffer
.
createObject
();
root
[
"sensor"
]
=
"gps"
;
root
[
"time"
]
=
ts
;
ArduinoJson
::
JsonArray
&
data
=
root
.
createNestedArray
(
"data"
);
data
.
add
(
48.756080
);
data
.
add
(
2.302038
);
root
.
printTo
(
buf
);
kout
<<
"buf is "
<<
buf
<<
endl
;
}
{
char
json
[]
=
"{
\"
sensor
\"
:
\"
gps
\"
,
\"
time
\"
:1351824120,
\"
data
\"
:[48.756080,2.302038]}"
;
ArduinoJson
::
StaticJsonBuffer
<
200
>
jsonBuffer
;
ArduinoJson
::
JsonObject
&
root
=
jsonBuffer
.
parseObject
(
json
);
const
char
*
sensor
=
root
[
"sensor"
];
kout
<<
"sensor: "
<<
sensor
<<
endl
;
}
#endif
#endif
/*
/*
...
@@ -122,14 +144,28 @@ void loop(void)
...
@@ -122,14 +144,28 @@ void loop(void)
{
"time"
,
ts
},
{
"time"
,
ts
},
{
"data"
,
{
48.756080
,
2.302038
}
}
{
"data"
,
{
48.756080
,
2.302038
}
}
};
};
kout
<<
js2
.
dump
()
<<
endl
;
kout
<<
"string:"
<<
js2
.
dump
()
<<
endl
;
std
::
vector
<
std
::
uint8_t
>
v_cbor
=
nlohmann
::
json
::
to_cbor
(
js2
);
std
::
vector
<
std
::
uint8_t
>
v_cbor
=
nlohmann
::
json
::
to_cbor
(
js2
);
kout
<<
"CBOR
vector is
"
<<
hex
;
kout
<<
"CBOR
:
"
<<
hex
;
for
(
unsigned
int
i
=
0
;
i
<
v_cbor
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
v_cbor
.
size
();
i
++
)
{
kout
<<
v_cbor
[
i
]
<<
" "
;
kout
<<
v_cbor
[
i
]
<<
" "
;
}
}
kout
<<
endl
;
kout
<<
endl
;
std
::
vector
<
std
::
uint8_t
>
v_msgpack
=
nlohmann
::
json
::
to_msgpack
(
js2
);
kout
<<
"MsgPack:"
<<
hex
;
for
(
unsigned
int
i
=
0
;
i
<
v_msgpack
.
size
();
i
++
)
{
kout
<<
v_msgpack
[
i
]
<<
" "
;
}
kout
<<
endl
;
std
::
vector
<
std
::
uint8_t
>
v_ubjson
=
nlohmann
::
json
::
to_ubjson
(
js2
);
kout
<<
"UBJSON:"
<<
hex
;
for
(
unsigned
int
i
=
0
;
i
<
v_ubjson
.
size
();
i
++
)
{
kout
<<
v_ubjson
[
i
]
<<
" "
;
}
kout
<<
endl
;
#endif
#endif
/*
/*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment