mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 12:17:05 +00:00
Compare commits
575
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9f3f68335 | ||
|
|
777485077c | ||
|
|
3e3ef4253f | ||
|
|
0e78b1f8c4 | ||
|
|
e7764ca7e6 | ||
|
|
89578058b6 | ||
|
|
34beb07120 | ||
|
|
c98ae55f23 | ||
|
|
6b08009fdd | ||
|
|
f3a8e503ac | ||
|
|
856afe9ec5 | ||
|
|
c4803b4136 | ||
|
|
9de29b8d9c | ||
|
|
5a2b4146e5 | ||
|
|
0a8050312c | ||
|
|
2ffa52c7ee | ||
|
|
6a984ad750 | ||
|
|
f0c1b10f46 | ||
|
|
da6ab075a5 | ||
|
|
fb7ffe0731 | ||
|
|
1d3bafc982 | ||
|
|
2fde3d28a8 | ||
|
|
4c1b3a8abf | ||
|
|
988f269954 | ||
|
|
808b571814 | ||
|
|
a4f8068fcd | ||
|
|
025e346cb1 | ||
|
|
3481dd9868 | ||
|
|
fd596c14b2 | ||
|
|
8c9b9b1700 | ||
|
|
e0b00a23cf | ||
|
|
685c975bab | ||
|
|
d01ca5209e | ||
|
|
d5a05a1ac5 | ||
|
|
c670520788 | ||
|
|
859b67e34d | ||
|
|
d325f7c1fd | ||
|
|
c2998b081f | ||
|
|
c3c2a0b6bd | ||
|
|
9e00623677 | ||
|
|
6be032b350 | ||
|
|
96367a9422 | ||
|
|
543ac49eaf | ||
|
|
3e0362d52a | ||
|
|
15118d372e | ||
|
|
c8ee7976cc | ||
|
|
b750e875bd | ||
|
|
5ad43348b4 | ||
|
|
08b2259924 | ||
|
|
f268b40291 | ||
|
|
52d747dd49 | ||
|
|
e5653d1817 | ||
|
|
6b2257063b | ||
|
|
b9a4af54c9 | ||
|
|
26634f7ba9 | ||
|
|
9beda98009 | ||
|
|
c7c46d28b1 | ||
|
|
c51b78bfbf | ||
|
|
df5c22529f | ||
|
|
808ab85afb | ||
|
|
ad1cbf5ddf | ||
|
|
4aff834f76 | ||
|
|
f8405690c5 | ||
|
|
3edf12913d | ||
|
|
f0aa9c50f6 | ||
|
|
80f87b6c53 | ||
|
|
f41f0969f0 | ||
|
|
14e2f4c697 | ||
|
|
b9f5535b48 | ||
|
|
81022e4605 | ||
|
|
616898514b | ||
|
|
020aec0541 | ||
|
|
1e39a314f5 | ||
|
|
4d369927fd | ||
|
|
c1465831bb | ||
|
|
3ec1d29c19 | ||
|
|
22b430c669 | ||
|
|
2f7560cc90 | ||
|
|
4f97db87f7 | ||
|
|
dcf8e86db7 | ||
|
|
06914e72b1 | ||
|
|
fca56ac311 | ||
|
|
2bacc5a1b2 | ||
|
|
a487bd132d | ||
|
|
3f441b11ee | ||
|
|
40d5780600 | ||
|
|
9822c4bac0 | ||
|
|
0fc3a28875 | ||
|
|
0aac28b15e | ||
|
|
810927f32b | ||
|
|
c3d8d0a2fe | ||
|
|
0c9e27a180 | ||
|
|
a5f44a1811 | ||
|
|
66f386f3fc | ||
|
|
e74cc14dfb | ||
|
|
ad1907eef4 | ||
|
|
7640132828 | ||
|
|
fecf740121 | ||
|
|
7d9628c6d1 | ||
|
|
7d5a0db6fa | ||
|
|
49fc761657 | ||
|
|
98d1a9cec4 | ||
|
|
ae010e25fb | ||
|
|
3013c8e468 | ||
|
|
ade5f83819 | ||
|
|
caf487e04e | ||
|
|
d8100a2b9d | ||
|
|
18f38b3019 | ||
|
|
952c532542 | ||
|
|
d1b15579a1 | ||
|
|
8445d8cc71 | ||
|
|
7720b5bce3 | ||
|
|
965046778a | ||
|
|
1a8fffda28 | ||
|
|
a5e3979be6 | ||
|
|
9d2e008a5c | ||
|
|
a031ce9b5b | ||
|
|
c8593d5644 | ||
|
|
306b2174f2 | ||
|
|
10ff688cc4 | ||
|
|
ae292921e2 | ||
|
|
a1622f6066 | ||
|
|
86490d6f0b | ||
|
|
976df758d2 | ||
|
|
c31e50dfa0 | ||
|
|
147acc6724 | ||
|
|
bfd5ad587a | ||
|
|
84791ecbd5 | ||
|
|
6e4f4cb27b | ||
|
|
c1ee60ebca | ||
|
|
fc1f6acc61 | ||
|
|
e2c82680aa | ||
|
|
f0eb7659b2 | ||
|
|
966353614d | ||
|
|
3308a47a3a | ||
|
|
ffad0256e9 | ||
|
|
c531639d03 | ||
|
|
a2ec2d15f1 | ||
|
|
eaa21d0182 | ||
|
|
5a19b08262 | ||
|
|
2c9964127c | ||
|
|
ea20971b51 | ||
|
|
eed78f9613 | ||
|
|
fe26453927 | ||
|
|
70db6d65db | ||
|
|
07b9d5c6f5 | ||
|
|
45048ea6bc | ||
|
|
c7ff6059ce | ||
|
|
6d2cd505a8 | ||
|
|
6b05d2b02e | ||
|
|
083310679c | ||
|
|
2758c80af2 | ||
|
|
0bd1134eca | ||
|
|
4a75b1fa6d | ||
|
|
21d30f0ebe | ||
|
|
16463dff85 | ||
|
|
8e5fb85fa8 | ||
|
|
74f059e639 | ||
|
|
045c50f69f | ||
|
|
a122066e36 | ||
|
|
d3bf64fc4f | ||
|
|
74decbd159 | ||
|
|
b00020de89 | ||
|
|
d9848c1911 | ||
|
|
648353b216 | ||
|
|
f729012ee1 | ||
|
|
87176b453a | ||
|
|
a2270bebbf | ||
|
|
305d729015 | ||
|
|
c31fa71988 | ||
|
|
fba4331213 | ||
|
|
972d24118a | ||
|
|
a885cf1f90 | ||
|
|
56d85814b1 | ||
|
|
c760174c78 | ||
|
|
2c43094a87 | ||
|
|
ee99e9e6f4 | ||
|
|
864e402cc2 | ||
|
|
dff51ba54d | ||
|
|
0eea67d176 | ||
|
|
9139baa6cb | ||
|
|
fdf8a40acf | ||
|
|
547f3643ff | ||
|
|
83d0980248 | ||
|
|
0b1f9a81b5 | ||
|
|
0e8b333f48 | ||
|
|
67098c2539 | ||
|
|
700b14b8ff | ||
|
|
9175cd3a17 | ||
|
|
c16f27af1b | ||
|
|
cc60b8a05d | ||
|
|
d7b46b3395 | ||
|
|
701677274f | ||
|
|
ebfffb8d43 | ||
|
|
f5fd624739 | ||
|
|
abdf011a2d | ||
|
|
4ece42bdc9 | ||
|
|
b0961c15a3 | ||
|
|
70a422bdfd | ||
|
|
5449d82639 | ||
|
|
7e5577b30b | ||
|
|
0d95fd12fe | ||
|
|
b7df21a1d5 | ||
|
|
431b94c587 | ||
|
|
53241f2afc | ||
|
|
076c2c04f1 | ||
|
|
10e912f46f | ||
|
|
c90174712b | ||
|
|
1d71d362b9 | ||
|
|
73fbe04981 | ||
|
|
469735b5fd | ||
|
|
cf13024175 | ||
|
|
eaf6488b0c | ||
|
|
4d067f010f | ||
|
|
e6db005dba | ||
|
|
7a03802c15 | ||
|
|
1e2e750b3b | ||
|
|
50a19692b5 | ||
|
|
b6284f2701 | ||
|
|
b3db6621e2 | ||
|
|
2d32fe3e32 | ||
|
|
241f21b87c | ||
|
|
4f18f81522 | ||
|
|
b860f79e77 | ||
|
|
8966e1680b | ||
|
|
01436201a3 | ||
|
|
1ac94bf6db | ||
|
|
ed66a98e08 | ||
|
|
5a0c2e2353 | ||
|
|
06bc63e385 | ||
|
|
d3ebe3ec46 | ||
|
|
2282288030 | ||
|
|
e5766bee46 | ||
|
|
c5bbfd1b4c | ||
|
|
652ce2f809 | ||
|
|
f3fd3900e5 | ||
|
|
07b726d4b1 | ||
|
|
648d960bf5 | ||
|
|
1829a35df2 | ||
|
|
c5bb6700d9 | ||
|
|
3b2dd86280 | ||
|
|
11563469d0 | ||
|
|
fcea12b515 | ||
|
|
2b72ad2088 | ||
|
|
30acf569e7 | ||
|
|
cb71f73b56 | ||
|
|
521ca465e5 | ||
|
|
ca10c834cc | ||
|
|
ef90c84506 | ||
|
|
3c2f539ec3 | ||
|
|
30419c9932 | ||
|
|
a340b4dedc | ||
|
|
69e4d1ec7a | ||
|
|
91570e9df5 | ||
|
|
53e9a8f4a3 | ||
|
|
71c9b772fe | ||
|
|
3ff96a5bec | ||
|
|
32f8edb1ce | ||
|
|
977611b39c | ||
|
|
52979cafba | ||
|
|
b0a1b95f64 | ||
|
|
04f323b902 | ||
|
|
c20656fe77 | ||
|
|
6d3b2d1b18 | ||
|
|
388b8f4feb | ||
|
|
7b6b72b912 | ||
|
|
5e9ad087b9 | ||
|
|
ca5a1bdba1 | ||
|
|
98522d7cfc | ||
|
|
30ab8aef9e | ||
|
|
22593d7116 | ||
|
|
a8f3ad1be2 | ||
|
|
d54a01a3e6 | ||
|
|
226b3f3d54 | ||
|
|
1e4a0858c1 | ||
|
|
379c4fccd1 | ||
|
|
886d46fd4c | ||
|
|
5184cba646 | ||
|
|
b8c4215a27 | ||
|
|
d1b017b287 | ||
|
|
a5421e816c | ||
|
|
d6ca15671d | ||
|
|
24231cdc56 | ||
|
|
30e192f041 | ||
|
|
38472a3d6b | ||
|
|
d54af04a79 | ||
|
|
056e7a7a40 | ||
|
|
f69e476174 | ||
|
|
b368252db8 | ||
|
|
ea3389f792 | ||
|
|
33b8570c33 | ||
|
|
76ff83e3f4 | ||
|
|
92680c5542 | ||
|
|
e568bbed7c | ||
|
|
82bfadd77a | ||
|
|
b636959cc7 | ||
|
|
2a1f6eebe7 | ||
|
|
b7b8ceebcf | ||
|
|
9f6f39053e | ||
|
|
8eed47393f | ||
|
|
cc0c2c0f8b | ||
|
|
0450d8a106 | ||
|
|
e96de4a988 | ||
|
|
28bdc37d24 | ||
|
|
b7ccba979c | ||
|
|
5132a318af | ||
|
|
cfd27b4918 | ||
|
|
feba82188a | ||
|
|
1a3274d2c2 | ||
|
|
0f04456ae6 | ||
|
|
6016e1b1d3 | ||
|
|
39e391ca0e | ||
|
|
8088ed4ed8 | ||
|
|
13bd7ba26b | ||
|
|
3cb90939c4 | ||
|
|
76cddb7c71 | ||
|
|
3d0f871600 | ||
|
|
ffb3ee4039 | ||
|
|
456796a87d | ||
|
|
bf512f9da0 | ||
|
|
d5b8a36acb | ||
|
|
f09642101f | ||
|
|
cb16773128 | ||
|
|
2e55b6304c | ||
|
|
f61586ebbc | ||
|
|
7f385fc74a | ||
|
|
a579c906d5 | ||
|
|
a80f3a5f0b | ||
|
|
7e10fda7e5 | ||
|
|
16a6135f53 | ||
|
|
343ea459ab | ||
|
|
0ddcee1f07 | ||
|
|
07ac4cf8cf | ||
|
|
a864aeab1e | ||
|
|
35a7ab94df | ||
|
|
44755e83b9 | ||
|
|
f93b38624d | ||
|
|
c1cb7d873c | ||
|
|
62d81325b2 | ||
|
|
5bc2af0e4c | ||
|
|
bc5bf7f3f1 | ||
|
|
0b4013b33c | ||
|
|
3c3a11d77b | ||
|
|
5876fb84af | ||
|
|
25ab07a9ba | ||
|
|
e6044bdbf8 | ||
|
|
572f8bcde7 | ||
|
|
c010640aa5 | ||
|
|
e60c0dc5f0 | ||
|
|
4e6e31fdae | ||
|
|
77deb3d8b3 | ||
|
|
3530027864 | ||
|
|
07bfec4234 | ||
|
|
3476792c58 | ||
|
|
45afaf8d3f | ||
|
|
9084a5542b | ||
|
|
4ac330ebf6 | ||
|
|
49a0476487 | ||
|
|
f606d2c55d | ||
|
|
4f9a383d93 | ||
|
|
d4d0ee3b30 | ||
|
|
9705702f4c | ||
|
|
c3e015342c | ||
|
|
209484554e | ||
|
|
27377ab3ed | ||
|
|
7055d24693 | ||
|
|
62e6317a23 | ||
|
|
29f89b687d | ||
|
|
697d20a028 | ||
|
|
e9df0e75b9 | ||
|
|
f23f49931b | ||
|
|
4af29c405b | ||
|
|
d780f1a07f | ||
|
|
f9be283cb7 | ||
|
|
3f1cda7b81 | ||
|
|
2fd226d6bd | ||
|
|
3d1edcf33e | ||
|
|
cc740b46f1 | ||
|
|
e829058c92 | ||
|
|
685438c35d | ||
|
|
f8a4ef389f | ||
|
|
7e9c31131c | ||
|
|
99150c4214 | ||
|
|
ec7e6f80b0 | ||
|
|
dada682ed6 | ||
|
|
ab31b33a2c | ||
|
|
621585901f | ||
|
|
eaaf1fe888 | ||
|
|
41e4705198 | ||
|
|
c35fe3d500 | ||
|
|
e2da8ecbb9 | ||
|
|
3dad26a58a | ||
|
|
ae930a1d36 | ||
|
|
45e980beda | ||
|
|
8723e177df | ||
|
|
8454994023 | ||
|
|
50732aed8a | ||
|
|
f2888951dc | ||
|
|
56ac640986 | ||
|
|
df2d7be30b | ||
|
|
9e06cf4dc7 | ||
|
|
cd27339b8e | ||
|
|
ec38ba1fb7 | ||
|
|
b8fa42925f | ||
|
|
4169ca0ee8 | ||
|
|
578477bf6d | ||
|
|
0803e946b0 | ||
|
|
06001bbc94 | ||
|
|
f171d5b211 | ||
|
|
360b552424 | ||
|
|
d9597febf8 | ||
|
|
6aa21ea6f8 | ||
|
|
b1de652b62 | ||
|
|
5c3bf9e894 | ||
|
|
0acd7b0e70 | ||
|
|
8bbaffdeb0 | ||
|
|
19e86e7df3 | ||
|
|
311d6f01df | ||
|
|
61f47d5ffc | ||
|
|
72f0f95471 | ||
|
|
4e33472d81 | ||
|
|
69c4f970a9 | ||
|
|
28866bd08c | ||
|
|
0f93e3ed3c | ||
|
|
59a82ee17f | ||
|
|
e8af00f99f | ||
|
|
ad4b0f8008 | ||
|
|
ae2a0b5208 | ||
|
|
785266bd39 | ||
|
|
2e63e764b2 | ||
|
|
f7eaecf5d4 | ||
|
|
1bee80d0ec | ||
|
|
504a9aa295 | ||
|
|
059530a6b7 | ||
|
|
5b83c634e9 | ||
|
|
ff7ab3837e | ||
|
|
badad651de | ||
|
|
8a767b77e8 | ||
|
|
072a1a4080 | ||
|
|
394e4b095d | ||
|
|
ae1e62c8c6 | ||
|
|
0efb7823d7 | ||
|
|
3ee7d4d04e | ||
|
|
f2d3a5d222 | ||
|
|
904a5cc612 | ||
|
|
5241f93f5f | ||
|
|
6d33d21f70 | ||
|
|
045e2ef9f4 | ||
|
|
527267de62 | ||
|
|
29c01eeb38 | ||
|
|
1c5a1d3656 | ||
|
|
d6fe76750a | ||
|
|
1889c0f9e5 | ||
|
|
ebc16044e2 | ||
|
|
5695ea8fa8 | ||
|
|
16cc9aaa6b | ||
|
|
7f393af2a0 | ||
|
|
3e22607276 | ||
|
|
4de720382d | ||
|
|
a718572688 | ||
|
|
2d66c9fefa | ||
|
|
de51a130b3 | ||
|
|
a8020c9011 | ||
|
|
a2cbc6d474 | ||
|
|
ea5c99431c | ||
|
|
6f68d87f50 | ||
|
|
4aa9c5e0ba | ||
|
|
7e4666afed | ||
|
|
7651a07efc | ||
|
|
f961a9f331 | ||
|
|
bb49cbdc89 | ||
|
|
7fe1b41ea5 | ||
|
|
358e9f1e24 | ||
|
|
8f77ffc871 | ||
|
|
60faa58894 | ||
|
|
aba095b25d | ||
|
|
617ebe96de | ||
|
|
a1bf42dde1 | ||
|
|
b0b83543eb | ||
|
|
b97be9c718 | ||
|
|
33831b072b | ||
|
|
a5f94298d8 | ||
|
|
d0dc959d31 | ||
|
|
644aa2f65e | ||
|
|
e457fe7597 | ||
|
|
dcd409e9d9 | ||
|
|
c227c13ba2 | ||
|
|
c64566ce49 | ||
|
|
a9366c8f23 | ||
|
|
bbf470c61d | ||
|
|
1c1211c4f3 | ||
|
|
7da0bc4a44 | ||
|
|
91a0c51ff8 | ||
|
|
0aa523a329 | ||
|
|
cac7275eb9 | ||
|
|
c705fdfff0 | ||
|
|
1fc876cfea | ||
|
|
109eaf7d25 | ||
|
|
9ba15f2c19 | ||
|
|
1c07d787c5 | ||
|
|
b7ae2ea5fe | ||
|
|
b75bb204e3 | ||
|
|
bfc8006205 | ||
|
|
aab2e4a442 | ||
|
|
abfdfe014e | ||
|
|
f82040d2ef | ||
|
|
56f2cf3121 | ||
|
|
21011c548e | ||
|
|
6349f07d1a | ||
|
|
1b44559d3e | ||
|
|
a151e60755 | ||
|
|
ce11c84e74 | ||
|
|
9808bf86c4 | ||
|
|
cfae636e55 | ||
|
|
ebaaf50df6 | ||
|
|
5c0be9e89f | ||
|
|
36468663f7 | ||
|
|
fba32608ee | ||
|
|
06848e50c3 | ||
|
|
879d0d4916 | ||
|
|
d083a58cd7 | ||
|
|
b1e9ff9fdc | ||
|
|
304280f415 | ||
|
|
2c8ca1421f | ||
|
|
3ce0fb9f75 | ||
|
|
8a71d2abd6 | ||
|
|
1b174f4eac | ||
|
|
f1d18c7b41 | ||
|
|
204d4607ba | ||
|
|
51f7ce0cb6 | ||
|
|
8f73deb133 | ||
|
|
1d4147309c | ||
|
|
a68e4c1456 | ||
|
|
2ee51363dd | ||
|
|
172eb37b5b | ||
|
|
68e1d8ea69 | ||
|
|
ac8e8db0e7 | ||
|
|
d72bf9b76c | ||
|
|
6d3f535d16 | ||
|
|
0709763f3a | ||
|
|
538d843643 | ||
|
|
2339ee928c | ||
|
|
9550b951d5 | ||
|
|
0491af8a2f | ||
|
|
806a2757b2 | ||
|
|
3931b71d00 | ||
|
|
af0c3d5f62 | ||
|
|
c7a6ca4555 | ||
|
|
4a01e2eb49 | ||
|
|
d6ff20b35d | ||
|
|
0ada9aa105 | ||
|
|
6b04539571 | ||
|
|
9380ec13dc | ||
|
|
ae946c27c0 | ||
|
|
86cf00759f | ||
|
|
0eb5f55d63 | ||
|
|
f27d2aa7eb | ||
|
|
2d3285aaaf | ||
|
|
765c56ccef | ||
|
|
02255180e9 | ||
|
|
886958d479 | ||
|
|
84cbc19f38 | ||
|
|
178ec9dfa9 | ||
|
|
e774ef5751 | ||
|
|
5d3f8bf073 | ||
|
|
dd88db1913 | ||
|
|
aab00567fc | ||
|
|
21cb6135dd | ||
|
|
07948c87aa | ||
|
|
4543a10739 | ||
|
|
daecf2017e | ||
|
|
37122bc619 | ||
|
|
0d17c099e9 | ||
|
|
85da10ef24 | ||
|
|
7f91ec2852 |
@@ -1,18 +1,44 @@
|
||||
**NOTE: This is not a support forum! For questions and support go here: https://www.letscontrolit.com/forum/viewforum.php?f=1**
|
||||
<!--- If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! --->
|
||||
<!--- NOTE: This is not a support forum! For questions and support go here: --->
|
||||
<!--- https://www.letscontrolit.com/forum/viewforum.php?f=1 --->
|
||||
<!--- Remove topics that are not applicable to your feature request of issue --->
|
||||
<!--- Remember to have a "to the point" TITLE --->
|
||||
|
||||
### Steps to reproduce
|
||||
How can we trigger this problem?
|
||||
|
||||
Does the problem persists after powering off and on? (just resetting isn't enough sometimes)
|
||||
### Summarize of the problem/feature request
|
||||
<!--- Describe the problem or feature request --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
### Expected behavior
|
||||
Tell us what should happen?
|
||||
<!--- Tell us what should happen? --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
### Actual behavior
|
||||
Tell us what happens instead?
|
||||
<!--- Tell us what happens instead? --->
|
||||
YOUR TEXT GOES HERE
|
||||
|
||||
### Steps to reproduce
|
||||
<!--- How can we trigger this problem? --->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
<!--- Does the problem persists after powering off and on? (just resetting isn't enough sometimes) --->
|
||||
<!--- Please document if you have restarted the unit and if the problem is then gone etc. etc. --->
|
||||
### System configuration
|
||||
|
||||
<!--- Please add as much information and screenshots as possible --->
|
||||
Hardware:
|
||||
|
||||
Software or git version:
|
||||
<!--- You should also provide links to hardware pages etc where we can find more info --->
|
||||
<!--- If you self compile, please state this and PLEASE try to ONLY REPORT ISSUES WITH OFFICIAL BUILDS! --->
|
||||
ESP Easy version:
|
||||
|
||||
<!--- In order to have a better readablity of your issue then you should place screenshots here --->
|
||||
<!--- Simply drag and drop them onto this template, move the text string below the "ESP Easy settings/screenshots" topic --->
|
||||
ESP Easy settings/screenshots:
|
||||
|
||||
### Rules or log data
|
||||
<!--- place your code/rules between the two ``` rows --->
|
||||
<!--- remove if not applicable! --->
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
@@ -16,3 +16,5 @@
|
||||
## Project #####################
|
||||
lib/readme.txt
|
||||
src/Custom.h
|
||||
/ESPEasy
|
||||
test/output_export.cpp
|
||||
|
||||
+3
-1
@@ -27,11 +27,13 @@ install:
|
||||
script:
|
||||
# - cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
|
||||
# - ./memanalyzer.py ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-objdump
|
||||
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
|
||||
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
|
||||
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
|
||||
|
||||
# patch platformio core libs for PUYA bug (https://github.com/letscontrolit/ESPEasy/issues/650)
|
||||
- cd patches; ./check_puya_patch; cd ..
|
||||
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
|
||||
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
|
||||
|
||||
|
||||
before_deploy:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
The scripts in this directory are so called GIT hooks.
|
||||
Purpose is to do automatic changes after merge, commit and checkout.
|
||||
|
||||
Those files are for a Linux-like environment with basic tools ln, grep, sed and bash.
|
||||
|
||||
Windows users can see them as template.
|
||||
|
||||
To use them simply copy those files into your ESPEasy/.git/hooks directory.
|
||||
@@ -1,6 +1,9 @@
|
||||
# ESPEasy (development branch)
|
||||
|
||||
Build status: [](https://travis-ci.org/letscontrolit/ESPEasy)
|
||||
Badge | Info |
|
||||
-------|-------|
|
||||
[](https://travis-ci.org/letscontrolit/ESPEasy) | build status |
|
||||
[](https://github.com/letscontrolit/ESPEasy/releases/latest) | latest nightly |
|
||||
|
||||
Introduction and wiki: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Introduction
|
||||
|
||||
|
||||
+6
-3
@@ -18,13 +18,16 @@ for ENV in \
|
||||
dev_ESP8266_4096\
|
||||
dev_ESP8285_1024\
|
||||
dev_ESP8266PUYA_1024\
|
||||
dev_ESP8266PUYA_1024_VCC;\
|
||||
dev_ESP8266PUYA_1024_VCC\
|
||||
hard_SONOFF_POW\
|
||||
esp32dev;\
|
||||
do
|
||||
echo
|
||||
echo "### Deploying environment $ENV for version $VERSION"
|
||||
BIN=.pioenvs/$ENV/firmware.bin
|
||||
BIN=.pioenvs/${ENV}/ESP_Easy_${VERSION}_${ENV}.bin
|
||||
cp .pioenvs/${ENV}/firmware.bin $BIN
|
||||
python2 crc2.py $BIN
|
||||
cp $BIN dist/"ESP_Easy_$VERSION""_$ENV.bin"
|
||||
mv $BIN "dist/ESP_Easy_${VERSION}_${ENV}.bin"
|
||||
done
|
||||
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import struct
|
||||
import md5
|
||||
import os
|
||||
MD5DUMMY = "MD5_MD5_MD5_MD5_BoundariesOfTheSegmentsGoHere..." #48 chars
|
||||
FILENAMEDUMMY = "ThisIsTheDummyPlaceHolderForTheBinaryFilename..." #48 chars
|
||||
FILENAMEDUMMY = "ThisIsTheDummyPlaceHolderForTheBinaryFilename64ByteLongFilenames" #64 chars
|
||||
|
||||
MemorySegmentStart,MemorySegmentEnd,MemoryContent=[],[],[]
|
||||
|
||||
|
||||
##################################################################
|
||||
# this subroutine shows the segments of a part
|
||||
##################################################################
|
||||
@@ -18,7 +18,7 @@ def showSegments (fileContent,offset):
|
||||
herestr =""
|
||||
herestr2 =""
|
||||
MemorySegmentStart.append(struct.pack("I",header[0]))
|
||||
MemorySegmentEnd.append(struct.pack("I",header[0]+header[1]))
|
||||
MemorySegmentEnd.append(struct.pack("I",header[0]+header[1]))
|
||||
MemoryContent.append(fileContent[offset+8:offset+8+header[1]])
|
||||
if fileContent.find( MD5DUMMY, offset+8, offset+8+header[1]) >0 :
|
||||
herestr= " <-- CRC is here."
|
||||
@@ -42,7 +42,7 @@ def showParts(fileContent, offset):
|
||||
return nextSegmentOffset
|
||||
|
||||
##################################################################
|
||||
# MAIN
|
||||
# MAIN
|
||||
##################################################################
|
||||
|
||||
#if len(sys.argv) !=2 :
|
||||
@@ -71,46 +71,46 @@ includeStr = "hash includes segments:"
|
||||
# 4: RAM
|
||||
|
||||
for i in (1,2 ): # use only stable segments, must be 4 in total. We use 2.
|
||||
startArray =startArray + MemorySegmentStart[i]
|
||||
endArray = endArray + MemorySegmentEnd[i]
|
||||
startArray =startArray + MemorySegmentStart[i]
|
||||
endArray = endArray + MemorySegmentEnd[i]
|
||||
hashString =hashString + MemoryContent[i]
|
||||
with open(FileName+str(i), mode='wb') as file: # b is important -> binary
|
||||
file.write(MemoryContent[i])
|
||||
includeStr = includeStr +" "+ str(i)
|
||||
print (includeStr)
|
||||
# IMPORTANT: pad array with zeros if you use only 3 segments (see above)
|
||||
while len(startArray) < 16 :
|
||||
startArray =startArray + struct.pack("I",0)
|
||||
endArray = endArray + struct.pack("I",0)
|
||||
# debug print (binascii.hexlify(startArray))
|
||||
# IMPORTANT: pad array with zeros if you use only 3 segments (see above)
|
||||
while len(startArray) < 16 :
|
||||
startArray =startArray + struct.pack("I",0)
|
||||
endArray = endArray + struct.pack("I",0)
|
||||
# debug print (binascii.hexlify(startArray))
|
||||
# debug print (binascii.hexlify(endArray))
|
||||
if (len(endArray) + len (startArray)) != 32 :
|
||||
print("ERROR: please make sure you add / remove padding if you change the semgents.")
|
||||
print("ERROR: please make sure you add / remove padding if you change the semgents.")
|
||||
|
||||
BinaryFileName = "";
|
||||
if fileContent.find( FILENAMEDUMMY) < 0:
|
||||
print("ERROR: FILENAMEDUMMY dummy not found in binary")
|
||||
else:
|
||||
BinaryFileName=os.path.basename(FileName) +"\0"
|
||||
if len(BinaryFileName) >48: # check that filename is <48 chars
|
||||
BinaryFileName=BinaryFileName[0:48] # truncate if necessary. 49th char in ESP is zero already
|
||||
if len(BinaryFileName) >64: # check that filename is <48 chars
|
||||
BinaryFileName=BinaryFileName[0:64] # truncate if necessary. 49th char in ESP is zero already
|
||||
else:
|
||||
BinaryFileName= BinaryFileName.ljust(48,'\0'); # pad with zeros.
|
||||
|
||||
BinaryFileName= BinaryFileName.ljust(64,'\0'); # pad with zeros.
|
||||
|
||||
|
||||
if fileContent.find( MD5DUMMY) < 0:
|
||||
print("ERROR: MD5 dummy not found in binary")
|
||||
else:
|
||||
hashString=hashString.replace (MD5DUMMY,"",1)
|
||||
hashString=hashString.replace (MD5DUMMY,"",1)
|
||||
m = md5.new()
|
||||
m.update (hashString) #use segment 1
|
||||
md5hash = m.digest()
|
||||
print("MD5 hash: "+ m.hexdigest())
|
||||
print("\nwriting output file:\n" + FileName)
|
||||
|
||||
|
||||
fileContent=fileContent.replace(MD5DUMMY,md5hash+startArray+endArray)
|
||||
fileContent=fileContent.replace(FILENAMEDUMMY,BinaryFileName)
|
||||
|
||||
with open(FileName, mode='wb') as file: # b is important -> binary
|
||||
file.write(fileContent)
|
||||
#k=input("press close to exit")
|
||||
#k=input("press close to exit")
|
||||
|
||||
Vendored
+927
@@ -1,3 +1,930 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180710 (since mega-20180708)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Jul 10 04:00:12 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
P077: changed category to "energy"
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180708 (since mega-20180705)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Jul 8 04:00:08 CEST 2018
|
||||
|
||||
TD-er (1):
|
||||
[PIO build] Build issues caused by incorrect precompile processing
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180705 (since mega-20180625)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Jul 5 04:00:18 CEST 2018
|
||||
|
||||
Bartłomiej Zimoń (1):
|
||||
Update _C005.ino
|
||||
|
||||
TD-er (10):
|
||||
[CPU usage] Increase loop count
|
||||
[loop times] New timer statistics class to monitor performance
|
||||
[BMx280] Do not wait for measurements, collect async
|
||||
[Timing stats] Allow computing timing to estimate performance.
|
||||
[ESP32] Upgrade to new ESpressif32 version
|
||||
[PIO build] Use newer flag syntax for Travis
|
||||
[Stability] Add check for string length to isNumerical()
|
||||
[Stability] Use functions to get Webserver Arguments from POST messages.
|
||||
[PlatformIO] Update to Espressif32@1.1.1
|
||||
[info] Display ESP32 partition table
|
||||
|
||||
Tempura San (2):
|
||||
[WebUI] font-family set to monospace for TEXTAREA
|
||||
[WebUI] removed stray </div>
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180625 (since mega-20180624)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Jun 25 04:00:08 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[Arduino IDE] Fix build include path ESPEasy-Globals.h
|
||||
[PIO update] platform to espressif8266@1.7.3
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180624 (since mega-20180621)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Jun 24 04:00:29 CEST 2018
|
||||
|
||||
Saverio Cisternino (2):
|
||||
Implement CommandsManager
|
||||
Migration core command
|
||||
|
||||
TD-er (8):
|
||||
[AM2320] Explicit use boolean in Wire.endTransmission
|
||||
[JavaScript] Device measurement value update may sometimes fail
|
||||
[ArduinoJson] Update external library ArduinoJson.
|
||||
[SDS011] Set SDS011 Dust plugin to normal from testing
|
||||
[PlatformIO.ini] VScode needs `monitor_speed` and update ESP8266 platform
|
||||
[web log] Disable excessive web log about RAM usage
|
||||
[Cmd Exec] Add #ifndef #def statements to prevent multiple includes
|
||||
[Cmd Exec] Use switch statement instead of lookup map
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180621 (since mega-20180619)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Jun 21 04:00:14 CEST 2018
|
||||
|
||||
Saverio Cisternino (2):
|
||||
Fixed Issue #1489
|
||||
Show in devices list port number in hex
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180619 (since mega-20180618)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Jun 19 04:00:10 CEST 2018
|
||||
|
||||
TD-er (4):
|
||||
[ESP32] Allow flashing to ESP32 again from PlatformIO
|
||||
[ESP32] Set build to @0.12.0
|
||||
[OTA] Output proper port number when ARDUINO_FEATURE_OTA is set
|
||||
[ESP8285] PlatformIO set max upload size limit
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180618 (since mega-20180615)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Jun 18 04:00:12 CEST 2018
|
||||
|
||||
Steffen Lange (2):
|
||||
Add GPS coordinates to Advanced Settings
|
||||
Add %sunrise% and %sunset% variables
|
||||
|
||||
TD-er (1):
|
||||
[#1494] Disabled ping to check if host is reachable
|
||||
|
||||
stefan (1):
|
||||
Ammended central I2C fuctions (#1417)
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180615 (since mega-20180614)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Jun 15 04:00:11 CEST 2018
|
||||
|
||||
TD-er (1):
|
||||
[1M flash warning] Warn for OTA when 1M flash present
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180614 (since mega-20180613)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Jun 14 04:00:11 CEST 2018
|
||||
|
||||
Gijs Noorlander (2):
|
||||
[#1502] Change wait-to-connect timeout to 12 sec.
|
||||
[#1503] Use proper timeout on BME280/BMP280
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180613 (since mega-20180611)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Jun 13 04:00:15 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
[BMx280] Correct nr values for special sensor type
|
||||
|
||||
TD-er (2):
|
||||
[Diag] Log Reset Reason at boot for ESP8266 and ESP32
|
||||
[BMx280] Send data from BMP280 as temp_baro, not temp_hum_baro
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180611 (since mega-20180606)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Jun 11 04:00:21 CEST 2018
|
||||
|
||||
Saverio Cisternino (1):
|
||||
Fixed issue when there is more PCA9685
|
||||
|
||||
TD-er (6):
|
||||
[#1417] Move I2C functions to a separate file
|
||||
[I2Cdev] Add I2Cdevlib library
|
||||
[I2C] Disable calls to wire.begin() from libraries
|
||||
[#1484] Multiple instances of ultrasonic sensors
|
||||
[PlatformIO] Added libraries to be able to use std::map
|
||||
[BME/BMP280] Improve temperature/humidity readout
|
||||
|
||||
Tempura San (1):
|
||||
[MQTT Import] system variables support for topics
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180606 (since mega-20180524)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Jun 6 04:00:17 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
[GPIO command] work-around as long as gpio command is still performed in P001_switch.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180524 (since mega-20180522)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu May 24 04:00:14 CEST 2018
|
||||
|
||||
Saverio Cisternino (25):
|
||||
Allows plugin to intercept PLUGIN_WRITE and PLUGIN_REQUEST, when there is more tasks of same plugin type but different configuration.
|
||||
Allow escape char [ and ] for use with comannd and rule containde space es [Extra 2]#Go
|
||||
Allow PLUGIN_TIMER_IN TaskIndex
|
||||
-Arminizze type of ParX of systemTimerStruct with EventStruct to prevent truncation issue -Add setSystemTimer overload
|
||||
EventStruct copy ctor
|
||||
Allow using two oled at same time.
|
||||
Allow custom mqtt lwt topic
|
||||
Allow custom lwt message
|
||||
Allow use Unit Name as MQTT ClientId
|
||||
Allows plugin to intercept PLUGIN_WRITE and PLUGIN_REQUEST, when there is more tasks of same plugin type but different configuration.
|
||||
Allow escape char [ and ] for use with comannd and rule containde space es [Extra 2]#Go
|
||||
Allow PLUGIN_TIMER_IN TaskIndex
|
||||
-Arminizze type of ParX of systemTimerStruct with EventStruct to prevent truncation issue -Add setSystemTimer overload
|
||||
EventStruct copy ctor
|
||||
ExecuteCommand intercept Par4 and Par5
|
||||
PCA9685: Allow select address.
|
||||
PCA9685: Allow named istance commands for execute command on specific task when there is more PCA9685 task.
|
||||
PCA9685: Add Pin e PWM validation
|
||||
PCA9685: show address in hex.
|
||||
PCA9685: Allow use pwm alias when call instance command es: Extender.pwm 1, 1000
|
||||
PCA9685: Add pcafrq arg validation
|
||||
PCA9685: Allow use frq alias when call instance command es: Extender.frq 100
|
||||
PCA9685: Add support at commad gpio on name instance call
|
||||
PCA9685: Add named istance pulse command. Es: Extend.pulse 0,1,50,auto gnenerate pulse on gpio 0 with duration of 50 ms an autorestart after 50 ms
|
||||
PCA9685: Add support at command [TaskName].gpio all,1 | 0 which allows you to turn on (1) or turn off (0) all gpio of expander.
|
||||
|
||||
Susis Strolch (3):
|
||||
GIT hooks: post-merge, post-commit, post-checkout
|
||||
add missing & around value, add README
|
||||
add missing & around value
|
||||
|
||||
TD-er (1):
|
||||
[CI build] Small fix to prevent Travis CI build errors.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180522 (since mega-20180519)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue May 22 04:00:14 CEST 2018
|
||||
|
||||
Daniel Tedenljung (1):
|
||||
Add note for PulseCounter
|
||||
|
||||
Plebs (1):
|
||||
Added 10 new commands for serial port configuration
|
||||
|
||||
TD-er (1):
|
||||
[P077] CSE7766 - Energy (Sonoff S31 and Sonoff Pow R2)
|
||||
|
||||
stefan (1):
|
||||
Add CSE7766 for Sonoff POW R2 to plugin_sets
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180519 (since mega-20180518)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat May 19 04:00:07 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
[tools page] added a function for wide buttons
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180518 (since mega-20180517)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri May 18 04:00:07 CEST 2018
|
||||
|
||||
Grovkillen (3):
|
||||
[JavaScript] made static variables "const"
|
||||
[tools page] wider buttons
|
||||
[tools page] Center text, factory reset is red
|
||||
|
||||
TD-er (1):
|
||||
[#1431] Add DataAcquisition to /json and reduce json for sensor updates
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180517 (since mega-20180516)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu May 17 04:00:08 CEST 2018
|
||||
|
||||
Gijs Noorlander (2):
|
||||
Update _C012.ino
|
||||
Update WebServer.ino
|
||||
|
||||
TD-er (1):
|
||||
[Flash strings] Store more strings into flash to keep memory usage low
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180516 (since mega-20180515)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed May 16 04:00:09 CEST 2018
|
||||
|
||||
Grovkillen (7):
|
||||
Added Github logo (for button)
|
||||
[sysinfo page] added GitHub copy
|
||||
[sysinfo page] added CSS to GitHub copy button
|
||||
[sysinfo page] Added GitHub button to TXBuffer
|
||||
[sysinfo page] fixed layout of button
|
||||
[web log] bugfix for empty logJSON stings
|
||||
[web log] error capture of lower log levels
|
||||
|
||||
Plebs (1):
|
||||
Another small fix for #1426
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180515 (since mega-20180514)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue May 15 04:00:11 CEST 2018
|
||||
|
||||
Grovkillen (6):
|
||||
[web log] Chunk transfer instead of line transfer
|
||||
[web log] Added declaring of reRunCount
|
||||
[web log] added the reRunCout to the function
|
||||
[web log] added warning if IE11 or older is used
|
||||
[fix for crc2.py] truncation corrupted bin file
|
||||
Added latest nightly release badge
|
||||
|
||||
Plebs (1):
|
||||
fix for #1426
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180514 (since mega-20180513)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon May 14 04:00:09 CEST 2018
|
||||
|
||||
Plebs (1):
|
||||
Added more #formats transformations
|
||||
|
||||
TD-er (5):
|
||||
[#1411] Add SensorTypeNone to indicate no sensor values for Domoticz
|
||||
[memory] use "-DNDEBUG" to disable ASSERT macros
|
||||
[issue #1380] Prevent memory leaks in WiFiClient
|
||||
[memory corruption] LWIP data corrupts log buffer
|
||||
[ESP32] ESP.getResetReason() is unknown to ESP32
|
||||
|
||||
ZericE (6):
|
||||
[#1404] Fix email notification for RFC2821, fix so msg body included.
|
||||
undo unnecessary changes in email body
|
||||
remove debug lines in email notify
|
||||
updated comment
|
||||
remove unneeded use of bMesg to free up mem.
|
||||
use reference to free up mem.
|
||||
|
||||
flexiti (4):
|
||||
Improvement in the file platformio.ini
|
||||
OTA check box
|
||||
ESP32 OTA port is set to 3232
|
||||
ESP32 OTA port setting
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180513 (since mega-20180512)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun May 13 04:00:08 CEST 2018
|
||||
|
||||
Gijs Noorlander (2):
|
||||
Fix debug code (commented) in _P045_MPU6050.ino
|
||||
[PR #1304] Rename file before running crc2.py
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180512 (since mega-20180511)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat May 12 04:00:06 CEST 2018
|
||||
|
||||
Grovkillen (15):
|
||||
Fixed the timers for log + devices
|
||||
Fixed format (I like tabs, Platformio like spaces)
|
||||
Preparation for fixed decimals...
|
||||
Removed a timer reset...
|
||||
Fixed some small syntax missing
|
||||
Added check to stop flooding
|
||||
Fixed scrolling issue when fetch <450mSec
|
||||
Fix for decimals on auto update device page
|
||||
Added ";"
|
||||
[web log] fixed overflow when set to "debug dev"
|
||||
[web log] fixed wait on requests
|
||||
[device page] added max request here too
|
||||
[web log] also taking care of disconnects
|
||||
[device page] added dynamic length to loop
|
||||
[web log] safety net not needed anymore
|
||||
|
||||
TD-er (2):
|
||||
[JSON] Add number of decimals to the JSON output
|
||||
[build] Do builds twice on the nightly builds
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180511 (since mega-20180510)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri May 11 04:00:08 CEST 2018
|
||||
|
||||
TD-er (3):
|
||||
[cleanup] Simplify formatting user variables and allow checking
|
||||
[log JSON] Add log level legend to the logjson output
|
||||
[Web] Improve serving large blobs directly from flash
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180510 (since mega-20180507)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu May 10 04:00:13 CEST 2018
|
||||
|
||||
Grovkillen (7):
|
||||
First draft of auto update of task/device values
|
||||
Values are updated (1-4 values per task)
|
||||
Wrap up for the PR
|
||||
Added div to web log (color scheme)
|
||||
Removed auto update of values... wrong branch
|
||||
Fixed the log level colors
|
||||
Fixed copy to clipboard (handle HTML tags)
|
||||
|
||||
Saverio Cisternino (1):
|
||||
Fix plugin_id visualization on devices view that afflict Development build
|
||||
|
||||
TD-er (2):
|
||||
[build] Special build config for Ventus W266
|
||||
[Ventus W266] Fix signed/unsigned warning
|
||||
|
||||
ZericE (1):
|
||||
[#1368] Remove call to Plugin_041_update causing a hard crash.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180507 (since mega-20180506)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon May 7 04:00:08 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
[issue template] extra reminder to self compilers
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180506 (since mega-20180505)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun May 6 04:00:08 CEST 2018
|
||||
|
||||
Grovkillen (10):
|
||||
Added javascript to handle the log entries
|
||||
Added div to not copy "Fetching log entries...."
|
||||
Web log now inside a textarea
|
||||
If error make log show this more clear
|
||||
Added break...
|
||||
BR should be \n, now fixed
|
||||
Forgot extra \ for escape in code
|
||||
Added some "-"
|
||||
Updated to compile with TD-er's update on JSON
|
||||
Forgot the auto-scroll function... now added
|
||||
|
||||
Plebs (2):
|
||||
fix for #960
|
||||
new command logentry
|
||||
|
||||
TD-er (5):
|
||||
[JSON] Use streaming webserver for serving JSON page
|
||||
[JSON] Make proper log JSON output for log viewer
|
||||
[JSON] Sanitize JSON value strings
|
||||
[JSON] Add TTL, task interval and task enabled
|
||||
[JSON] Fix for single task view of json output.
|
||||
|
||||
ZericE (1):
|
||||
[#1356] Remove redundant call to MQTTCheck
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180505 (since mega-20180505_TD-er)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat May 5 04:00:07 CEST 2018
|
||||
|
||||
TD-er (2):
|
||||
[#1337] Include hidden SSID in wifi scans
|
||||
[#1337] WiFi.isHidden() is unknown to ESP32
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180504 (since mega-20180503)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri May 4 04:00:10 CEST 2018
|
||||
|
||||
Grovkillen (3):
|
||||
Added dropdown for phones
|
||||
[#1363] fixed overlapping checkboxes
|
||||
Added a break under the hamburger
|
||||
|
||||
TD-er (3):
|
||||
[rules timer] revert treating the rules timer as periodical timer
|
||||
[Settings] Add checks to investigate issues with overlap in settings
|
||||
[LWIP2] Change LWIP1.4 => LWIP2 Low Memory
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180503 (since mega-20180502)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu May 3 04:00:12 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
Spelling correction
|
||||
|
||||
TD-er (3):
|
||||
[rules] Make rules start working again.
|
||||
[timers] Make rules timers more constant and MQTT reconnect less aggressive
|
||||
[#1353] Remove Domoticz HTTP as default controller
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180502 (since mega-20180501)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed May 2 04:00:16 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
Added log JSON
|
||||
|
||||
Plebs (4):
|
||||
fix for #1170
|
||||
fix for #1142
|
||||
deleted comments
|
||||
Added 2 system variables
|
||||
|
||||
Saverio Cisternino (1):
|
||||
Optimize setSystemTimer; Removed the second "for" cycle for checking the availability of timers
|
||||
|
||||
TD-er (5):
|
||||
[LWIP 1.4.0] Change to LWIP 1.4.0, to allow large http POST messages
|
||||
[LWIP] fix ESP32 build
|
||||
[timers] Make timers more accurate
|
||||
[wifi] Make retry intervals to connect increase at each attempt.
|
||||
[web log] Read all items from the log buffer
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180501 (since mega-20180430)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue May 1 04:00:17 CEST 2018
|
||||
|
||||
mvdbro (1):
|
||||
Fix broken Mini Dashboard feature
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180430 (since mega-20180429)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Apr 30 04:00:08 CEST 2018
|
||||
|
||||
TD-er (4):
|
||||
[wifi] Do not rely on WiFi.status() and better log of status
|
||||
[wifi] Use internal ESPeasy state to check connected status
|
||||
[rules] Add log indicating POST request for update rules
|
||||
[MQTT] Set default timeout to 10 sec, equal to default Mosquito timeout
|
||||
|
||||
mvdbro (1):
|
||||
Changed plugin call debug timers
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180429 (since mega-20180428)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Apr 29 04:00:07 CEST 2018
|
||||
|
||||
TD-er (7):
|
||||
[wifi] Setup static IP config after connecting to wifi.
|
||||
[wifi] Set static IP config before and after connect
|
||||
[wifi] Show number of reconnects in the sysinfo
|
||||
[wifi] Add wifi status log (Debug More) and DHCP/Static config to info page
|
||||
[wifi] ESP32 does not know wifi_station_get_connect_status()
|
||||
[wifi] Added connectionCheckHandler() to force reconnect when needed
|
||||
[wifi] Force wifi reconnect at lots of MQTT failed connects.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180428 (since mega-20180426)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Apr 28 04:00:15 CEST 2018
|
||||
|
||||
TD-er (4):
|
||||
[wifi] Attempt to make event based wifi simpler
|
||||
[PlatformIO] Updated core to 2.4.1
|
||||
[wifi] Just disconnect when DNS lookup is not possible
|
||||
[Wifi] Avoid doing network communications when not connected.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180426 (since mega-20180425)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Apr 26 04:00:14 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Change use of core 2_4_0 to 2_3_0
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180425 (since mega-20180424)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Wed Apr 25 04:00:08 CEST 2018
|
||||
|
||||
Grovkillen (4):
|
||||
Added a void addCopyButton
|
||||
Made copy to clipboard JavaScript based instead
|
||||
Added copy to clipboard on log page
|
||||
Added new lines if BR + delimiter if wanted
|
||||
|
||||
Plebs (3):
|
||||
Fix for #1300
|
||||
Adding 3 new http commands: taskrun, taskvalueset and rules
|
||||
Fix another bug in LCD plugin
|
||||
|
||||
TD-er (2):
|
||||
[Modbus] PR #1128 made by @s0170071
|
||||
[wifi] More active reconnect to wifi when disconnected
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180424 (since mega-20180423)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Apr 24 04:00:13 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
Added note to self compilers
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180423 (since mega-20180422)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Apr 23 04:00:10 CEST 2018
|
||||
|
||||
Plebs (1):
|
||||
Fixing #1289 for backwards compatibility
|
||||
|
||||
TD-er (1):
|
||||
[wifi] Add delay between connection attempts
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180422 (since mega-20180421)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Apr 22 04:00:09 CEST 2018
|
||||
|
||||
Plebs (2):
|
||||
Syntax: [task#value#transformation#justification]
|
||||
Code changed as per TD-er suggestions
|
||||
|
||||
TD-er (1):
|
||||
[issue #1292] Remove CRC from settings, init settings and wifi fixes
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180421 (since mega-20180420)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Apr 21 04:00:08 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
Removed fade in of body added toast message!
|
||||
|
||||
Saverio Cisternino (4):
|
||||
Add Commands timerpause and timerresume
|
||||
Add Trigger Rules#TimerPause= and Rules#TimerResume=
|
||||
Add support at elseif statment
|
||||
Add debug info
|
||||
|
||||
TD-er (7):
|
||||
[WiFi] Init static IP before connect to wifi
|
||||
[Toast message] Change "Settings saved" to "Submitted"
|
||||
[info] Add more build related info to the log and wifi info link to wiki
|
||||
[Sonoff Pow] Add support for HLW8012
|
||||
[Sonoff Pow] Add support for HLW8012
|
||||
[Sonoff POW] Change Plugin ID to 76
|
||||
[Sonoff POW] Set some proper defaults for the Sonoff POW
|
||||
|
||||
Unknown (2):
|
||||
Merge remote-tracking branch 'papperone/mega' into merge/papperone
|
||||
Merge remote-tracking branch 'papperone/mega' into merge/papperone
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180420 (since mega-20180419)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Apr 20 04:00:09 CEST 2018
|
||||
|
||||
Grovkillen (3):
|
||||
Added small fade in (0.5s)
|
||||
"bodymenu" was accidentally copied to all body
|
||||
Added extra breaks below "back to setup" button
|
||||
|
||||
TD-er (4):
|
||||
[Static IP] Make sure static mode is set correct always
|
||||
[wifi] Restart webserver when connection changes.
|
||||
[log] Make web log 30 lines for ESP32
|
||||
[wifi] Create event 'gotIP' after processing 'connected' event
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180419 (since mega-20180417)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Apr 19 04:00:17 CEST 2018
|
||||
|
||||
Grovkillen (3):
|
||||
Updated the input, select, textareas with CSS
|
||||
Added CSS radio buttons to WiFi setup wizard
|
||||
Removed unused row on hardware settings page
|
||||
|
||||
Hans-Rune Bue (1):
|
||||
Implemented syslog facilities and levels
|
||||
|
||||
TD-er (3):
|
||||
[Static IP] Work-around for set _use_static_ip
|
||||
[PR #1257] Make it compile again
|
||||
[ESP32] Add Generic info plugin
|
||||
|
||||
sentinel073 (2):
|
||||
Issue #1211: Plugin template file and hints on writing new plugins
|
||||
Issue #1211: Plugin template file and hints on writing new plugins Added review comments
|
||||
|
||||
stefan (1):
|
||||
Changes for use of plugin sets
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180417 (since mega-20180416)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Apr 17 04:00:09 CEST 2018
|
||||
|
||||
Grovkillen (11):
|
||||
Put borders around checkboxes
|
||||
Re-arranged Rules page
|
||||
Moved help button for sleep
|
||||
Moved help button on hardware page
|
||||
Made controller symbols a bit bigger (1)(2)(3)
|
||||
Change enable "off" to a nicer X
|
||||
Made input type password part of "wide"
|
||||
Added number input to CSS (width 100px)
|
||||
Made IDX column wider (device list)
|
||||
Added max widths for inputs
|
||||
"Ctr (IDX)" was accidentally removed, now added
|
||||
|
||||
TD-er (5):
|
||||
[wifi] Fix wifi reconnects with static IP
|
||||
[NTP] Add more information in the log when connecting to NTP server fail
|
||||
[issue #1260] parentheses error on the json page
|
||||
[P075] Nextion plugin (testing)
|
||||
[wifi] Fix build error for ESP32
|
||||
|
||||
Unknown (1):
|
||||
[Nextion] Initial support for Nextion displays
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180416 (since mega-20180415)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Apr 16 04:00:09 CEST 2018
|
||||
|
||||
TD-er (4):
|
||||
[wifi] Prevent starting AP+STA mode with correct settings
|
||||
[Wifi] force STA mode at boot
|
||||
[wifi] Proper log of static IP configuration
|
||||
[info] Added FW information to help diagnose issues
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180415 (since mega-20180414)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sun Apr 15 04:00:08 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
Added C013
|
||||
|
||||
Grovkillen (6):
|
||||
Made checkmarks CSS
|
||||
Fixed missed update.
|
||||
Added column width for separator...
|
||||
Updated some more stuff
|
||||
Made addFormSeparator function a lot cleaner
|
||||
Bumped delay timer for MQTT pub 10mSec
|
||||
|
||||
Nuno Sousa (1):
|
||||
Replace ultrasonic plugin with NewPing lib
|
||||
|
||||
Susis Strolch (4):
|
||||
add missing USES_XXX to _C*.ino, _N*.ino
|
||||
system variables %sysheap%, %syssec_d
|
||||
ignore power-on reset value (85.0 °C)
|
||||
DS_readTemp: handle power-on reset value
|
||||
|
||||
TD-er (4):
|
||||
[WebServer] Cleanup of all functions appending to a big string
|
||||
[PR #1247 ] Merged PR into the refactoring of Webserver
|
||||
[PR #1248] Fixed textarea sizes
|
||||
[Merge] Easier to merge, rebased on Mega branch.
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180414 (since mega-20180413)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Apr 14 04:00:08 CEST 2018
|
||||
|
||||
GHolli (3):
|
||||
Update _P049_MHZ19.ino
|
||||
Change comma to semicolon
|
||||
Downstream updates (#1)
|
||||
|
||||
Gerald (1):
|
||||
Update _P049_MHZ19.ino
|
||||
|
||||
Grovkillen (4):
|
||||
Added RSSI, BSSID, Channel to WifiScan/Setup
|
||||
Removed the serial print "done."
|
||||
Added better(?) format for tables
|
||||
Fixed main page!
|
||||
|
||||
Holli (2):
|
||||
It seems the offsets [3]..[4] for the detection range setting (command byte 0x99) are wrong in the latest online data sheet: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf According to the MH-Z19B data sheet version 1.2, valid from: 2017.03.22 (received 2018-03-07), the offset should be [6]..[7] instead. Fixing the implementation accordingly.
|
||||
Disable detection range commands by default.
|
||||
|
||||
Plebs (5):
|
||||
Fixes for #1208 and partial #1196
|
||||
modified float() call
|
||||
new #formats
|
||||
added more formats
|
||||
Added #I
|
||||
|
||||
TD-er (1):
|
||||
[issue #1239] %bssid% and %wi_ch% added as variables
|
||||
|
||||
clumsy-stefan (1):
|
||||
_P015_TSL2561 added Broadband and IR Values
|
||||
|
||||
linuxnico (1):
|
||||
add ds1822 definition to ds_read_temp function
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180413 (since mega-20180412)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Fri Apr 13 04:00:09 CEST 2018
|
||||
|
||||
TD-er (1):
|
||||
[wifi] Event based wifi, fix set AP and crash on start
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180412 (since mega-20180410)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Thu Apr 12 04:00:14 CEST 2018
|
||||
|
||||
Gijs Noorlander (1):
|
||||
[MQTT] Process MQTT loop on publish
|
||||
|
||||
TD-er (7):
|
||||
[issue #1215] Cannot login to accesspoint on new install
|
||||
[issue #1215] Cannot login to accesspoint on new install
|
||||
[Wifi] Use statemachine to move between Wifi states
|
||||
[WiFi] Event based wifi, now AP mode works
|
||||
[wifi] Make it work for ESP32 again
|
||||
[wifi] Fix wifi AP setup mode for ESP32.
|
||||
[wifi] Event based wifi, improve scan information.
|
||||
|
||||
flexiti (1):
|
||||
ESP CPU speed and ID
|
||||
|
||||
mvdbro (1):
|
||||
Reboot/Reset pin, build 20101 patch
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180410 (since mega-20180409)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Tue Apr 10 04:00:21 CEST 2018
|
||||
|
||||
Grovkillen (5):
|
||||
Added comments that will not show up on issues
|
||||
Update issue_template.md
|
||||
Update issue_template.md
|
||||
Update issue_template.md
|
||||
Update issue_template.md
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180409 (since mega-20180407)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Mon Apr 9 04:00:13 CEST 2018
|
||||
|
||||
mvdbro (2):
|
||||
Factory Reset (not enabled yet)
|
||||
Both reset/factoryreset option
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180407 (since mega-20180405)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: Sat Apr 7 04:00:12 CEST 2018
|
||||
|
||||
Grovkillen (1):
|
||||
Fixed clickable link www.letscontrolit.com (#1192)
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20180405 (since mega-20180403)
|
||||
-------------------------------------------------
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# purpose: GIT post-commit
|
||||
# change value of BUILD_GIT macro
|
||||
#
|
||||
WORKDIR=src
|
||||
CUSTOM_H=${WORKDIR}/Custom.h
|
||||
GLOBAL_H=${WORKDIR}/ESPEasy-Globals.h
|
||||
|
||||
# update BUILD_GIT on branch checkout
|
||||
[[ $3 == 1 && -f ${CUSTOM_H} ]] && \
|
||||
sed -i.bak -e "s/\(#define BUILD_GIT\).*/\1 \"$(git log -1 --pretty=format:%h HEAD)\"/" ${CUSTOM_H}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# purpose: GIT post-commit
|
||||
# change value of BUILD_GIT macro
|
||||
#
|
||||
WORKDIR=src
|
||||
CUSTOM_H=${WORKDIR}/Custom.h
|
||||
GLOBAL_H=${WORKDIR}/ESPEasy-Globals.h
|
||||
|
||||
[[ -f ${CUSTOM_H} ]] && \
|
||||
sed -i.bak -e "s/\(#define BUILD_GIT\).*/\1 \"$(git log -1 --pretty=format:%h HEAD)\"/" ${CUSTOM_H}
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
# build an include file to select plugins
|
||||
#
|
||||
WORKDIR=ESPEasy
|
||||
CUSTOM_H=${WORKDIR}/Custom.h
|
||||
GLOBAL_H=${WORKDIR}/ESPEasy-Globals.h
|
||||
|
||||
[[ -L ${WORKDIR} ]] || (
|
||||
ln -s src ${WORKDIR}
|
||||
)
|
||||
|
||||
# we expect that ${CUSTOM_H} always contains a "#define BUILD_GIT" macro
|
||||
[[ -f ${CUSTOM_H} ]] && (
|
||||
echo "post_merge: change BUILD_GIT"
|
||||
sed -i.bak -e "s/\(#define BUILD_GIT\).*/\1 \"$(git log -1 --pretty=format:%h HEAD)\"/" ${CUSTOM_H}
|
||||
)
|
||||
|
||||
# uncomment if you don't want to use the Custom.h include
|
||||
grep -q "^#define USE_CUSTOM_H" ${GLOBAL_H} || (
|
||||
sed -i -e "/[ \t]*#define ESPEASY_GLOBALS_H_/a #define USE_CUSTOM_H" ${GLOBAL_H}
|
||||
)
|
||||
+16
-16
@@ -1,25 +1,25 @@
|
||||
#include "AM2320.h"
|
||||
#include <Wire.h>
|
||||
//
|
||||
//
|
||||
// AM2321 Temperature & Humidity Sensor library for Arduino
|
||||
// Сделана Тимофеевым Е.Н. из AM2320-master
|
||||
|
||||
unsigned int CRC16(byte *ptr, byte length)
|
||||
{
|
||||
unsigned int crc = 0xFFFF;
|
||||
uint8_t s = 0x00;
|
||||
unsigned int CRC16(byte *ptr, byte length)
|
||||
{
|
||||
unsigned int crc = 0xFFFF;
|
||||
uint8_t s = 0x00;
|
||||
|
||||
while(length--) {
|
||||
crc ^= *ptr++;
|
||||
crc ^= *ptr++;
|
||||
for(s = 0; s < 8; s++) {
|
||||
if((crc & 0x01) != 0) {
|
||||
crc >>= 1;
|
||||
crc ^= 0xA001;
|
||||
} else crc >>= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
crc >>= 1;
|
||||
crc ^= 0xA001;
|
||||
} else crc >>= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
AM2320::AM2320()
|
||||
{
|
||||
@@ -28,7 +28,7 @@ AM2320::AM2320()
|
||||
int AM2320::Read()
|
||||
{
|
||||
byte buf[8];
|
||||
for(int s = 0; s < 8; s++) buf[s] = 0x00;
|
||||
for(int s = 0; s < 8; s++) buf[s] = 0x00;
|
||||
|
||||
Wire.beginTransmission(AM2320_address);
|
||||
Wire.endTransmission();
|
||||
@@ -37,10 +37,10 @@ int AM2320::Read()
|
||||
Wire.write(0x03);// запрос
|
||||
Wire.write(0x00); // с 0-го адреса
|
||||
Wire.write(0x04); // 4 байта
|
||||
if (Wire.endTransmission(1) != 0) return 1;
|
||||
if (Wire.endTransmission(true) != 0) return 1;
|
||||
delayMicroseconds(1600); //>1.5ms
|
||||
// считываем результаты запроса
|
||||
Wire.requestFrom(AM2320_address, 0x08);
|
||||
Wire.requestFrom(AM2320_address, 0x08);
|
||||
for (int i = 0; i < 0x08; i++) buf[i] = Wire.read();
|
||||
|
||||
// CRC check
|
||||
|
||||
+37
-37
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
This is a (Arduino) library for the BH1750FVI Digital Light Sensor.
|
||||
|
||||
|
||||
Description:
|
||||
http://www.rohm.com/web/global/products/-/product/BH1750FVI
|
||||
|
||||
|
||||
Datasheet:
|
||||
http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf
|
||||
|
||||
|
||||
Copyright (c) 2013 Alexander Schulz. All right reserved.
|
||||
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
@@ -31,10 +31,10 @@
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Erlaubt die I2C-Adresse des Sensors zu ändern.
|
||||
* Standardadresse: 0x23, Alternativadresse: 0x5C.
|
||||
* Erlaubt die I2C-Adresse des Sensors zu ändern.
|
||||
* Standardadresse: 0x23, Alternativadresse: 0x5C.
|
||||
* Es sind entsprechende Konstanten definiert: BH1750_DEFAULT_I2CADDR und BH1750_SECOND_I2CADDR.
|
||||
* Bei Nichtangabe wird die Standardadresse verwendet.
|
||||
* Bei Nichtangabe wird die Standardadresse verwendet.
|
||||
* Um die Alternativadresse zu nutzen, muss der Sensorpin 'ADR' des Chips auf VCC gelegt werden.
|
||||
*/
|
||||
AS_BH1750::AS_BH1750(uint8_t address) {
|
||||
@@ -44,23 +44,23 @@ AS_BH1750::AS_BH1750(uint8_t address) {
|
||||
|
||||
/**
|
||||
* Führt die anfängliche Initialisierung des Sensors.
|
||||
* Mögliche Parameter:
|
||||
* Mögliche Parameter:
|
||||
* - Modus für die Sensorauflösung:
|
||||
* -- RESOLUTION_LOW: Physische Sensormodus mit 4 lx Auflösung. Messzeit ca. 16ms. Bereich 0-54612.
|
||||
* -- RESOLUTION_NORMAL: Physische Sensormodus mit 1 lx Auflösung. Messzeit ca. 120ms. Bereich 0-54612.
|
||||
* -- RESOLUTION_HIGH: Physische Sensormodus mit 0,5 lx Auflösung. Messzeit ca. 120ms. Bereich 0-54612.
|
||||
* (Die Messbereiche können durch Änderung des MTreg verschoben werden.)
|
||||
* -- RESOLUTION_AUTO_HIGH: Die Werte im MTreg werden je nach Helligkeit automatisch so angepasst,
|
||||
* -- RESOLUTION_AUTO_HIGH: Die Werte im MTreg werden je nach Helligkeit automatisch so angepasst,
|
||||
* dass eine maximalmögliche Auflösung und Messbereich erziehlt werden.
|
||||
* Die messbaren Werte fangen von 0,11 lx und gehen bis über 100000 lx.
|
||||
* (ich weis nicht, wie genau die Werte in Grenzbereichen sind,
|
||||
* (ich weis nicht, wie genau die Werte in Grenzbereichen sind,
|
||||
* besonders bei hohen Werte habe ich da meine Zweifel.
|
||||
* Die Werte scheinen jedoch weitgehend linear mit der steigenden Helligkeit zu wachsen.)
|
||||
* Auflösung im Unteren Bereich ca. 0,13 lx, im mittleren 0,5 lx, im oberen etwa 1-2 lx.
|
||||
* Die Messzeiten verlängern sich durch mehrfache Messungen und
|
||||
* Die Messzeiten verlängern sich durch mehrfache Messungen und
|
||||
* die Änderungen von Measurement Time (MTreg) bis max. ca. 500 ms.
|
||||
*
|
||||
* - AutoPowerDown: true = Der Sensor wird nach der Messung in den Stromsparmodus versetzt.
|
||||
*
|
||||
* - AutoPowerDown: true = Der Sensor wird nach der Messung in den Stromsparmodus versetzt.
|
||||
* Das spätere Aufwecken wird ggf. automatisch vorgenommen, braucht jedoch geringfügig mehr Zeit.
|
||||
*
|
||||
* Defaultwerte: RESOLUTION_AUTO_HIGH, true
|
||||
@@ -73,8 +73,8 @@ bool AS_BH1750::begin(sensors_resolution_t mode, bool autoPowerDown) {
|
||||
#endif
|
||||
_virtualMode = mode;
|
||||
_autoPowerDown = autoPowerDown;
|
||||
|
||||
Wire.begin();
|
||||
|
||||
//Wire.begin(); called in ESPEasy framework
|
||||
|
||||
defineMTReg(BH1750_MTREG_DEFAULT); // eigentlich normalerweise unnötig, da standard
|
||||
|
||||
@@ -132,7 +132,7 @@ bool AS_BH1750::isPresent() {
|
||||
// Check I2C Adresse
|
||||
Wire.beginTransmission(_address);
|
||||
if(Wire.endTransmission()!=0) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check device: ist es ein BH1750
|
||||
@@ -141,10 +141,10 @@ bool AS_BH1750::isPresent() {
|
||||
//write8(BH1750_POWER_ON);
|
||||
selectResolutionMode(BH1750_ONE_TIME_LOW_RES_MODE);
|
||||
_hardwareMode=255;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// falls einmal-modus aktiv war, muss der Sensor geweckt werden
|
||||
powerOn();
|
||||
powerOn();
|
||||
}
|
||||
|
||||
// Prüfen, ob Werte auch wirklich geliefert werden (letztes Modus, ggf. wird auto-PowerDown ausgeführt)
|
||||
@@ -189,9 +189,9 @@ void AS_BH1750::powerDown() {
|
||||
* Sendet zum Sensor ein Befehl zum Auswahl von HardwareMode.
|
||||
*
|
||||
* Parameter:
|
||||
* - mode: s.o.
|
||||
* - mode: s.o.
|
||||
* - DelayFuncPtr: delay(n) Möglichkeit, eigene Delay-Funktion mitzugeben (z.B. um sleep-Modus zu verwenden).
|
||||
*
|
||||
*
|
||||
* Defaultwerte: delay()
|
||||
*
|
||||
*/
|
||||
@@ -256,17 +256,17 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ggf. PowerOn
|
||||
// ggf. PowerOn
|
||||
if(_autoPowerDown && _valueReaded){
|
||||
powerOn();
|
||||
}
|
||||
|
||||
// Das Automatische Modus benötigt eine Sonderbehandlung.
|
||||
// Zuerst wird die Helligkeit im LowRes-Modus gelesen,
|
||||
// Zuerst wird die Helligkeit im LowRes-Modus gelesen,
|
||||
// je nach Bereich (dunkel, normal, sehr hell) werden die Werte von MTreg gesetzt und
|
||||
// danach wird die eigentliche Messung vorgenommen.
|
||||
/*
|
||||
Die feste Grenzwerte verursachen möglicherweise einen 'Sprung' in der Messkurve.
|
||||
Die feste Grenzwerte verursachen möglicherweise einen 'Sprung' in der Messkurve.
|
||||
In diesem Fall wäre eine laufende Anpassung von MTreg in Grenzbereichen vermutlich besser.
|
||||
Für meine Zwecke ist das jedoch ohne Bedeutung.
|
||||
*/
|
||||
@@ -282,8 +282,8 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
|
||||
if(level<10) {
|
||||
#if BH1750_DEBUG == 1
|
||||
Serial.println("level 0: dark");
|
||||
#endif
|
||||
// Dunkel, Empfindlichkeit auf Maximum.
|
||||
#endif
|
||||
// Dunkel, Empfindlichkeit auf Maximum.
|
||||
// Der Wert ist zufällig. Ab ca. 16000 wäre diese Vorgehnsweise möglich.
|
||||
// Ich brauche diese Genauigkeit aber nur in den ganz dunklen Bereichen (zu erkennen, wann wirklich 'dunkel' ist).
|
||||
defineMTReg(BH1750_MTREG_MAX);
|
||||
@@ -294,16 +294,16 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
|
||||
else if(level<32767) {
|
||||
#if BH1750_DEBUG == 1
|
||||
Serial.println("level 1: normal");
|
||||
#endif
|
||||
#endif
|
||||
// Bis hierher reicht die 0,5 lx Modus. Normale Empfindlichkeit.
|
||||
defineMTReg(BH1750_MTREG_DEFAULT);
|
||||
selectResolutionMode(_autoPowerDown?BH1750_ONE_TIME_HIGH_RES_MODE_2:BH1750_CONTINUOUS_HIGH_RES_MODE_2, fDelayPtr);
|
||||
fDelayPtr(120); // TODO: Wert prüfen
|
||||
}
|
||||
}
|
||||
else if(level<60000) {
|
||||
#if BH1750_DEBUG == 1
|
||||
Serial.println("level 2: bright");
|
||||
#endif
|
||||
#endif
|
||||
// hoher Bereich, 1 lx Modus, normale Empfindlichkeit. Der Wert von 60000 ist mehr oder weniger zufällig, es mus einfach ein hoher Wert, nah an der Grenze sein.
|
||||
defineMTReg(BH1750_MTREG_DEFAULT);
|
||||
selectResolutionMode(_autoPowerDown?BH1750_ONE_TIME_HIGH_RES_MODE:BH1750_CONTINUOUS_HIGH_RES_MODE, fDelayPtr);
|
||||
@@ -312,29 +312,29 @@ float AS_BH1750::readLightLevel(DelayFuncPtr fDelayPtr) {
|
||||
else {
|
||||
#if BH1750_DEBUG == 1
|
||||
Serial.println("level 3: very bright");
|
||||
#endif
|
||||
#endif
|
||||
// sehr hoher Bereich, Empfindlichkeit verringern
|
||||
defineMTReg(32); // Min+1, bei dem Minimum aus Doku spielt der Sensor (zumindest meiner) verrückt: Die Werte sind ca. 1/10 von den Erwarteten.
|
||||
selectResolutionMode(_autoPowerDown?BH1750_ONE_TIME_HIGH_RES_MODE:BH1750_CONTINUOUS_HIGH_RES_MODE, fDelayPtr);
|
||||
fDelayPtr(120); // TODO: Wert prüfen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hardware Wert lesen und in Lux umrechnen.
|
||||
uint16_t raw = readRawLevel();
|
||||
if(raw==65535) {
|
||||
// Wert verdächtig hoch. Sensor prüfen.
|
||||
// Wert verdächtig hoch. Sensor prüfen.
|
||||
// Check I2C Adresse
|
||||
Wire.beginTransmission(_address);
|
||||
if(Wire.endTransmission()!=0) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return convertRawValue(raw);
|
||||
return convertRawValue(raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Roh-Wert der Helligkeit auslesen.
|
||||
* Roh-Wert der Helligkeit auslesen.
|
||||
* Wertebereich 0-65535.
|
||||
*/
|
||||
uint16_t AS_BH1750::readRawLevel(void) {
|
||||
@@ -457,7 +457,7 @@ void AS_BH1750::defineMTReg(uint8_t val) {
|
||||
* Gibt an, ob der Sensor initialisiert ist.
|
||||
*/
|
||||
bool AS_BH1750::isInitialized() {
|
||||
return _hardwareMode!=255;
|
||||
return _hardwareMode!=255;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ Adafruit_MPR121::Adafruit_MPR121() {
|
||||
}
|
||||
|
||||
boolean Adafruit_MPR121::begin(uint8_t i2caddr) {
|
||||
Wire.begin();
|
||||
//Wire.begin(); called in ESPEasy framework
|
||||
|
||||
_i2caddr = i2caddr;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Adafruit_MotorShield::Adafruit_MotorShield(uint8_t addr) {
|
||||
|
||||
void Adafruit_MotorShield::begin(uint16_t freq) {
|
||||
// init PWM w/_freq
|
||||
WIRE.begin();
|
||||
//Wire.begin(); called in ESPEasy framework
|
||||
_pwm.begin();
|
||||
_freq = freq;
|
||||
_pwm.setPWMFreq(_freq); // This is the maximum PWM frequency
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/***************************************************
|
||||
/***************************************************
|
||||
This is a library for our Adafruit 16-channel PWM & Servo driver
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/products/815
|
||||
|
||||
These displays use I2C to communicate, 2 pins are required to
|
||||
These displays use I2C to communicate, 2 pins are required to
|
||||
interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
@@ -29,7 +29,7 @@ Adafruit_MS_PWMServoDriver::Adafruit_MS_PWMServoDriver(uint8_t addr) {
|
||||
}
|
||||
|
||||
void Adafruit_MS_PWMServoDriver::begin(void) {
|
||||
WIRE.begin();
|
||||
//Wire.begin(); called in ESPEasy framework
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void Adafruit_MS_PWMServoDriver::reset(void) {
|
||||
void Adafruit_MS_PWMServoDriver::setPWMFreq(float freq) {
|
||||
//Serial.print("Attempting to set freq ");
|
||||
//Serial.println(freq);
|
||||
|
||||
|
||||
freq *= 0.9; // Correct for overshoot in the frequency setting (see issue #11).
|
||||
|
||||
float prescaleval = 25000000;
|
||||
@@ -50,8 +50,8 @@ void Adafruit_MS_PWMServoDriver::setPWMFreq(float freq) {
|
||||
prescaleval -= 1;
|
||||
//Serial.print("Estimated pre-scale: "); Serial.println(prescaleval);
|
||||
uint8_t prescale = floor(prescaleval + 0.5);
|
||||
//Serial.print("Final pre-scale: "); Serial.println(prescale);
|
||||
|
||||
//Serial.print("Final pre-scale: "); Serial.println(prescale);
|
||||
|
||||
uint8_t oldmode = read8(PCA9685_MODE1);
|
||||
uint8_t newmode = (oldmode&0x7F) | 0x10; // sleep
|
||||
write8(PCA9685_MODE1, newmode); // go to sleep
|
||||
|
||||
@@ -119,7 +119,7 @@ void Adafruit_TCS34725::enable(void)
|
||||
{
|
||||
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON);
|
||||
delay(3);
|
||||
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN);
|
||||
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
@@ -144,7 +144,7 @@ void Adafruit_TCS34725::disable(void)
|
||||
Constructor
|
||||
*/
|
||||
/**************************************************************************/
|
||||
Adafruit_TCS34725::Adafruit_TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_t gain)
|
||||
Adafruit_TCS34725::Adafruit_TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_t gain)
|
||||
{
|
||||
_tcs34725Initialised = false;
|
||||
_tcs34725IntegrationTime = it;
|
||||
@@ -161,10 +161,10 @@ Adafruit_TCS34725::Adafruit_TCS34725(tcs34725IntegrationTime_t it, tcs34725Gain_
|
||||
doing anything else)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
boolean Adafruit_TCS34725::begin(void)
|
||||
boolean Adafruit_TCS34725::begin(void)
|
||||
{
|
||||
Wire.begin();
|
||||
|
||||
//Wire.begin(); called in ESPEasy framework
|
||||
|
||||
/* Make sure we're actually connected */
|
||||
uint8_t x = read8(TCS34725_ID);
|
||||
if ((x != 0x44) && (x != 0x10))
|
||||
@@ -182,7 +182,7 @@ boolean Adafruit_TCS34725::begin(void)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
Sets the integration time for the TC34725
|
||||
@@ -228,7 +228,7 @@ void Adafruit_TCS34725::getRawData (uint16_t *r, uint16_t *g, uint16_t *b, uint1
|
||||
*r = read16(TCS34725_RDATAL);
|
||||
*g = read16(TCS34725_GDATAL);
|
||||
*b = read16(TCS34725_BDATAL);
|
||||
|
||||
|
||||
/* Set a delay for the integration time */
|
||||
switch (_tcs34725IntegrationTime)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ Adafruit_TSL2591::Adafruit_TSL2591(int32_t sensorID)
|
||||
|
||||
boolean Adafruit_TSL2591::begin(void)
|
||||
{
|
||||
Wire.begin();
|
||||
//Wire.begin(); called in ESPEasy framework
|
||||
|
||||
/*
|
||||
for (uint8_t i=0; i<0x20; i++)
|
||||
|
||||
+11
-8
@@ -1,11 +1,14 @@
|
||||
<!--
|
||||
Thanks for using ArduinoJson :-)
|
||||
Before opening an issue, please read the FAQ:
|
||||
https://arduinojson.org/faq/
|
||||
|
||||
Before opening an issue, please make sure you've read these:
|
||||
https://github.com/bblanchon/ArduinoJson/wiki/FAQ
|
||||
https://github.com/bblanchon/ArduinoJson/wiki/Avoiding-pitfalls
|
||||
Please provide all the relevant information:
|
||||
* good title
|
||||
* short description of the problem
|
||||
* target platform
|
||||
* compiler model and version
|
||||
* MVCE (https://stackoverflow.com/help/mcve)
|
||||
* compiler output
|
||||
|
||||
Next, make sure you provide all the relevant information: platform, code snippet, and error messages.
|
||||
|
||||
Please be concise!
|
||||
-->
|
||||
Good questions get fast answers!
|
||||
-->
|
||||
|
||||
@@ -6,3 +6,6 @@
|
||||
/sftp-config.json
|
||||
.tags
|
||||
.tags_sorted_by_file
|
||||
/fuzzing/*_fuzzer
|
||||
/fuzzing/*_fuzzer.options
|
||||
/fuzzing/*_fuzzer_seed_corpus.zip
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
.github/
|
||||
examples/
|
||||
fuzzing/
|
||||
scripts/
|
||||
test/
|
||||
third-party/
|
||||
+56
-48
@@ -7,111 +7,119 @@ matrix:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.4']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.4
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.5']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.5
|
||||
env: SCRIPT=cmake GCC=4.4
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.6']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.6
|
||||
env: SCRIPT=cmake GCC=4.6
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.7']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.7
|
||||
env: SCRIPT=cmake GCC=4.7
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.8']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.8
|
||||
env: SCRIPT=cmake GCC=4.8 SANITIZE=address
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-4.9']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-4.9
|
||||
env: SCRIPT=cmake GCC=4.9 SANITIZE=leak
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-5']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=g++-5
|
||||
env: SCRIPT=cmake GCC=5
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-6']
|
||||
env: SCRIPT=cmake GCC=6
|
||||
- compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: ['g++-7']
|
||||
env: SCRIPT=cmake GCC=7
|
||||
- compiler: clang
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++
|
||||
env: SCRIPT=cmake
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5']
|
||||
packages: ['clang-3.5']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.5
|
||||
env: SCRIPT=cmake CLANG=3.5 SANITIZE=address
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.6']
|
||||
packages: ['clang-3.6']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.6
|
||||
env: SCRIPT=cmake CLANG=3.6 SANITIZE=leak
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.7']
|
||||
packages: ['clang-3.7']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.7
|
||||
env: SCRIPT=cmake CLANG=3.7
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-precise-3.8']
|
||||
packages: ['clang-3.8']
|
||||
env: SCRIPT=cmake CMAKE_CXX_COMPILER=clang++-3.8
|
||||
env: SCRIPT=cmake CLANG=3.8 SANITIZE=undefined
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-3.9']
|
||||
packages: ['clang-3.9']
|
||||
env: SCRIPT=cmake CLANG=3.9
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-4.0']
|
||||
packages: ['clang-4.0']
|
||||
env: SCRIPT=cmake CLANG=4.0
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-5.0']
|
||||
packages: ['clang-5.0']
|
||||
env: SCRIPT=cmake CLANG=5.0
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
|
||||
packages: ['clang-6.0']
|
||||
env: SCRIPT=cmake CLANG=6.0
|
||||
- compiler: gcc
|
||||
env: SCRIPT=coverage
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.1
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.2
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- os: osx
|
||||
osx_image: beta-xcode6.3
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- os: osx
|
||||
osx_image: xcode6.4
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- os: osx
|
||||
osx_image: xcode7
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- os: osx
|
||||
osx_image: xcode7.1
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- os: osx
|
||||
osx_image: xcode7.2
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
env: SCRIPT=cmake
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
env: SCRIPT=cmake-osx
|
||||
- env: SCRIPT=arduino VERSION=1.5.8 BOARD=arduino:avr:uno
|
||||
env: SCRIPT=cmake SANITIZE=address
|
||||
- env: SCRIPT=arduino VERSION=1.6.7 BOARD=arduino:avr:uno
|
||||
- env: SCRIPT=arduino VERSION=1.6.8 BOARD=arduino:avr:uno
|
||||
- env: SCRIPT=arduino VERSION=1.6.9 BOARD=arduino:avr:uno
|
||||
- env: SCRIPT=arduino VERSION=1.8.2 BOARD=arduino:avr:uno
|
||||
- env: SCRIPT=platformio BOARD=uno
|
||||
- env: SCRIPT=platformio BOARD=due
|
||||
- env: SCRIPT=platformio BOARD=esp01
|
||||
- env: SCRIPT=platformio BOARD=teensy31
|
||||
- compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
|
||||
packages: ['clang-6.0','llvm-6.0']
|
||||
env: SCRIPT=fuzz CLANG=6.0
|
||||
cache:
|
||||
directories:
|
||||
- "~/.platformio"
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include "include/ArduinoJson.h"
|
||||
#include "src/ArduinoJson.h"
|
||||
|
||||
+279
-111
@@ -1,6 +1,270 @@
|
||||
ArduinoJson: change log
|
||||
=======================
|
||||
|
||||
v5.13.2
|
||||
-------
|
||||
|
||||
* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693)
|
||||
* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu)
|
||||
* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky)
|
||||
* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`...
|
||||
|
||||
v5.13.1
|
||||
-------
|
||||
|
||||
* Fixed `JsonVariant::operator|(int)` that returned the default value if the variant contained a double (issue #675)
|
||||
* Allowed non-quoted key to contain underscores (issue #665)
|
||||
|
||||
v5.13.0
|
||||
-------
|
||||
|
||||
* Changed the rules of string duplication (issue #658)
|
||||
* `RawJson()` accepts any kind of string and obeys to the same rules for duplication
|
||||
* Changed the return type of `strdup()` to `const char*` to prevent double duplication
|
||||
* Marked `strdup()` as deprecated
|
||||
|
||||
> ### New rules for string duplication
|
||||
>
|
||||
> | type | duplication |
|
||||
> |:---------------------------|:------------|
|
||||
> | const char* | no |
|
||||
> | char* | ~~no~~ yes |
|
||||
> | String | yes |
|
||||
> | std::string | yes |
|
||||
> | const __FlashStringHelper* | yes |
|
||||
>
|
||||
> These new rules make `JsonBuffer::strdup()` useless.
|
||||
|
||||
v5.12.0
|
||||
-------
|
||||
|
||||
* Added `JsonVariant::operator|` to return a default value (see below)
|
||||
* Added a clear error message when compiled as C instead of C++ (issue #629)
|
||||
* Added detection of MPLAB XC compiler (issue #629)
|
||||
* Added detection of Keil ARM Compiler (issue #629)
|
||||
* Added an example that shows how to save and load a configuration file
|
||||
* Reworked all other examples
|
||||
|
||||
> ### How to use the new feature?
|
||||
>
|
||||
> If you have a block like this:
|
||||
>
|
||||
> ```c++
|
||||
> const char* ssid = root["ssid"];
|
||||
> if (!ssid)
|
||||
> ssid = "default ssid";
|
||||
> ```
|
||||
>
|
||||
> You can simplify like that:
|
||||
>
|
||||
> ```c++
|
||||
> const char* ssid = root["ssid"] | "default ssid";
|
||||
> ```
|
||||
|
||||
v5.11.2
|
||||
-------
|
||||
|
||||
* Fixed `DynamicJsonBuffer::clear()` not resetting allocation size (issue #561)
|
||||
* Fixed incorrect rounding for float values (issue #588)
|
||||
|
||||
v5.11.1
|
||||
-------
|
||||
|
||||
* Removed dependency on `PGM_P` as Particle 0.6.2 doesn't define it (issue #546)
|
||||
* Fixed warning "dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]"
|
||||
* Fixed warning "floating constant exceeds range of 'float' [-Woverflow]" (issue #544)
|
||||
* Fixed warning "this statement may fall through" [-Wimplicit-fallthrough=] (issue #539)
|
||||
* Removed `ARDUINOJSON_DOUBLE_IS_64BITS` as it became useless.
|
||||
* Fixed too many decimals places in float serialization (issue #543)
|
||||
|
||||
v5.11.0
|
||||
-------
|
||||
|
||||
* Made `JsonBuffer` non-copyable (PR #524 by @luisrayas3)
|
||||
* Added `StaticJsonBuffer::clear()`
|
||||
* Added `DynamicJsonBuffer::clear()`
|
||||
|
||||
v5.10.1
|
||||
-------
|
||||
|
||||
* Fixed IntelliSense errors in Visual Micro (issue #483)
|
||||
* Fixed compilation in IAR Embedded Workbench (issue #515)
|
||||
* Fixed reading "true" as a float (issue #516)
|
||||
* Added `ARDUINOJSON_DOUBLE_IS_64BITS`
|
||||
* Added `ARDUINOJSON_EMBEDDED_MODE`
|
||||
|
||||
v5.10.0
|
||||
-------
|
||||
|
||||
* Removed configurable number of decimal places (issues #288, #427 and #506)
|
||||
* Changed exponentiation thresholds to `1e7` and `1e-5` (issues #288, #427 and #506)
|
||||
* `JsonVariant::is<double>()` now returns `true` for integers
|
||||
* Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495)
|
||||
* Fixed error `forming reference to reference` (issue #495)
|
||||
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> | Old syntax | New syntax |
|
||||
> |:--------------------------------|:--------------------|
|
||||
> | `double_with_n_digits(3.14, 2)` | `3.14` |
|
||||
> | `float_with_n_digits(3.14, 2)` | `3.14f` |
|
||||
> | `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` |
|
||||
> | `arr.add(3.14, 2)` | `arr.add(3.14)` |
|
||||
>
|
||||
> | Input | Old output | New output |
|
||||
> |:----------|:-----------|:-----------|
|
||||
> | `3.14159` | `3.14` | `3.14159` |
|
||||
> | `42.0` | `42.00` | `42` |
|
||||
> | `0.0` | `0.00` | `0` |
|
||||
>
|
||||
> | Expression | Old result | New result |
|
||||
> |:-------------------------------|:-----------|:-----------|
|
||||
> | `JsonVariant(42).is<int>()` | `true` | `true` |
|
||||
> | `JsonVariant(42).is<float>()` | `false` | `true` |
|
||||
> | `JsonVariant(42).is<double>()` | `false` | `true` |
|
||||
|
||||
v5.9.0
|
||||
------
|
||||
|
||||
* Added `JsonArray::remove(iterator)` (issue #479)
|
||||
* Added `JsonObject::remove(iterator)`
|
||||
* Renamed `JsonArray::removeAt(size_t)` into `remove(size_t)`
|
||||
* Renamed folder `include/` to `src/`
|
||||
* Fixed warnings `floating constant exceeds range of float`and `floating constant truncated to zero` (issue #483)
|
||||
* Removed `Print` class and converted `printTo()` to a template method (issue #276)
|
||||
* Removed example `IndentedPrintExample.ino`
|
||||
* Now compatible with Particle 0.6.1, thanks to Jacob Nite (issue #294 and PR #461 by @foodbag)
|
||||
|
||||
v5.8.4
|
||||
------
|
||||
|
||||
* Added custom implementation of `strtod()` (issue #453)
|
||||
* Added custom implementation of `strtol()` (issue #465)
|
||||
* `char` is now treated as an integral type (issue #337, #370)
|
||||
|
||||
v5.8.3
|
||||
------
|
||||
|
||||
* Fixed an access violation in `DynamicJsonBuffer` when memory allocation fails (issue #433)
|
||||
* Added operators `==` and `!=` for two `JsonVariant`s (issue #436)
|
||||
* Fixed `JsonVariant::operator[const FlashStringHelper*]` (issue #441)
|
||||
|
||||
v5.8.2
|
||||
------
|
||||
|
||||
* Fixed parsing of comments (issue #421)
|
||||
* Fixed ignored `Stream` timeout (issue #422)
|
||||
* Made sure we don't read more that necessary (issue #422)
|
||||
* Fixed error when the key of a `JsonObject` is a `char[]` (issue #423)
|
||||
* Reduced code size when using `const` references
|
||||
* Fixed error with string of type `unsigned char*` (issue #428)
|
||||
* Added `deprecated` attribute on `asArray()`, `asObject()` and `asString()` (issue #420)
|
||||
|
||||
v5.8.1
|
||||
------
|
||||
|
||||
* Fixed error when assigning a `volatile int` to a `JsonVariant` (issue #415)
|
||||
* Fixed errors with Variable Length Arrays (issue #416)
|
||||
* Fixed error when both `ARDUINOJSON_ENABLE_STD_STREAM` and `ARDUINOJSON_ENABLE_ARDUINO_STREAM` are set to `1`
|
||||
* Fixed error "Stream does not name a type" (issue #412)
|
||||
|
||||
v5.8.0
|
||||
------
|
||||
|
||||
* Added operator `==` to compare `JsonVariant` and strings (issue #402)
|
||||
* Added support for `Stream` (issue #300)
|
||||
* Reduced memory consumption by not duplicating spaces and comments
|
||||
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> `JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`.
|
||||
>
|
||||
> This means that if you have code like:
|
||||
>
|
||||
> ```c++
|
||||
> void myFunction(JsonBuffer& jsonBuffer);
|
||||
> ```
|
||||
>
|
||||
> you need to replace it with one of the following:
|
||||
>
|
||||
> ```c++
|
||||
> void myFunction(DynamicJsonBuffer& jsonBuffer);
|
||||
> void myFunction(StaticJsonBufferBase& jsonBuffer);
|
||||
> template<typename TJsonBuffer> void myFunction(TJsonBuffer& jsonBuffer);
|
||||
> ```
|
||||
|
||||
v5.7.3
|
||||
------
|
||||
|
||||
* Added an `printTo(char[N])` and `prettyPrintTo(char[N])` (issue #292)
|
||||
* Added ability to set a nested value like this: `root["A"]["B"] = "C"` (issue #352)
|
||||
* Renamed `*.ipp` to `*Impl.hpp` because they were ignored by Arduino IDE (issue #396)
|
||||
|
||||
v5.7.2
|
||||
------
|
||||
|
||||
* Made PROGMEM available on more platforms (issue #381)
|
||||
* Fixed PROGMEM causing an exception on ESP8266 (issue #383)
|
||||
|
||||
v5.7.1
|
||||
------
|
||||
|
||||
* Added support for PROGMEM (issue #76)
|
||||
* Fixed compilation error when index is not an `int` (issue #381)
|
||||
|
||||
v5.7.0
|
||||
------
|
||||
|
||||
* Templatized all functions using `String` or `std::string`
|
||||
* Removed `ArduinoJson::String`
|
||||
* Removed `JsonVariant::defaultValue<T>()`
|
||||
* Removed non-template `JsonObject::get()` and `JsonArray.get()`
|
||||
* Fixed support for `StringSumHelper` (issue #184)
|
||||
* Replaced `ARDUINOJSON_USE_ARDUINO_STRING` by `ARDUINOJSON_ENABLE_STD_STRING` and `ARDUINOJSON_ENABLE_ARDUINO_STRING` (issue #378)
|
||||
* Added example `StringExample.ino` to show where `String` can be used
|
||||
* Increased default nesting limit to 50 when compiled for a computer (issue #349)
|
||||
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return.
|
||||
>
|
||||
> Old code:
|
||||
>
|
||||
> ```c++
|
||||
> #define ARDUINOJSON_USE_ARDUINO_STRING 0
|
||||
> JsonVariant value1 = myObject.get("myKey");
|
||||
> JsonVariant value2 = myArray.get(0);
|
||||
> ```
|
||||
>
|
||||
> New code:
|
||||
>
|
||||
> ```c++
|
||||
> #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0
|
||||
> #define ARDUINOJSON_ENABLE_STD_STRING 1
|
||||
> JsonVariant value1 = myObject.get<JsonVariant>("myKey");
|
||||
> JsonVariant value2 = myArray.get<JsonVariant>(0);
|
||||
> ```
|
||||
|
||||
v5.6.7
|
||||
------
|
||||
|
||||
* Fixed `array[idx].as<JsonVariant>()` and `object[key].as<JsonVariant>()`
|
||||
* Fixed return value of `JsonObject::set()` (issue #350)
|
||||
* Fixed undefined behavior in `Prettyfier` and `Print` (issue #354)
|
||||
* Fixed parser that incorrectly rejected floats containing a `+` (issue #349)
|
||||
|
||||
v5.6.6
|
||||
------
|
||||
|
||||
* Fixed `-Wparentheses` warning introduced in v5.6.5 (PR #335 by @nuket)
|
||||
* Added `.mbedignore` for ARM mbdeb (PR #334 by @nuket)
|
||||
* Fixed `JsonVariant::success()` which didn't propagate `JsonArray::success()` nor `JsonObject::success()` (issue #342).
|
||||
|
||||
v5.6.5
|
||||
------
|
||||
|
||||
* `as<char*>()` now returns `true` when input is `null` (issue #330)
|
||||
|
||||
v5.6.4
|
||||
------
|
||||
|
||||
@@ -71,8 +335,9 @@ v5.1.0
|
||||
* Added support of `long long` (issue #171)
|
||||
* Moved all build settings to `ArduinoJson/Configuration.hpp`
|
||||
|
||||
**BREAKING CHANGE**:
|
||||
If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`.
|
||||
> ### BREAKING CHANGE :warning:
|
||||
>
|
||||
> If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`.
|
||||
|
||||
v5.0.8
|
||||
------
|
||||
@@ -86,9 +351,10 @@ v5.0.7
|
||||
* Made library easier to use from a CMake project: simply `add_subdirectory(ArduinoJson/src)`
|
||||
* Changed `String` to be a `typedef` of `std::string` (issues #142 and #161)
|
||||
|
||||
**BREAKING CHANGES**:
|
||||
- `JsonVariant(true).as<String>()` now returns `"true"` instead of `"1"`
|
||||
- `JsonVariant(false).as<String>()` now returns `"false"` instead of `"0"`
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> - `JsonVariant(true).as<String>()` now returns `"true"` instead of `"1"`
|
||||
> - `JsonVariant(false).as<String>()` now returns `"false"` instead of `"0"`
|
||||
|
||||
v5.0.6
|
||||
------
|
||||
@@ -142,10 +408,11 @@ v5.0.0
|
||||
* Redesigned `JsonVariant` to leverage converting constructors instead of assignment operators (issue #66)
|
||||
* Switched to new the library layout (requires Arduino 1.0.6 or above)
|
||||
|
||||
**BREAKING CHANGES**:
|
||||
- `JsonObject::add()` was renamed to `set()`
|
||||
- `JsonArray::at()` and `JsonObject::at()` were renamed to `get()`
|
||||
- Number of digits of floating point value are now set with `double_with_n_digits()`
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> - `JsonObject::add()` was renamed to `set()`
|
||||
> - `JsonArray::at()` and `JsonObject::at()` were renamed to `get()`
|
||||
> - Number of digits of floating point value are now set with `double_with_n_digits()`
|
||||
|
||||
**Personal note about the `String` class**:
|
||||
Support of the `String` class has been added to the library because many people use it in their programs.
|
||||
@@ -198,106 +465,7 @@ v4.0
|
||||
* Unified parser and generator API (issue #23)
|
||||
* Updated library layout, now requires Arduino 1.0.6 or newer
|
||||
|
||||
**BREAKING CHANGE**: API changed significantly, see [Migrating code to the new API](https://github.com/bblanchon/ArduinoJson/wiki/Migrating-code-to-the-new-API).
|
||||
> ### BREAKING CHANGES :warning:
|
||||
>
|
||||
> API changed significantly since v3, see [Migrating code to the new API](https://arduinojson.org/doc/migration/).
|
||||
|
||||
|
||||
v3.4
|
||||
----
|
||||
|
||||
* Fixed escaped char parsing (issue #16)
|
||||
|
||||
|
||||
v3.3
|
||||
----
|
||||
|
||||
* Added indented output for the JSON generator (issue #11), see example bellow.
|
||||
* Added `IndentedPrint`, a decorator for `Print` to allow indented output
|
||||
|
||||
Example:
|
||||
|
||||
JsonOject<2> json;
|
||||
json["key"] = "value";
|
||||
json.prettyPrintTo(Serial);
|
||||
|
||||
v3.2
|
||||
----
|
||||
|
||||
* Fixed a bug when adding nested object in `JsonArray` (bug introduced in v3.1).
|
||||
|
||||
v3.1
|
||||
----
|
||||
|
||||
* Calling `Generator::JsonObject::add()` twice with the same `key` now replaces the `value`
|
||||
* Added `Generator::JsonObject::operator[]`, see bellow the new API
|
||||
* Added `Generator::JsonObject::remove()` (issue #9)
|
||||
|
||||
Old generator API:
|
||||
|
||||
JsonObject<3> root;
|
||||
root.add("sensor", "gps");
|
||||
root.add("time", 1351824120);
|
||||
root.add("data", array);
|
||||
|
||||
New generator API:
|
||||
|
||||
JsonObject<3> root;
|
||||
root["sensor"] = "gps";
|
||||
root["time"] = 1351824120;
|
||||
root["data"] = array;
|
||||
|
||||
v3.0
|
||||
----
|
||||
|
||||
* New parser API, see bellow
|
||||
* Renamed `JsonHashTable` into `JsonObject`
|
||||
* Added iterators for `JsonArray` and `JsonObject` (issue #4)
|
||||
|
||||
Old parser API:
|
||||
|
||||
JsonHashTable root = parser.parseHashTable(json);
|
||||
|
||||
char* sensor = root.getString("sensor");
|
||||
long time = root.getLong("time");
|
||||
double latitude = root.getArray("data").getDouble(0);
|
||||
double longitude = root.getArray("data").getDouble(1);
|
||||
|
||||
New parser API:
|
||||
|
||||
JsonObject root = parser.parse(json);
|
||||
|
||||
char* sensor = root["sensor"];
|
||||
long time = root["time"];
|
||||
double latitude = root["data"][0];
|
||||
double longitude = root["data"][1];
|
||||
|
||||
v2.1
|
||||
----
|
||||
|
||||
* Fixed case `#include "jsmn.cpp"` which caused an error in Linux (issue #6)
|
||||
* Fixed a buffer overrun in JSON Parser (issue #5)
|
||||
|
||||
v2.0
|
||||
----
|
||||
|
||||
* Added JSON encoding (issue #2)
|
||||
* Renamed the library `ArduinoJsonParser` becomes `ArduinoJson`
|
||||
|
||||
**Breaking change**: you need to add the following line at the top of your program.
|
||||
|
||||
using namespace ArduinoJson::Parser;
|
||||
|
||||
v1.2
|
||||
----
|
||||
|
||||
* Fixed error in JSON parser example (issue #1)
|
||||
|
||||
v1.1
|
||||
----
|
||||
|
||||
* Example: changed `char* json` into `char[] json` so that the bytes are not write protected
|
||||
* Fixed parsing bug when the JSON contains multi-dimensional arrays
|
||||
|
||||
v1.0
|
||||
----
|
||||
|
||||
Initial release
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
# Copyright Benoit Blanchon 2014-2016
|
||||
# ArduinoJson - arduinojson.org
|
||||
# Copyright Benoit Blanchon 2014-2018
|
||||
# MIT License
|
||||
#
|
||||
# Arduino JSON library
|
||||
# https://github.com/bblanchon/ArduinoJson
|
||||
# If you like this project, please add a star!
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(ArduinoJson)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
|
||||
if(${COVERAGE})
|
||||
set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
||||
add_subdirectory(third-party/catch)
|
||||
add_subdirectory(test)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Contribution to ArduinoJson
|
||||
|
||||
First, thank you for taking the time to contribute to this project.
|
||||
|
||||
You can submit changes via GitHub Pull Requests.
|
||||
|
||||
Please:
|
||||
|
||||
1. Unit test every change in behavior
|
||||
2. Use clang-format in "file" mode to format the code
|
||||
3. Consider using the Continuous Integration (Travis and AppVeyor)
|
||||
@@ -1,7 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
---------------------
|
||||
|
||||
Copyright © 2014-2016 Benoit BLANCHON
|
||||
Copyright © 2014-2018 Benoit BLANCHON
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
+59
-79
@@ -1,46 +1,60 @@
|
||||
Arduino JSON library
|
||||
====================
|
||||

|
||||
|
||||
---
|
||||
|
||||
[](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/master) [](https://travis-ci.org/bblanchon/ArduinoJson) [](https://coveralls.io/r/bblanchon/ArduinoJson?branch=master) [](https://github.com/bblanchon/ArduinoJson)
|
||||
|
||||
*An elegant and efficient JSON library for embedded systems.*
|
||||
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
||||
|
||||
It's designed to have the most intuitive API, the smallest footprint and works without any allocation on the heap (no malloc).
|
||||
|
||||
It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project.
|
||||
|
||||
Features
|
||||
--------
|
||||
## Features
|
||||
|
||||
* JSON decoding (comments are supported)
|
||||
* JSON encoding (with optional indentation)
|
||||
* Elegant API, very easy to use
|
||||
* Elegant API, easy to use
|
||||
* Fixed memory allocation (zero malloc)
|
||||
* No data duplication (zero copy)
|
||||
* Portable (written in C++98)
|
||||
* Portable (written in C++98, can be used in any C++ project)
|
||||
* Self-contained (no external dependency)
|
||||
* Small footprint
|
||||
* Header-only library
|
||||
* MIT License
|
||||
* Input and output streams
|
||||
* [100% code coverage](https://coveralls.io/github/bblanchon/ArduinoJson)
|
||||
* [Header-only library](https://en.wikipedia.org/wiki/Header-only)
|
||||
* [MIT License](https://en.wikipedia.org/wiki/MIT_License)
|
||||
* [Comprehensive documentation](https://arduinojson.org?utm_source=github&utm_medium=readme)
|
||||
|
||||
Works on
|
||||
--------
|
||||
## Compatibility
|
||||
|
||||
* All Arduino boards (Uno, Due, Mini, Micro, Yun...)
|
||||
* ESP8266
|
||||
* Teensy
|
||||
* Intel Edison and Galileo
|
||||
* PlatformIO
|
||||
* Energia
|
||||
* RedBearLab boards (BLE Nano...)
|
||||
* Computers (Windows, Linux, OSX...)
|
||||
ArduinoJson works on the following hardware:
|
||||
|
||||
See [FAQ: Compatibility issues](https://github.com/bblanchon/ArduinoJson/wiki/Compatibility-issues)
|
||||
* <img src="https://www.arduino.cc/favicon.ico" height="16" width="16"> Arduino boards: [Uno](https://www.arduino.cc/en/Main/ArduinoBoardUno), [Due](https://www.arduino.cc/en/Main/ArduinoBoardDue), [Mini](https://www.arduino.cc/en/Main/ArduinoBoardMini), [Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro), [Yun](https://www.arduino.cc/en/Main/ArduinoBoardYun)...
|
||||
* <img src="http://espressif.com/sites/all/themes/espressif/favicon.ico" height="16" width="16"> Espressif chips: [ESP8266](https://en.wikipedia.org/wiki/ESP8266), [ESP32](https://en.wikipedia.org/wiki/ESP32)
|
||||
* <img src="https://www.wemos.cc/themes/martin-materialize-parallax/assets/favicon.ico" height="16" width="16"> WeMos boards: [D1](https://wiki.wemos.cc/products:d1:d1), [D1 mini](https://wiki.wemos.cc/products:d1:d1_mini), ...
|
||||
* <img src="http://redbearlab.com/favicon.ico" height="16" width="16"> RedBearLab boards: [BLE Nano](http://redbearlab.com/blenano/), [BLE Mini](http://redbearlab.com/blemini/), [WiFi Micro](https://redbear.cc/product/wifi/wifi-micro.html), [LOLIN32](https://wiki.wemos.cc/products:lolin32:lolin32)...
|
||||
* <img src="https://www.pjrc.com/favicon.ico" height="16" width="16"> [Teensy](https://www.pjrc.com/teensy/) boards
|
||||
* <img src="https://software.intel.com/sites/all/themes/zero/favicon.ico" height="16" width="16"> Intel boards: Edison, Galileo...
|
||||
* <img src="https://www-assets.particle.io/images/favicon.png" height="16" width="16"> Particle boards: [Photon](https://www.particle.io/products/hardware/photon-wifi-dev-kit), [Electron](https://www.particle.io/products/hardware/electron-cellular-dev-kit)...
|
||||
* <img src="http://www.ti.com/favicon.ico" height="16" width="16"> Texas Instruments boards: [MSP430](http://www.ti.com/microcontrollers/msp430-ultra-low-power-mcus/overview/overview.html)...
|
||||
|
||||
Quick start
|
||||
-----------
|
||||
ArduinoJson compiles with zero warning on the following compilers, IDEs, and platforms:
|
||||
|
||||
#### Decoding / Parsing
|
||||
* <img src="https://www.arduino.cc/favicon.ico" height="16" width="16"> [Arduino IDE](https://www.arduino.cc/en/Main/Software)
|
||||
* <img src="http://cdn.platformio.org/favicon.ico" height="16" width="16"> [PlatformIO](http://platformio.org/)
|
||||
* <img src="http://energia.nu/img/favicon.ico" height="16" width="16"> [Energia](http://energia.nu/)
|
||||
* <img src="http://www.visualmicro.com/pics/arduino-visual-studio-ld.png" height="16" width="16"> [Visual Micro](http://www.visualmicro.com/)
|
||||
* <img src="http://www.atmel.com/Images/favicon.ico" height="16" width="16"> [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
|
||||
* <img src="https://www.iar.com/favicon.ico" height="16" width="16"> [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/)
|
||||
* <img src="http://www.st.com/etc/clientlibs/st-site/media/app/images/favicon.png" height="16" width="16"> [Atollic TrueSTUDIO](https://atollic.com/truestudio/)
|
||||
* <img src="http://www.keil.com/favicon.ico" height="16" width="16"> [Keil uVision](http://www.keil.com/)
|
||||
* <img src="http://www.microchip.com/favicon.ico" height="16" width="16"> [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide)
|
||||
* <img src="https://gcc.gnu.org/favicon.ico" height="16" width="16"> [GCC](https://gcc.gnu.org/)
|
||||
* <img src="https://clang.llvm.org/favicon.ico" height="16" width="16"> [Clang](https://clang.llvm.org/)
|
||||
* <img src="https://www.visualstudio.com/favicon.ico" height="16" width="16"> [Visual Studio](https://www.visualstudio.com/)
|
||||
|
||||
## Quickstart
|
||||
|
||||
### Deserialization
|
||||
|
||||
Here is a program that parses a JSON document with ArduinoJson.
|
||||
|
||||
```c++
|
||||
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||
@@ -55,7 +69,11 @@ double latitude = root["data"][0];
|
||||
double longitude = root["data"][1];
|
||||
```
|
||||
|
||||
#### Encoding / Generating
|
||||
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/decoding/?utm_source=github&utm_medium=readme)
|
||||
|
||||
### Serialization
|
||||
|
||||
Here is a program that generates a JSON document with ArduinoJson:
|
||||
|
||||
```c++
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
@@ -65,66 +83,28 @@ root["sensor"] = "gps";
|
||||
root["time"] = 1351824120;
|
||||
|
||||
JsonArray& data = root.createNestedArray("data");
|
||||
data.add(48.756080, 6); // 6 is the number of decimals to print
|
||||
data.add(2.302038, 6); // if not specified, 2 digits are printed
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
root.printTo(Serial);
|
||||
// This prints:
|
||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||
```
|
||||
|
||||
See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme)
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
## Documentation
|
||||
|
||||
The documentation is available online in the [Arduino JSON wiki](https://github.com/bblanchon/ArduinoJson/wiki)
|
||||
The documentation is available on [arduinojson.org](https://arduinojson.org/?utm_source=github&utm_medium=readme), here are some shortcuts:
|
||||
|
||||
Testimonials
|
||||
------------
|
||||
|
||||
From Arduino's Forum user `jflaplante`:
|
||||
> I tried aJson json-arduino before trying your library. I always ran into memory problem after a while.
|
||||
> I have no such problem so far with your library. It is working perfectly with my web services.
|
||||
|
||||
From Arduino's Forum user `gbathree`:
|
||||
> Thanks so much - this is an awesome library! If you want to see what we're doing with it - the project is located at www.photosynq.org.
|
||||
|
||||
From StackOverflow user `thegreendroid`:
|
||||
> It has a really elegant, simple API and it works like a charm on embedded and Windows/Linux platforms. We recently started using this on an embedded project and I can vouch for its quality.
|
||||
|
||||
From GitHub user `zacsketches`:
|
||||
> Thanks for a great library!!!
|
||||
> I've been watching you consistently develop this library over the past six months, and I used it today for a publish and subscribe architecture designed to help hobbyists move into more advanced robotics. Your library allowed me to implement remote subscription in order to facilitate multi-processor robots.
|
||||
> ArduinoJson saved me a week's worth of time!!
|
||||
|
||||
[From Reddit user `erm_what_`](https://www.reddit.com/r/arduino/comments/3jj6ep/announcing_arduinojson_50/cusjk8c):
|
||||
> This is a great library and I wouldn't be able to do the project I'm doing without it. I completely recommend it.
|
||||
|
||||
[From Reddit user `makerhacks`](https://www.reddit.com/r/arduino/comments/3jj6ep/announcing_arduinojson_50/cusqg7b):
|
||||
> I am just starting an ESP8266 clock project and now I can output JSON from my server script and interpret it painlessly.
|
||||
|
||||
[From Twitter user `@hemalchevli`](https://twitter.com/hemalchevli/status/715788439397011456):
|
||||
> ArduinoJson library should be used as a benchmark/reference for making libraries. Truly elegant.
|
||||
|
||||
Donators
|
||||
--------
|
||||
|
||||
Special thanks to the following persons and companies who made generous donations to the library author:
|
||||
|
||||
* Robert Murphy <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Surge Communications <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Alex Scott <img alt='United Kingdom' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1ec-1f1e7.svg' width='18' height='18'>
|
||||
* Firepick Services LLC <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* A B Doodkorte <img alt='Netherlands' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f3-1f1f1.svg' width='18' height='18'>
|
||||
* Scott Smith <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Johann Stieger <img alt='Austria' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1e6-1f1f9.svg' width='18' height='18'>
|
||||
* Gustavo Donizeti Gini <img alt='Brazil' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1e7-1f1f7.svg' width='18' height='18'>
|
||||
* Charles-Henri Hallard <img alt='France' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1eb-1f1f7.svg' width='18' height='18'>
|
||||
* Martijn van den Burg <img alt='Netherlands' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f3-1f1f1.svg' width='18' height='18'>
|
||||
* Nick Koumaris <img alt='Greece' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1ec-1f1f7.svg' width='18' height='18'>
|
||||
* Jon Williams <img alt='USA' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1fa-1f1f8.svg' width='18' height='18'>
|
||||
* Kestutis Liaugminas <img alt='Lithuania' src='https://cdnjs.cloudflare.com/ajax/libs/emojione/2.1.4/assets/svg/1f1f1-1f1f9.svg' width='18' height='18'>
|
||||
* The [Examples](https://arduinojson.org/example/?utm_source=github&utm_medium=readme) show how to use the library in various situations.
|
||||
* The [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=readme) contains the description of each class and function.
|
||||
* The [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=readme) has the answer to virtually every question.
|
||||
* The [ArduinoJson Assistant](https://arduinojson.org/assistant/?utm_source=github&utm_medium=readme) writes programs for you!
|
||||
|
||||
---
|
||||
|
||||
Found this library useful? Please star this project or [help me back with a donation!](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donate%40benoitblanchon%2efr&lc=GB&item_name=Benoit%20Blanchon&item_number=Arduino%20JSON¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) :smile:
|
||||
Do you like this library? Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)!
|
||||
|
||||
What? You don't like it but you *love* it?
|
||||
We don't take donations anymore, but [we sell a book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme), so you can help and learn at the same time!
|
||||
@@ -0,0 +1,27 @@
|
||||
# ArduinoJson Support
|
||||
|
||||
First off, thank you very much for using ArduinoJson.
|
||||
|
||||
We'll be very happy to help you, but first please read the following.
|
||||
|
||||
## Before asking for help
|
||||
|
||||
1. Read the [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=support)
|
||||
2. Search in the [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=support)
|
||||
|
||||
If you did not find the answer, please create a [new issue on GitHub](https://github.com/bblanchon/ArduinoJson/issues/new).
|
||||
|
||||
It is OK to add a comment to a currently opened issue, but please avoid adding comments to a closed issue.
|
||||
|
||||
## Before hitting the Submit button
|
||||
|
||||
Please provide all the relevant information:
|
||||
|
||||
* Good title
|
||||
* Short description of the problem
|
||||
* Target platform
|
||||
* Compiler model and version
|
||||
* [MVCE](https://stackoverflow.com/help/mcve)
|
||||
* Compiler output
|
||||
|
||||
Good questions get fast answers!
|
||||
@@ -1,13 +1,15 @@
|
||||
version: 5.6.4.{build}
|
||||
version: 5.13.2.{build}
|
||||
environment:
|
||||
matrix:
|
||||
- CMAKE_GENERATOR: Visual Studio 14 2015
|
||||
- CMAKE_GENERATOR: Visual Studio 12 2013
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_GENERATOR: Visual Studio 15 2017
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE_GENERATOR: Visual Studio 14 2015
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
CMAKE_GENERATOR: Visual Studio 12 2013
|
||||
- CMAKE_GENERATOR: Visual Studio 11 2012
|
||||
- CMAKE_GENERATOR: Visual Studio 10 2010
|
||||
# - CMAKE_GENERATOR: MinGW Makefiles
|
||||
# Note: Disabled because of unexplicated error -1073741511
|
||||
# This used to work fine with GCC 4.8.2 then failed after they upgraded to GCC 4.9.3
|
||||
- CMAKE_GENERATOR: MinGW Makefiles
|
||||
configuration: Debug
|
||||
before_build:
|
||||
- set PATH=C:\MinGW\bin;%PATH:C:\Program Files\Git\usr\bin;=% # Workaround for CMake not wanting sh.exe on PATH for MinGW
|
||||
@@ -15,4 +17,4 @@ before_build:
|
||||
build_script:
|
||||
- cmake --build . --config %CONFIGURATION%
|
||||
test_script:
|
||||
- ctest -V .
|
||||
- ctest --output-on-failure .
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 32 KiB |
@@ -1,35 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
using namespace ArduinoJson::Internals;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
// wait serial port initialization
|
||||
}
|
||||
|
||||
IndentedPrint serial(Serial);
|
||||
serial.setTabSize(4);
|
||||
|
||||
serial.println("This is at indentation 0");
|
||||
serial.indent();
|
||||
serial.println("This is at indentation 1");
|
||||
serial.println("This is also at indentation 1");
|
||||
serial.indent();
|
||||
serial.println("This is at indentation 2");
|
||||
|
||||
serial.unindent();
|
||||
serial.unindent();
|
||||
serial.println("This is back at indentation 0");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows how to store your project configuration in a file.
|
||||
// It uses the SD library but can be easily modified for any other file-system.
|
||||
//
|
||||
// The file contains a JSON document with the following content:
|
||||
// {
|
||||
// "hostname": "examples.com",
|
||||
// "port": 2731
|
||||
// }
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <SD.h>
|
||||
#include <SPI.h>
|
||||
|
||||
// Configuration that we'll store on disk
|
||||
struct Config {
|
||||
char hostname[64];
|
||||
int port;
|
||||
};
|
||||
|
||||
const char *filename = "/config.txt"; // <- SD library uses 8.3 filenames
|
||||
Config config; // <- global configuration object
|
||||
|
||||
// Loads the configuration from a file
|
||||
void loadConfiguration(const char *filename, Config &config) {
|
||||
// Open file for reading
|
||||
File file = SD.open(filename);
|
||||
|
||||
// Allocate the memory pool on the stack.
|
||||
// Don't forget to change the capacity to match your JSON document.
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<512> jsonBuffer;
|
||||
|
||||
// Parse the root object
|
||||
JsonObject &root = jsonBuffer.parseObject(file);
|
||||
|
||||
if (!root.success())
|
||||
Serial.println(F("Failed to read file, using default configuration"));
|
||||
|
||||
// Copy values from the JsonObject to the Config
|
||||
config.port = root["port"] | 2731;
|
||||
strlcpy(config.hostname, // <- destination
|
||||
root["hostname"] | "example.com", // <- source
|
||||
sizeof(config.hostname)); // <- destination's capacity
|
||||
|
||||
// Close the file (File's destructor doesn't close the file)
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Saves the configuration to a file
|
||||
void saveConfiguration(const char *filename, const Config &config) {
|
||||
// Delete existing file, otherwise the configuration is appended to the file
|
||||
SD.remove(filename);
|
||||
|
||||
// Open file for writing
|
||||
File file = SD.open(filename, FILE_WRITE);
|
||||
if (!file) {
|
||||
Serial.println(F("Failed to create file"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate the memory pool on the stack
|
||||
// Don't forget to change the capacity to match your JSON document.
|
||||
// Use https://arduinojson.org/assistant/ to compute the capacity.
|
||||
StaticJsonBuffer<256> jsonBuffer;
|
||||
|
||||
// Parse the root object
|
||||
JsonObject &root = jsonBuffer.createObject();
|
||||
|
||||
// Set the values
|
||||
root["hostname"] = config.hostname;
|
||||
root["port"] = config.port;
|
||||
|
||||
// Serialize JSON to file
|
||||
if (root.printTo(file) == 0) {
|
||||
Serial.println(F("Failed to write to file"));
|
||||
}
|
||||
|
||||
// Close the file (File's destructor doesn't close the file)
|
||||
file.close();
|
||||
}
|
||||
|
||||
// Prints the content of a file to the Serial
|
||||
void printFile(const char *filename) {
|
||||
// Open file for reading
|
||||
File file = SD.open(filename);
|
||||
if (!file) {
|
||||
Serial.println(F("Failed to read file"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract each characters by one by one
|
||||
while (file.available()) {
|
||||
Serial.print((char)file.read());
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
// Close the file (File's destructor doesn't close the file)
|
||||
file.close();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize SD library
|
||||
while (!SD.begin()) {
|
||||
Serial.println(F("Failed to initialize SD library"));
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// Should load default config if run for the first time
|
||||
Serial.println(F("Loading configuration..."));
|
||||
loadConfiguration(filename, config);
|
||||
|
||||
// Create configuration file
|
||||
Serial.println(F("Saving configuration..."));
|
||||
saveConfiguration(filename, config);
|
||||
|
||||
// Dump config file
|
||||
Serial.println(F("Print config file..."));
|
||||
printFile(filename);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization or deserialization problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a case study of a project that has
|
||||
// a complex configuration with nested members.
|
||||
// Contrary to this example, the project in the book uses the SPIFFS filesystem.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -1,29 +1,27 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
// This example shows how to generate a JSON document with ArduinoJson.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
// Initialize Serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
// wait serial port initialization
|
||||
}
|
||||
while (!Serial) continue;
|
||||
|
||||
// Memory pool for JSON object tree.
|
||||
//
|
||||
// Inside the brackets, 200 is the size of the pool in bytes.
|
||||
// If the JSON object is more complex, you need to increase that value.
|
||||
// Don't forget to change this value to match your JSON document.
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
// StaticJsonBuffer allocates memory on the stack, it can be
|
||||
// replaced by DynamicJsonBuffer which allocates in the heap.
|
||||
// It's simpler but less efficient.
|
||||
//
|
||||
// DynamicJsonBuffer jsonBuffer;
|
||||
// DynamicJsonBuffer jsonBuffer(200);
|
||||
|
||||
// Create the root of the object tree.
|
||||
//
|
||||
@@ -44,8 +42,8 @@ void setup() {
|
||||
// It's also possible to create the array separately and add it to the
|
||||
// JsonObject but it's less efficient.
|
||||
JsonArray& data = root.createNestedArray("data");
|
||||
data.add(double_with_n_digits(48.756080, 6));
|
||||
data.add(double_with_n_digits(2.302038, 6));
|
||||
data.add(48.756080);
|
||||
data.add(2.302038);
|
||||
|
||||
root.printTo(Serial);
|
||||
// This prints:
|
||||
@@ -68,3 +66,16 @@ void setup() {
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
|
||||
// It begins with a simple example, like the one above, and then adds more
|
||||
// features like serializing directly to a file or an HTTP request.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -1,195 +1,112 @@
|
||||
// Sample Arduino Json Web Client
|
||||
// Downloads and parse http://jsonplaceholder.typicode.com/users/1
|
||||
//
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
// This example shows how to parse a JSON document in an HTTP response.
|
||||
// It uses the Ethernet library, but can be easily adapted for Wifi.
|
||||
//
|
||||
// It performs a GET resquest on arduinojson.org/example.json
|
||||
// Here is the expected response:
|
||||
// {
|
||||
// "sensor": "gps",
|
||||
// "time": 1351824120,
|
||||
// "data": [
|
||||
// 48.756080,
|
||||
// 2.302038
|
||||
// ]
|
||||
// }
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
EthernetClient client;
|
||||
|
||||
const char* server = "jsonplaceholder.typicode.com"; // server's address
|
||||
const char* resource = "/users/1"; // http resource
|
||||
const unsigned long BAUD_RATE = 9600; // serial connection speed
|
||||
const unsigned long HTTP_TIMEOUT = 10000; // max respone time from server
|
||||
const size_t MAX_CONTENT_SIZE = 512; // max size of the HTTP response
|
||||
|
||||
// The type of data that we want to extract from the page
|
||||
struct UserData {
|
||||
char name[32];
|
||||
char company[32];
|
||||
};
|
||||
|
||||
// ARDUINO entry point #1: runs once when you press reset or power the board
|
||||
void setup() {
|
||||
initSerial();
|
||||
initEthernet();
|
||||
}
|
||||
// Initialize Serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// ARDUINO entry point #2: runs over and over again forever
|
||||
void loop() {
|
||||
if (connect(server)) {
|
||||
if (sendRequest(server, resource) && skipResponseHeaders()) {
|
||||
char response[MAX_CONTENT_SIZE];
|
||||
readReponseContent(response, sizeof(response));
|
||||
|
||||
UserData userData;
|
||||
if (parseUserData(response, &userData)) {
|
||||
printUserData(&userData);
|
||||
}
|
||||
}
|
||||
disconnect();
|
||||
}
|
||||
wait();
|
||||
}
|
||||
|
||||
// Initialize Serial port
|
||||
void initSerial() {
|
||||
Serial.begin(BAUD_RATE);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to initialize
|
||||
}
|
||||
Serial.println("Serial ready");
|
||||
}
|
||||
|
||||
// Initialize Ethernet library
|
||||
void initEthernet() {
|
||||
// Initialize Ethernet library
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println("Failed to configure Ethernet");
|
||||
Serial.println(F("Failed to configure Ethernet"));
|
||||
return;
|
||||
}
|
||||
Serial.println("Ethernet ready");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// Open connection to the HTTP server
|
||||
bool connect(const char* hostName) {
|
||||
Serial.print("Connect to ");
|
||||
Serial.println(hostName);
|
||||
Serial.println(F("Connecting..."));
|
||||
|
||||
bool ok = client.connect(hostName, 80);
|
||||
// Connect to HTTP server
|
||||
EthernetClient client;
|
||||
client.setTimeout(10000);
|
||||
if (!client.connect("arduinojson.org", 80)) {
|
||||
Serial.println(F("Connection failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println(ok ? "Connected" : "Connection Failed!");
|
||||
return ok;
|
||||
}
|
||||
Serial.println(F("Connected!"));
|
||||
|
||||
// Send the HTTP GET request to the server
|
||||
bool sendRequest(const char* host, const char* resource) {
|
||||
Serial.print("GET ");
|
||||
Serial.println(resource);
|
||||
// Send HTTP request
|
||||
client.println(F("GET /example.json HTTP/1.0"));
|
||||
client.println(F("Host: arduinojson.org"));
|
||||
client.println(F("Connection: close"));
|
||||
if (client.println() == 0) {
|
||||
Serial.println(F("Failed to send request"));
|
||||
return;
|
||||
}
|
||||
|
||||
client.print("GET ");
|
||||
client.print(resource);
|
||||
client.println(" HTTP/1.1");
|
||||
client.print("Host: ");
|
||||
client.println(server);
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
// Check HTTP status
|
||||
char status[32] = {0};
|
||||
client.readBytesUntil('\r', status, sizeof(status));
|
||||
if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
|
||||
Serial.print(F("Unexpected response: "));
|
||||
Serial.println(status);
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip HTTP headers so that we are at the beginning of the response's body
|
||||
bool skipResponseHeaders() {
|
||||
// HTTP headers end with an empty line
|
||||
// Skip HTTP headers
|
||||
char endOfHeaders[] = "\r\n\r\n";
|
||||
|
||||
client.setTimeout(HTTP_TIMEOUT);
|
||||
bool ok = client.find(endOfHeaders);
|
||||
|
||||
if (!ok) {
|
||||
Serial.println("No response or invalid response!");
|
||||
if (!client.find(endOfHeaders)) {
|
||||
Serial.println(F("Invalid response"));
|
||||
return;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Read the body of the response from the HTTP server
|
||||
void readReponseContent(char* content, size_t maxSize) {
|
||||
size_t length = client.readBytes(content, maxSize);
|
||||
content[length] = 0;
|
||||
Serial.println(content);
|
||||
}
|
||||
|
||||
// Parse the JSON from the input string and extract the interesting values
|
||||
// Here is the JSON we need to parse
|
||||
// {
|
||||
// "id": 1,
|
||||
// "name": "Leanne Graham",
|
||||
// "username": "Bret",
|
||||
// "email": "Sincere@april.biz",
|
||||
// "address": {
|
||||
// "street": "Kulas Light",
|
||||
// "suite": "Apt. 556",
|
||||
// "city": "Gwenborough",
|
||||
// "zipcode": "92998-3874",
|
||||
// "geo": {
|
||||
// "lat": "-37.3159",
|
||||
// "lng": "81.1496"
|
||||
// }
|
||||
// },
|
||||
// "phone": "1-770-736-8031 x56442",
|
||||
// "website": "hildegard.org",
|
||||
// "company": {
|
||||
// "name": "Romaguera-Crona",
|
||||
// "catchPhrase": "Multi-layered client-server neural-net",
|
||||
// "bs": "harness real-time e-markets"
|
||||
// }
|
||||
// }
|
||||
bool parseUserData(char* content, struct UserData* userData) {
|
||||
// Compute optimal size of the JSON buffer according to what we need to parse.
|
||||
// This is only required if you use StaticJsonBuffer.
|
||||
const size_t BUFFER_SIZE =
|
||||
JSON_OBJECT_SIZE(8) // the root object has 8 elements
|
||||
+ JSON_OBJECT_SIZE(5) // the "address" object has 5 elements
|
||||
+ JSON_OBJECT_SIZE(2) // the "geo" object has 2 elements
|
||||
+ JSON_OBJECT_SIZE(3); // the "company" object has 3 elements
|
||||
|
||||
// Allocate a temporary memory pool on the stack
|
||||
StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
|
||||
// If the memory pool is too big for the stack, use this instead:
|
||||
// DynamicJsonBuffer jsonBuffer;
|
||||
|
||||
JsonObject& root = jsonBuffer.parseObject(content);
|
||||
// Allocate JsonBuffer
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
|
||||
DynamicJsonBuffer jsonBuffer(capacity);
|
||||
|
||||
// Parse JSON object
|
||||
JsonObject& root = jsonBuffer.parseObject(client);
|
||||
if (!root.success()) {
|
||||
Serial.println("JSON parsing failed!");
|
||||
return false;
|
||||
Serial.println(F("Parsing failed!"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Here were copy the strings we're interested in
|
||||
strcpy(userData->name, root["name"]);
|
||||
strcpy(userData->company, root["company"]["name"]);
|
||||
// It's not mandatory to make a copy, you could just use the pointers
|
||||
// Since, they are pointing inside the "content" buffer, so you need to make
|
||||
// sure it's still in memory when you read the string
|
||||
// Extract values
|
||||
Serial.println(F("Response:"));
|
||||
Serial.println(root["sensor"].as<char*>());
|
||||
Serial.println(root["time"].as<char*>());
|
||||
Serial.println(root["data"][0].as<char*>());
|
||||
Serial.println(root["data"][1].as<char*>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Print the data extracted from the JSON
|
||||
void printUserData(const struct UserData* userData) {
|
||||
Serial.print("Name = ");
|
||||
Serial.println(userData->name);
|
||||
Serial.print("Company = ");
|
||||
Serial.println(userData->company);
|
||||
}
|
||||
|
||||
// Close the connection with the HTTP server
|
||||
void disconnect() {
|
||||
Serial.println("Disconnect");
|
||||
// Disconnect
|
||||
client.stop();
|
||||
}
|
||||
|
||||
// Pause for a 1 minute
|
||||
void wait() {
|
||||
Serial.println("Wait 60 seconds");
|
||||
delay(60000);
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on deserialization
|
||||
// showing how to parse the response from Yahoo Weather. In the last chapter,
|
||||
// it shows how to parse the huge documents from OpenWeatherMap
|
||||
// and Weather Underground.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -1,29 +1,27 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
// This example shows how to deserialize a JSON document with ArduinoJson.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
// wait serial port initialization
|
||||
}
|
||||
while (!Serial) continue;
|
||||
|
||||
// Memory pool for JSON object tree.
|
||||
//
|
||||
// Inside the brackets, 200 is the size of the pool in bytes,
|
||||
// If the JSON object is more complex, you need to increase that value.
|
||||
// Inside the brackets, 200 is the size of the pool in bytes.
|
||||
// Don't forget to change this value to match your JSON document.
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<200> jsonBuffer;
|
||||
|
||||
// StaticJsonBuffer allocates memory on the stack, it can be
|
||||
// replaced by DynamicJsonBuffer which allocates in the heap.
|
||||
// It's simpler but less efficient.
|
||||
//
|
||||
// DynamicJsonBuffer jsonBuffer;
|
||||
// DynamicJsonBuffer jsonBuffer(200);
|
||||
|
||||
// JSON input string.
|
||||
//
|
||||
@@ -65,3 +63,16 @@ void setup() {
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// deserialization problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on deserialization.
|
||||
// It begins with a simple example, like the one above, and then adds more
|
||||
// features like deserializing directly from a file or an HTTP request.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -1,74 +1,109 @@
|
||||
// Sample Arduino Json Web Server
|
||||
// Created by Benoit Blanchon.
|
||||
// Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows how to implement an HTTP server that sends JSON document
|
||||
// in the responses.
|
||||
// It uses the Ethernet library but can be easily adapted for Wifi.
|
||||
//
|
||||
// It sends the value of the analog and digital pins.
|
||||
// The JSON document looks like the following:
|
||||
// {
|
||||
// "analog": [ 0, 1, 2, 3, 4, 5 ],
|
||||
// "digital": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
|
||||
// }
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
IPAddress ip(192, 168, 0, 177);
|
||||
EthernetServer server(80);
|
||||
|
||||
bool readRequest(EthernetClient& client) {
|
||||
bool currentLineIsBlank = true;
|
||||
while (client.connected()) {
|
||||
if (client.available()) {
|
||||
char c = client.read();
|
||||
if (c == '\n' && currentLineIsBlank) {
|
||||
return true;
|
||||
} else if (c == '\n') {
|
||||
currentLineIsBlank = true;
|
||||
} else if (c != '\r') {
|
||||
currentLineIsBlank = false;
|
||||
}
|
||||
}
|
||||
void setup() {
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize Ethernet libary
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println(F("Failed to initialize Ethernet library"));
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
|
||||
// Start to listen
|
||||
server.begin();
|
||||
|
||||
Serial.println(F("Server is ready."));
|
||||
Serial.print(F("Please connect to http://"));
|
||||
Serial.println(Ethernet.localIP());
|
||||
}
|
||||
|
||||
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
|
||||
void loop() {
|
||||
// Wait for an incomming connection
|
||||
EthernetClient client = server.available();
|
||||
|
||||
// Do we have a client?
|
||||
if (!client) return;
|
||||
|
||||
Serial.println(F("New client"));
|
||||
|
||||
// Read the request (we ignore the content in this example)
|
||||
while (client.available()) client.read();
|
||||
|
||||
// Allocate JsonBuffer
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
|
||||
// Create the root object
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
// Create the "analog" array
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
// Read the analog input
|
||||
int value = analogRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
// Create the "digital" array
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
// Read the digital input
|
||||
int value = digitalRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
Serial.print(F("Sending: "));
|
||||
root.printTo(Serial);
|
||||
Serial.println();
|
||||
|
||||
void writeResponse(EthernetClient& client, JsonObject& json) {
|
||||
client.println("HTTP/1.1 200 OK");
|
||||
// Write response headers
|
||||
client.println("HTTP/1.0 200 OK");
|
||||
client.println("Content-Type: application/json");
|
||||
client.println("Connection: close");
|
||||
client.println();
|
||||
|
||||
json.prettyPrintTo(client);
|
||||
// Write JSON document
|
||||
root.prettyPrintTo(client);
|
||||
|
||||
// Disconnect
|
||||
client.stop();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Ethernet.begin(mac, ip);
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
EthernetClient client = server.available();
|
||||
if (client) {
|
||||
bool success = readRequest(client);
|
||||
if (success) {
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
JsonObject& json = prepareResponse(jsonBuffer);
|
||||
writeResponse(client, json);
|
||||
}
|
||||
delay(1);
|
||||
client.stop();
|
||||
}
|
||||
}
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
|
||||
// It begins with a simple example, then adds more features like serializing
|
||||
// directly to a file or an HTTP client.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -1,55 +1,101 @@
|
||||
// Send a JSON object on UDP at regular interval
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// You can easily test this program with netcat:
|
||||
// $ nc -ulp 8888
|
||||
// This example shows how to send a JSON document to a UDP socket.
|
||||
// At regular interval, it sends a UDP packet that contains the status of
|
||||
// analog and digital pins.
|
||||
// The JSON document looks like the following:
|
||||
// {
|
||||
// "analog": [ 0, 1, 2, 3, 4, 5 ],
|
||||
// "digital": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
|
||||
// }
|
||||
//
|
||||
// by Benoit Blanchon, MIT License 2015-2016
|
||||
// If you want to test this program, you need to be able to receive the UDP
|
||||
// packets.
|
||||
// For example, you can run netcat on your computer
|
||||
// $ ncat -ulp 8888
|
||||
// See https://nmap.org/ncat/
|
||||
|
||||
#include <SPI.h>
|
||||
#include <Ethernet.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
|
||||
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
|
||||
IPAddress localIp(192, 168, 0, 177);
|
||||
IPAddress remoteIp(192, 168, 0, 109);
|
||||
unsigned int remotePort = 8888;
|
||||
unsigned localPort = 8888;
|
||||
IPAddress remoteIp(192, 168, 0, 108); // <- EDIT!!!!
|
||||
unsigned short remotePort = 8888;
|
||||
unsigned short localPort = 8888;
|
||||
EthernetUDP udp;
|
||||
|
||||
JsonObject& buildJson(JsonBuffer& jsonBuffer) {
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
int value = analogRead(pin);
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
int value = digitalRead(pin);
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
void sendJson(JsonObject& json) {
|
||||
udp.beginPacket(remoteIp, remotePort);
|
||||
json.printTo(udp);
|
||||
udp.println();
|
||||
udp.endPacket();
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Ethernet.begin(mac, localIp);
|
||||
// Initialize serial port
|
||||
Serial.begin(9600);
|
||||
while (!Serial) continue;
|
||||
|
||||
// Initialize Ethernet libary
|
||||
if (!Ethernet.begin(mac)) {
|
||||
Serial.println(F("Failed to initialize Ethernet library"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable UDP
|
||||
udp.begin(localPort);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(1000);
|
||||
// Allocate JsonBuffer
|
||||
// Use arduinojson.org/assistant to compute the capacity.
|
||||
StaticJsonBuffer<500> jsonBuffer;
|
||||
|
||||
StaticJsonBuffer<300> jsonBuffer;
|
||||
JsonObject& json = buildJson(jsonBuffer);
|
||||
sendJson(json);
|
||||
// Create the root object
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
|
||||
// Create the "analog" array
|
||||
JsonArray& analogValues = root.createNestedArray("analog");
|
||||
for (int pin = 0; pin < 6; pin++) {
|
||||
// Read the analog input
|
||||
int value = analogRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
analogValues.add(value);
|
||||
}
|
||||
|
||||
// Create the "digital" array
|
||||
JsonArray& digitalValues = root.createNestedArray("digital");
|
||||
for (int pin = 0; pin < 14; pin++) {
|
||||
// Read the digital input
|
||||
int value = digitalRead(pin);
|
||||
|
||||
// Add the value at the end of the array
|
||||
digitalValues.add(value);
|
||||
}
|
||||
|
||||
// Log
|
||||
Serial.print(F("Sending to "));
|
||||
Serial.print(remoteIp);
|
||||
Serial.print(F(" on port "));
|
||||
Serial.println(remotePort);
|
||||
root.printTo(Serial);
|
||||
|
||||
// Send UDP packet
|
||||
udp.beginPacket(remoteIp, remotePort);
|
||||
root.printTo(udp);
|
||||
udp.println();
|
||||
udp.endPacket();
|
||||
|
||||
// Wait
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any
|
||||
// serialization problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a tutorial on serialization.
|
||||
// It begins with a simple example, then adds more features like serializing
|
||||
// directly to a file or any stream.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -0,0 +1,70 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows the different ways you can use Flash strings with
|
||||
// ArduinoJson.
|
||||
//
|
||||
// Use Flash strings sparingly, because ArduinoJson duplicates them in the
|
||||
// JsonBuffer. Prefer plain old char*, as they are more efficient in term of
|
||||
// code size, speed, and memory usage.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
#ifdef PROGMEM // <- check that Flash strings are supported
|
||||
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
|
||||
// You can use a Flash String as your JSON input.
|
||||
// WARNING: the content of the Flash String will be duplicated in the
|
||||
// JsonBuffer.
|
||||
JsonObject& root =
|
||||
jsonBuffer.parseObject(F("{\"sensor\":\"gps\",\"time\":1351824120,"
|
||||
"\"data\":[48.756080,2.302038]}"));
|
||||
|
||||
// You can use a Flash String to get an element of a JsonObject
|
||||
// No duplication is done.
|
||||
long time = root[F("time")];
|
||||
|
||||
// You can use a Flash String to set an element of a JsonObject
|
||||
// WARNING: the content of the Flash String will be duplicated in the
|
||||
// JsonBuffer.
|
||||
root[F("time")] = time;
|
||||
|
||||
// You can set a Flash String to a JsonObject or JsonArray:
|
||||
// WARNING: the content of the Flash String will be duplicated in the
|
||||
// JsonBuffer.
|
||||
root["sensor"] = F("gps");
|
||||
|
||||
// It works with RawJson too:
|
||||
root["sensor"] = RawJson(F("\"gps\""));
|
||||
|
||||
// You can compare the content of a JsonVariant to a Flash String
|
||||
if (root["sensor"] == F("gps")) {
|
||||
// ...
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#warning PROGMEM is not supported on this platform
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any memory
|
||||
// problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a quick C++ course that explains
|
||||
// how your microcontroller stores strings in memory. It also tells why you
|
||||
// should not abuse Flash strings with ArduinoJson.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -0,0 +1,74 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
//
|
||||
// This example shows the different ways you can use String with ArduinoJson.
|
||||
//
|
||||
// Use String objects sparingly, because ArduinoJson duplicates them in the
|
||||
// JsonBuffer. Prefer plain old char[], as they are more efficient in term of
|
||||
// code size, speed, and memory usage.
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
|
||||
// You can use a String as your JSON input.
|
||||
// WARNING: the content of the String will be duplicated in the JsonBuffer.
|
||||
String input =
|
||||
"{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||
JsonObject& root = jsonBuffer.parseObject(input);
|
||||
|
||||
// You can use a String to get an element of a JsonObject
|
||||
// No duplication is done.
|
||||
long time = root[String("time")];
|
||||
|
||||
// You can use a String to set an element of a JsonObject
|
||||
// WARNING: the content of the String will be duplicated in the JsonBuffer.
|
||||
root[String("time")] = time;
|
||||
|
||||
// You can get a String from a JsonObject or JsonArray:
|
||||
// No duplication is done, at least not in the JsonBuffer.
|
||||
String sensor = root["sensor"];
|
||||
|
||||
// Unfortunately, the following doesn't work (issue #118):
|
||||
// sensor = root["sensor"]; // <- error "ambiguous overload for 'operator='"
|
||||
// As a workaround, you need to replace by:
|
||||
sensor = root["sensor"].as<String>();
|
||||
|
||||
// You can set a String to a JsonObject or JsonArray:
|
||||
// WARNING: the content of the String will be duplicated in the JsonBuffer.
|
||||
root["sensor"] = sensor;
|
||||
|
||||
// It works with RawJson too:
|
||||
root["sensor"] = RawJson(sensor);
|
||||
|
||||
// You can also concatenate strings
|
||||
// WARNING: the content of the String will be duplicated in the JsonBuffer.
|
||||
root[String("sen") + "sor"] = String("gp") + "s";
|
||||
|
||||
// You can compare the content of a JsonObject with a String
|
||||
if (root["sensor"] == sensor) {
|
||||
// ...
|
||||
}
|
||||
|
||||
// Lastly, you can print the resulting JSON to a String
|
||||
String output;
|
||||
root.printTo(output);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// not used in this example
|
||||
}
|
||||
|
||||
// See also
|
||||
// --------
|
||||
//
|
||||
// The website arduinojson.org contains the documentation for all the functions
|
||||
// used above. It also includes an FAQ that will help you solve any problem.
|
||||
// Please check it out at: https://arduinojson.org/
|
||||
//
|
||||
// The book "Mastering ArduinoJson" contains a quick C++ course that explains
|
||||
// how your microcontroller stores strings in memory. On several occasions, it
|
||||
// shows how you can avoid String in your program.
|
||||
// Please check it out at: https://arduinojson.org/book/
|
||||
@@ -0,0 +1,19 @@
|
||||
# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
|
||||
|
||||
CXXFLAGS += -I../src
|
||||
|
||||
all: \
|
||||
$(OUT)/json_fuzzer \
|
||||
$(OUT)/json_fuzzer_seed_corpus.zip \
|
||||
$(OUT)/json_fuzzer.options
|
||||
|
||||
$(OUT)/json_fuzzer: fuzzer.cpp $(shell find ../src -type f)
|
||||
$(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
|
||||
|
||||
$(OUT)/json_fuzzer_seed_corpus.zip: seed_corpus/*
|
||||
zip -j $@ $?
|
||||
|
||||
$(OUT)/json_fuzzer.options:
|
||||
@echo "[libfuzzer]" > $@
|
||||
@echo "max_len = 256" >> $@
|
||||
@echo "timeout = 10" >> $@
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class memstream : public std::istream {
|
||||
struct membuf : std::streambuf {
|
||||
membuf(const uint8_t *p, size_t l) {
|
||||
setg((char *)p, (char *)p, (char *)p + l);
|
||||
}
|
||||
};
|
||||
membuf _buffer;
|
||||
|
||||
public:
|
||||
memstream(const uint8_t *p, size_t l)
|
||||
: std::istream(&_buffer), _buffer(p, l) {
|
||||
rdbuf(&_buffer);
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
memstream json(data, size);
|
||||
JsonVariant variant = jsonBuffer.parse(json);
|
||||
if (variant.success()) {
|
||||
variant.as<std::string>(); // <- serialize to JSON
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,10 @@
|
||||
//comment
|
||||
/*comment*/
|
||||
[ //comment
|
||||
/*comment*/"comment"/*comment*/,//comment
|
||||
/*comment*/{//comment
|
||||
/* comment*/"key"//comment
|
||||
: //comment
|
||||
"value"//comment
|
||||
}/*comment*/
|
||||
]//comment
|
||||
@@ -0,0 +1 @@
|
||||
[]
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
[1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20,[21,[22,[23,[24,[25,[26,[27,[28,[29,[30,[31,[32,[33,[34,[35,[36,[37,[38,[39,[40,[41,[42,[43,[44,[45,[46,[47,[48,[49,[50,[51,[52,[53,[54,[55,[56,[57,[58,[59,[60,[61,[62,[63,[64,[65,[66,[67,[68,[69,[70,[71,[72,[73,[74,[75,[76,[77,[78,[79,[80,[81,[82,[83,[84,[85,[86,[87,[88,[89,[90,[91,[92,[93,[94,[95,[96,[97,[98,[99,[100,[101,[102,[103,[104,[105,[106,[107,[108,[109,[110,[111,[112,[113,[114,[115,[116,[117,[118,[119,[120]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
||||
@@ -0,0 +1,24 @@
|
||||
[
|
||||
123,
|
||||
-123,
|
||||
123.456,
|
||||
-123.456,
|
||||
12e34,
|
||||
12e-34,
|
||||
12e+34,
|
||||
12E34,
|
||||
12E-34,
|
||||
12E+34,
|
||||
12.34e56,
|
||||
12.34e-56,
|
||||
12.34e+56,
|
||||
12.34E56,
|
||||
12.34E-56,
|
||||
12.34E+56,
|
||||
NaN,
|
||||
-NaN,
|
||||
+NaN,
|
||||
Infinity,
|
||||
+Infinity,
|
||||
-Infinity
|
||||
]
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"coord": {
|
||||
"lon": -0.13,
|
||||
"lat": 51.51
|
||||
},
|
||||
"weather": [
|
||||
{
|
||||
"id": 301,
|
||||
"main": "Drizzle",
|
||||
"description": "drizzle",
|
||||
"icon": "09n"
|
||||
},
|
||||
{
|
||||
"id": 701,
|
||||
"main": "Mist",
|
||||
"description": "mist",
|
||||
"icon": "50n"
|
||||
},
|
||||
{
|
||||
"id": 741,
|
||||
"main": "Fog",
|
||||
"description": "fog",
|
||||
"icon": "50n"
|
||||
}
|
||||
],
|
||||
"base": "stations",
|
||||
"main": {
|
||||
"temp": 281.87,
|
||||
"pressure": 1032,
|
||||
"humidity": 100,
|
||||
"temp_min": 281.15,
|
||||
"temp_max": 283.15
|
||||
},
|
||||
"visibility": 2900,
|
||||
"wind": {
|
||||
"speed": 1.5
|
||||
},
|
||||
"clouds": {
|
||||
"all": 90
|
||||
},
|
||||
"dt": 1483820400,
|
||||
"sys": {
|
||||
"type": 1,
|
||||
"id": 5091,
|
||||
"message": 0.0226,
|
||||
"country": "GB",
|
||||
"sunrise": 1483776245,
|
||||
"sunset": 1483805443
|
||||
},
|
||||
"id": 2643743,
|
||||
"name": "London",
|
||||
"cod": 200
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
[
|
||||
"hello",
|
||||
'hello',
|
||||
hello,
|
||||
{"hello":"world"},
|
||||
{'hello':'world'},
|
||||
{hello:world}
|
||||
]
|
||||
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"response": {
|
||||
"version": "0.1",
|
||||
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
|
||||
"features": {
|
||||
"conditions": 1
|
||||
}
|
||||
},
|
||||
"current_observation": {
|
||||
"image": {
|
||||
"url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
|
||||
"title": "Weather Underground",
|
||||
"link": "http://www.wunderground.com"
|
||||
},
|
||||
"display_location": {
|
||||
"full": "San Francisco, CA",
|
||||
"city": "San Francisco",
|
||||
"state": "CA",
|
||||
"state_name": "California",
|
||||
"country": "US",
|
||||
"country_iso3166": "US",
|
||||
"zip": "94101",
|
||||
"latitude": "37.77500916",
|
||||
"longitude": "-122.41825867",
|
||||
"elevation": "47.00000000"
|
||||
},
|
||||
"observation_location": {
|
||||
"full": "SOMA - Near Van Ness, San Francisco, California",
|
||||
"city": "SOMA - Near Van Ness, San Francisco",
|
||||
"state": "California",
|
||||
"country": "US",
|
||||
"country_iso3166": "US",
|
||||
"latitude": "37.773285",
|
||||
"longitude": "-122.417725",
|
||||
"elevation": "49 ft"
|
||||
},
|
||||
"estimated": {},
|
||||
"station_id": "KCASANFR58",
|
||||
"observation_time": "Last Updated on June 27, 5:27 PM PDT",
|
||||
"observation_time_rfc822": "Wed, 27 Jun 2012 17:27:13 -0700",
|
||||
"observation_epoch": "1340843233",
|
||||
"local_time_rfc822": "Wed, 27 Jun 2012 17:27:14 -0700",
|
||||
"local_epoch": "1340843234",
|
||||
"local_tz_short": "PDT",
|
||||
"local_tz_long": "America/Los_Angeles",
|
||||
"local_tz_offset": "-0700",
|
||||
"weather": "Partly Cloudy",
|
||||
"temperature_string": "66.3 F (19.1 C)",
|
||||
"temp_f": 66.3,
|
||||
"temp_c": 19.1,
|
||||
"relative_humidity": "65%",
|
||||
"wind_string": "From the NNW at 22.0 MPH Gusting to 28.0 MPH",
|
||||
"wind_dir": "NNW",
|
||||
"wind_degrees": 346,
|
||||
"wind_mph": 22,
|
||||
"wind_gust_mph": "28.0",
|
||||
"wind_kph": 35.4,
|
||||
"wind_gust_kph": "45.1",
|
||||
"pressure_mb": "1013",
|
||||
"pressure_in": "29.93",
|
||||
"pressure_trend": "+",
|
||||
"dewpoint_string": "54 F (12 C)",
|
||||
"dewpoint_f": 54,
|
||||
"dewpoint_c": 12,
|
||||
"heat_index_string": "NA",
|
||||
"heat_index_f": "NA",
|
||||
"heat_index_c": "NA",
|
||||
"windchill_string": "NA",
|
||||
"windchill_f": "NA",
|
||||
"windchill_c": "NA",
|
||||
"feelslike_string": "66.3 F (19.1 C)",
|
||||
"feelslike_f": "66.3",
|
||||
"feelslike_c": "19.1",
|
||||
"visibility_mi": "10.0",
|
||||
"visibility_km": "16.1",
|
||||
"solarradiation": "",
|
||||
"UV": "5",
|
||||
"precip_1hr_string": "0.00 in ( 0 mm)",
|
||||
"precip_1hr_in": "0.00",
|
||||
"precip_1hr_metric": " 0",
|
||||
"precip_today_string": "0.00 in (0 mm)",
|
||||
"precip_today_in": "0.00",
|
||||
"precip_today_metric": "0",
|
||||
"icon": "partlycloudy",
|
||||
"icon_url": "http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
|
||||
"forecast_url": "http://www.wunderground.com/US/CA/San_Francisco.html",
|
||||
"history_url": "http://www.wunderground.com/history/airport/KCASANFR58/2012/6/27/DailyHistory.html",
|
||||
"ob_url": "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=37.773285,-122.417725"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#include "ArduinoJson.hpp"
|
||||
using namespace ArduinoJson;
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ArduinoJson/DynamicJsonBuffer.hpp"
|
||||
#include "ArduinoJson/JsonArray.hpp"
|
||||
#include "ArduinoJson/JsonObject.hpp"
|
||||
#include "ArduinoJson/StaticJsonBuffer.hpp"
|
||||
|
||||
#include "ArduinoJson/Internals/JsonParser.ipp"
|
||||
#include "ArduinoJson/JsonArray.ipp"
|
||||
#include "ArduinoJson/JsonBuffer.ipp"
|
||||
#include "ArduinoJson/JsonObject.ipp"
|
||||
#include "ArduinoJson/JsonVariant.ipp"
|
||||
|
||||
using namespace ArduinoJson;
|
||||
@@ -1,89 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ARDUINO // assume this is an embedded platform
|
||||
|
||||
// store using float instead of double to reduce the memory usage (issue #134)
|
||||
#ifndef ARDUINOJSON_USE_DOUBLE
|
||||
#define ARDUINOJSON_USE_DOUBLE 0
|
||||
#endif
|
||||
|
||||
// store using a long because it usually match the size of a float.
|
||||
#ifndef ARDUINOJSON_USE_LONG_LONG
|
||||
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||
#endif
|
||||
#ifndef ARDUINOJSON_USE_INT64
|
||||
#define ARDUINOJSON_USE_INT64 0
|
||||
#endif
|
||||
|
||||
// arduino has its own implementation of String to replace std::string
|
||||
#ifndef ARDUINOJSON_USE_ARDUINO_STRING
|
||||
#define ARDUINOJSON_USE_ARDUINO_STRING 1
|
||||
#endif
|
||||
|
||||
// arduino doesn't support STL stream
|
||||
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
|
||||
#define ARDUINOJSON_ENABLE_STD_STREAM 0
|
||||
#endif
|
||||
|
||||
#ifndef ARDUINOJSON_ENABLE_ALIGNMENT
|
||||
#ifdef ARDUINO_ARCH_AVR
|
||||
// alignment isn't needed for 8-bit AVR
|
||||
#define ARDUINOJSON_ENABLE_ALIGNMENT 0
|
||||
#else
|
||||
// but must processor needs pointer to be align on word size
|
||||
#define ARDUINOJSON_ENABLE_ALIGNMENT 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else // assume this is a computer
|
||||
|
||||
// on a computer we have plenty of memory so we can use doubles
|
||||
#ifndef ARDUINOJSON_USE_DOUBLE
|
||||
#define ARDUINOJSON_USE_DOUBLE 1
|
||||
#endif
|
||||
|
||||
// use long long when available
|
||||
#ifndef ARDUINOJSON_USE_LONG_LONG
|
||||
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||
#define ARDUINOJSON_USE_LONG_LONG 1
|
||||
#else
|
||||
#define ARDUINOJSON_USE_LONG_LONG 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// use _int64 on old versions of Visual Studio
|
||||
#ifndef ARDUINOJSON_USE_INT64
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1700
|
||||
#define ARDUINOJSON_USE_INT64 1
|
||||
#else
|
||||
#define ARDUINOJSON_USE_INT64 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// on a computer, we can use std::string
|
||||
#ifndef ARDUINOJSON_USE_ARDUINO_STRING
|
||||
#define ARDUINOJSON_USE_ARDUINO_STRING 0
|
||||
#endif
|
||||
|
||||
// on a computer, we can assume that the STL is there
|
||||
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
|
||||
#define ARDUINOJSON_ENABLE_STD_STREAM 1
|
||||
#endif
|
||||
|
||||
#ifndef ARDUINOJSON_ENABLE_ALIGNMENT
|
||||
// even if not required, most cpu's are faster with aligned pointers
|
||||
#define ARDUINOJSON_ENABLE_ALIGNMENT 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_USE_LONG_LONG && ARDUINOJSON_USE_INT64
|
||||
#error ARDUINOJSON_USE_LONG_LONG and ARDUINOJSON_USE_INT64 cannot be set together
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Internals/BlockJsonBuffer.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
// Implements a JsonBuffer with dynamic memory allocation.
|
||||
// You are strongly encouraged to consider using StaticJsonBuffer which is much
|
||||
// more suitable for embedded systems.
|
||||
typedef Internals::BlockJsonBuffer<Internals::DefaultAllocator>
|
||||
DynamicJsonBuffer;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
inline const char *skipCStyleComment(const char *ptr) {
|
||||
ptr += 2;
|
||||
for (;;) {
|
||||
if (ptr[0] == '\0') return ptr;
|
||||
if (ptr[0] == '*' && ptr[1] == '/') return ptr + 2;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
inline const char *skipCppStyleComment(const char *ptr) {
|
||||
ptr += 2;
|
||||
for (;;) {
|
||||
if (ptr[0] == '\0' || ptr[0] == '\n') return ptr;
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
inline const char *skipSpacesAndComments(const char *ptr) {
|
||||
for (;;) {
|
||||
switch (ptr[0]) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
ptr++;
|
||||
continue;
|
||||
case '/':
|
||||
switch (ptr[1]) {
|
||||
case '*':
|
||||
ptr = skipCStyleComment(ptr);
|
||||
break;
|
||||
case '/':
|
||||
ptr = skipCppStyleComment(ptr);
|
||||
break;
|
||||
default:
|
||||
return ptr;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Print.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// A dummy Print implementation used in JsonPrintable::measureLength()
|
||||
class DummyPrint : public Print {
|
||||
public:
|
||||
virtual size_t write(uint8_t) { return 1; }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Print.hpp"
|
||||
#include "../String.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// A Print implementation that allows to write in a String
|
||||
class DynamicStringBuilder : public Print {
|
||||
public:
|
||||
DynamicStringBuilder(String &str) : _str(str) {}
|
||||
|
||||
virtual size_t write(uint8_t c) {
|
||||
// Need to cast to char, otherwise String will print a number (issue #120)
|
||||
_str += static_cast<char>(c);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
DynamicStringBuilder &operator=(const DynamicStringBuilder &);
|
||||
|
||||
String &_str;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JsonBuffer.hpp"
|
||||
#include "../JsonVariant.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// Parse JSON string to create JsonArrays and JsonObjects
|
||||
// This internal class is not indended to be used directly.
|
||||
// Instead, use JsonBuffer.parseArray() or .parseObject()
|
||||
class JsonParser {
|
||||
public:
|
||||
JsonParser(JsonBuffer *buffer, char *json, uint8_t nestingLimit)
|
||||
: _buffer(buffer),
|
||||
_readPtr(json ? json : ""),
|
||||
_writePtr(json),
|
||||
_nestingLimit(nestingLimit) {}
|
||||
|
||||
JsonArray &parseArray();
|
||||
JsonObject &parseObject();
|
||||
|
||||
JsonVariant parseVariant() {
|
||||
JsonVariant result;
|
||||
parseAnythingTo(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
bool skip(char charToSkip);
|
||||
|
||||
const char *parseString();
|
||||
bool parseAnythingTo(JsonVariant *destination);
|
||||
FORCE_INLINE bool parseAnythingToUnsafe(JsonVariant *destination);
|
||||
|
||||
inline bool parseArrayTo(JsonVariant *destination);
|
||||
inline bool parseObjectTo(JsonVariant *destination);
|
||||
inline bool parseStringTo(JsonVariant *destination);
|
||||
|
||||
static inline bool isInRange(char c, char min, char max) {
|
||||
return min <= c && c <= max;
|
||||
}
|
||||
|
||||
static inline bool isLetterOrNumber(char c) {
|
||||
return isInRange(c, '0', '9') || isInRange(c, 'a', 'z') ||
|
||||
isInRange(c, 'A', 'Z') || c == '-' || c == '.';
|
||||
}
|
||||
|
||||
static inline bool isQuote(char c) {
|
||||
return c == '\'' || c == '\"';
|
||||
}
|
||||
|
||||
JsonBuffer *_buffer;
|
||||
const char *_readPtr;
|
||||
char *_writePtr;
|
||||
uint8_t _nestingLimit;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Comments.hpp"
|
||||
#include "JsonParser.hpp"
|
||||
|
||||
inline bool ArduinoJson::Internals::JsonParser::skip(char charToSkip) {
|
||||
const char *ptr = skipSpacesAndComments(_readPtr);
|
||||
if (*ptr != charToSkip) return false;
|
||||
ptr++;
|
||||
_readPtr = skipSpacesAndComments(ptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool ArduinoJson::Internals::JsonParser::parseAnythingTo(
|
||||
JsonVariant *destination) {
|
||||
if (_nestingLimit == 0) return false;
|
||||
_nestingLimit--;
|
||||
bool success = parseAnythingToUnsafe(destination);
|
||||
_nestingLimit++;
|
||||
return success;
|
||||
}
|
||||
|
||||
inline bool ArduinoJson::Internals::JsonParser::parseAnythingToUnsafe(
|
||||
JsonVariant *destination) {
|
||||
_readPtr = skipSpacesAndComments(_readPtr);
|
||||
|
||||
switch (*_readPtr) {
|
||||
case '[':
|
||||
return parseArrayTo(destination);
|
||||
|
||||
case '{':
|
||||
return parseObjectTo(destination);
|
||||
|
||||
default:
|
||||
return parseStringTo(destination);
|
||||
}
|
||||
}
|
||||
|
||||
inline ArduinoJson::JsonArray &
|
||||
ArduinoJson::Internals::JsonParser::parseArray() {
|
||||
// Create an empty array
|
||||
JsonArray &array = _buffer->createArray();
|
||||
|
||||
// Check opening braket
|
||||
if (!skip('[')) goto ERROR_MISSING_BRACKET;
|
||||
if (skip(']')) goto SUCCESS_EMPTY_ARRAY;
|
||||
|
||||
// Read each value
|
||||
for (;;) {
|
||||
// 1 - Parse value
|
||||
JsonVariant value;
|
||||
if (!parseAnythingTo(&value)) goto ERROR_INVALID_VALUE;
|
||||
if (!array.add(value)) goto ERROR_NO_MEMORY;
|
||||
|
||||
// 2 - More values?
|
||||
if (skip(']')) goto SUCCES_NON_EMPTY_ARRAY;
|
||||
if (!skip(',')) goto ERROR_MISSING_COMMA;
|
||||
}
|
||||
|
||||
SUCCESS_EMPTY_ARRAY:
|
||||
SUCCES_NON_EMPTY_ARRAY:
|
||||
return array;
|
||||
|
||||
ERROR_INVALID_VALUE:
|
||||
ERROR_MISSING_BRACKET:
|
||||
ERROR_MISSING_COMMA:
|
||||
ERROR_NO_MEMORY:
|
||||
return JsonArray::invalid();
|
||||
}
|
||||
|
||||
inline bool ArduinoJson::Internals::JsonParser::parseArrayTo(
|
||||
JsonVariant *destination) {
|
||||
JsonArray &array = parseArray();
|
||||
if (!array.success()) return false;
|
||||
|
||||
*destination = array;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline ArduinoJson::JsonObject &
|
||||
ArduinoJson::Internals::JsonParser::parseObject() {
|
||||
// Create an empty object
|
||||
JsonObject &object = _buffer->createObject();
|
||||
|
||||
// Check opening brace
|
||||
if (!skip('{')) goto ERROR_MISSING_BRACE;
|
||||
if (skip('}')) goto SUCCESS_EMPTY_OBJECT;
|
||||
|
||||
// Read each key value pair
|
||||
for (;;) {
|
||||
// 1 - Parse key
|
||||
const char *key = parseString();
|
||||
if (!key) goto ERROR_INVALID_KEY;
|
||||
if (!skip(':')) goto ERROR_MISSING_COLON;
|
||||
|
||||
// 2 - Parse value
|
||||
JsonVariant value;
|
||||
if (!parseAnythingTo(&value)) goto ERROR_INVALID_VALUE;
|
||||
if (!object.set(key, value)) goto ERROR_NO_MEMORY;
|
||||
|
||||
// 3 - More keys/values?
|
||||
if (skip('}')) goto SUCCESS_NON_EMPTY_OBJECT;
|
||||
if (!skip(',')) goto ERROR_MISSING_COMMA;
|
||||
}
|
||||
|
||||
SUCCESS_EMPTY_OBJECT:
|
||||
SUCCESS_NON_EMPTY_OBJECT:
|
||||
return object;
|
||||
|
||||
ERROR_INVALID_KEY:
|
||||
ERROR_INVALID_VALUE:
|
||||
ERROR_MISSING_BRACE:
|
||||
ERROR_MISSING_COLON:
|
||||
ERROR_MISSING_COMMA:
|
||||
ERROR_NO_MEMORY:
|
||||
return JsonObject::invalid();
|
||||
}
|
||||
|
||||
inline bool ArduinoJson::Internals::JsonParser::parseObjectTo(
|
||||
JsonVariant *destination) {
|
||||
JsonObject &object = parseObject();
|
||||
if (!object.success()) return false;
|
||||
|
||||
*destination = object;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const char *ArduinoJson::Internals::JsonParser::parseString() {
|
||||
const char *readPtr = _readPtr;
|
||||
char *writePtr = _writePtr;
|
||||
|
||||
char c = *readPtr;
|
||||
|
||||
if (isQuote(c)) { // quotes
|
||||
char stopChar = c;
|
||||
for (;;) {
|
||||
c = *++readPtr;
|
||||
if (c == '\0') break;
|
||||
|
||||
if (c == stopChar) {
|
||||
readPtr++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '\\') {
|
||||
// replace char
|
||||
c = Encoding::unescapeChar(*++readPtr);
|
||||
if (c == '\0') break;
|
||||
}
|
||||
|
||||
*writePtr++ = c;
|
||||
}
|
||||
} else { // no quotes
|
||||
for (;;) {
|
||||
if (!isLetterOrNumber(c)) break;
|
||||
*writePtr++ = c;
|
||||
c = *++readPtr;
|
||||
}
|
||||
}
|
||||
// end the string here
|
||||
*writePtr++ = '\0';
|
||||
|
||||
const char *startPtr = _writePtr;
|
||||
|
||||
// update end ptr
|
||||
_readPtr = readPtr;
|
||||
_writePtr = writePtr;
|
||||
|
||||
// return pointer to unquoted string
|
||||
return startPtr;
|
||||
}
|
||||
|
||||
inline bool ArduinoJson::Internals::JsonParser::parseStringTo(
|
||||
JsonVariant *destination) {
|
||||
bool hasQuotes = isQuote(_readPtr[0]);
|
||||
const char *value = parseString();
|
||||
if (value == NULL) return false;
|
||||
if (hasQuotes) {
|
||||
*destination = value;
|
||||
} else {
|
||||
*destination = RawJson(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
class JsonArray;
|
||||
class JsonObject;
|
||||
|
||||
namespace Internals {
|
||||
|
||||
// Enumerated type to know the current type of a JsonVariant.
|
||||
// The value determines which member of JsonVariantContent is used.
|
||||
enum JsonVariantType {
|
||||
JSON_UNDEFINED, // JsonVariant has not been initialized
|
||||
JSON_UNPARSED, // JsonVariant contains an unparsed string
|
||||
JSON_STRING, // JsonVariant stores a const char*
|
||||
JSON_BOOLEAN, // JsonVariant stores a bool
|
||||
JSON_POSITIVE_INTEGER, // JsonVariant stores an unsigned long
|
||||
JSON_NEGATIVE_INTEGER, // JsonVariant stores an unsigned long that must be
|
||||
// negated
|
||||
JSON_ARRAY, // JsonVariant stores a pointer to a JsonArray
|
||||
JSON_OBJECT, // JsonVariant stores a pointer to a JsonObject
|
||||
|
||||
// The following values are reserved for float values
|
||||
// Multiple values are used for double, depending on the number of decimal
|
||||
// digits that must be printed in the JSON output.
|
||||
// This little trick allow to save one extra member in JsonVariant
|
||||
JSON_FLOAT_0_DECIMALS
|
||||
// JSON_FLOAT_1_DECIMAL
|
||||
// JSON_FLOAT_2_DECIMALS
|
||||
// ...
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Polyfills/attributes.hpp"
|
||||
#include "../Polyfills/math.hpp"
|
||||
#include "../Polyfills/normalize.hpp"
|
||||
#include "../Print.hpp"
|
||||
#include "Encoding.hpp"
|
||||
#include "JsonFloat.hpp"
|
||||
#include "JsonInteger.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// Writes the JSON tokens to a Print implementation
|
||||
// This class is used by:
|
||||
// - JsonArray::writeTo()
|
||||
// - JsonObject::writeTo()
|
||||
// - JsonVariant::writeTo()
|
||||
// Its derived by PrettyJsonWriter that overrides some members to add
|
||||
// indentation.
|
||||
class JsonWriter {
|
||||
public:
|
||||
explicit JsonWriter(Print &sink) : _sink(sink), _length(0) {}
|
||||
|
||||
// Returns the number of bytes sent to the Print implementation.
|
||||
// This is very handy for implementations of printTo() that must return the
|
||||
// number of bytes written.
|
||||
size_t bytesWritten() const {
|
||||
return _length;
|
||||
}
|
||||
|
||||
void beginArray() {
|
||||
writeRaw('[');
|
||||
}
|
||||
void endArray() {
|
||||
writeRaw(']');
|
||||
}
|
||||
|
||||
void beginObject() {
|
||||
writeRaw('{');
|
||||
}
|
||||
void endObject() {
|
||||
writeRaw('}');
|
||||
}
|
||||
|
||||
void writeColon() {
|
||||
writeRaw(':');
|
||||
}
|
||||
void writeComma() {
|
||||
writeRaw(',');
|
||||
}
|
||||
|
||||
void writeBoolean(bool value) {
|
||||
writeRaw(value ? "true" : "false");
|
||||
}
|
||||
|
||||
void writeString(const char *value) {
|
||||
if (!value) {
|
||||
writeRaw("null");
|
||||
} else {
|
||||
writeRaw('\"');
|
||||
while (*value) writeChar(*value++);
|
||||
writeRaw('\"');
|
||||
}
|
||||
}
|
||||
|
||||
void writeChar(char c) {
|
||||
char specialChar = Encoding::escapeChar(c);
|
||||
if (specialChar) {
|
||||
writeRaw('\\');
|
||||
writeRaw(specialChar);
|
||||
} else {
|
||||
writeRaw(c);
|
||||
}
|
||||
}
|
||||
|
||||
void writeFloat(JsonFloat value, uint8_t digits = 2) {
|
||||
if (Polyfills::isNaN(value)) return writeRaw("NaN");
|
||||
|
||||
if (value < 0.0) {
|
||||
writeRaw('-');
|
||||
value = -value;
|
||||
}
|
||||
|
||||
if (Polyfills::isInfinity(value)) return writeRaw("Infinity");
|
||||
|
||||
short powersOf10;
|
||||
if (value > 1000 || value < 0.001) {
|
||||
powersOf10 = Polyfills::normalize(value);
|
||||
} else {
|
||||
powersOf10 = 0;
|
||||
}
|
||||
|
||||
// Round up last digit (so that print(1.999, 2) prints as "2.00")
|
||||
value += getRoundingBias(digits);
|
||||
|
||||
// Extract the integer part of the value and print it
|
||||
JsonUInt int_part = static_cast<JsonUInt>(value);
|
||||
JsonFloat remainder = value - static_cast<JsonFloat>(int_part);
|
||||
writeInteger(int_part);
|
||||
|
||||
// Print the decimal point, but only if there are digits beyond
|
||||
if (digits > 0) {
|
||||
writeRaw('.');
|
||||
}
|
||||
|
||||
// Extract digits from the remainder one at a time
|
||||
while (digits-- > 0) {
|
||||
// Extract digit
|
||||
remainder *= 10.0;
|
||||
char currentDigit = char(remainder);
|
||||
remainder -= static_cast<JsonFloat>(currentDigit);
|
||||
|
||||
// Print
|
||||
writeRaw(char('0' + currentDigit));
|
||||
}
|
||||
|
||||
if (powersOf10 < 0) {
|
||||
writeRaw("e-");
|
||||
writeInteger(-powersOf10);
|
||||
}
|
||||
|
||||
if (powersOf10 > 0) {
|
||||
writeRaw('e');
|
||||
writeInteger(powersOf10);
|
||||
}
|
||||
}
|
||||
|
||||
void writeInteger(JsonUInt value) {
|
||||
char buffer[22];
|
||||
char *ptr = buffer + sizeof(buffer) - 1;
|
||||
|
||||
*ptr = 0;
|
||||
do {
|
||||
*--ptr = static_cast<char>(value % 10 + '0');
|
||||
value /= 10;
|
||||
} while (value);
|
||||
|
||||
writeRaw(ptr);
|
||||
}
|
||||
|
||||
void writeRaw(const char *s) {
|
||||
_length += _sink.print(s);
|
||||
}
|
||||
void writeRaw(char c) {
|
||||
_length += _sink.write(c);
|
||||
}
|
||||
|
||||
protected:
|
||||
Print &_sink;
|
||||
size_t _length;
|
||||
|
||||
private:
|
||||
JsonWriter &operator=(const JsonWriter &); // cannot be assigned
|
||||
|
||||
static JsonFloat getLastDigit(uint8_t digits) {
|
||||
// Designed as a compromise between code size and speed
|
||||
switch (digits) {
|
||||
case 0:
|
||||
return 1e-0;
|
||||
case 1:
|
||||
return 1e-1;
|
||||
case 2:
|
||||
return 1e-2;
|
||||
case 3:
|
||||
return 1e-3;
|
||||
default:
|
||||
return getLastDigit(uint8_t(digits - 4)) * 1e-4;
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE static JsonFloat getRoundingBias(uint8_t digits) {
|
||||
return 0.5 * getLastDigit(digits);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
template <typename TFloat>
|
||||
TFloat parse(const char *);
|
||||
|
||||
template <>
|
||||
inline float parse<float>(const char *s) {
|
||||
return static_cast<float>(strtod(s, NULL));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline double parse<double>(const char *s) {
|
||||
return strtod(s, NULL);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline long parse<long>(const char *s) {
|
||||
return strtol(s, NULL, 10);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline unsigned long parse<unsigned long>(const char *s) {
|
||||
return strtoul(s, NULL, 10);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline int parse<int>(const char *s) {
|
||||
return atoi(s);
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
template <>
|
||||
inline long long parse<long long>(const char *s) {
|
||||
return strtoll(s, NULL, 10);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline unsigned long long parse<unsigned long long>(const char *s) {
|
||||
return strtoull(s, NULL, 10);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_USE_INT64
|
||||
template <>
|
||||
inline __int64 parse<__int64>(const char *s) {
|
||||
return _strtoi64(s, NULL, 10);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline unsigned __int64 parse<unsigned __int64>(const char *s) {
|
||||
return _strtoui64(s, NULL, 10);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// A type that is meant to be used by reference only (JsonArray and JsonObject)
|
||||
class ReferenceType {
|
||||
public:
|
||||
bool operator==(const ReferenceType& other) const {
|
||||
// two JsonArray are equal if they are the same instance
|
||||
// (we don't compare the content)
|
||||
return this == &other;
|
||||
}
|
||||
|
||||
bool operator!=(const ReferenceType& other) const { return this != &other; }
|
||||
|
||||
protected:
|
||||
ReferenceType() {}
|
||||
|
||||
private:
|
||||
// copy constructor is private
|
||||
ReferenceType(const ReferenceType&);
|
||||
|
||||
// copy operator is private
|
||||
ReferenceType& operator=(const ReferenceType&);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Print.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// A Print implementation that allows to write in a char[]
|
||||
class StaticStringBuilder : public Print {
|
||||
public:
|
||||
StaticStringBuilder(char *buf, size_t size)
|
||||
: buffer(buf), capacity(size - 1), length(0) {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
||||
virtual size_t write(uint8_t c) {
|
||||
if (length >= capacity) return 0;
|
||||
|
||||
buffer[length++] = c;
|
||||
buffer[length] = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
private:
|
||||
char *buffer;
|
||||
size_t capacity;
|
||||
size_t length;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,268 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Internals/JsonBufferAllocated.hpp"
|
||||
#include "Internals/JsonPrintable.hpp"
|
||||
#include "Internals/List.hpp"
|
||||
#include "Internals/ReferenceType.hpp"
|
||||
#include "JsonVariant.hpp"
|
||||
#include "TypeTraits/EnableIf.hpp"
|
||||
#include "TypeTraits/IsFloatingPoint.hpp"
|
||||
#include "TypeTraits/IsReference.hpp"
|
||||
#include "TypeTraits/IsSame.hpp"
|
||||
|
||||
// Returns the size (in bytes) of an array with n elements.
|
||||
// Can be very handy to determine the size of a StaticJsonBuffer.
|
||||
#define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \
|
||||
(sizeof(JsonArray) + (NUMBER_OF_ELEMENTS) * sizeof(JsonArray::node_type))
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// Forward declarations
|
||||
class JsonObject;
|
||||
class JsonBuffer;
|
||||
class JsonArraySubscript;
|
||||
|
||||
// An array of JsonVariant.
|
||||
//
|
||||
// The constructor is private, instances must be created via
|
||||
// JsonBuffer::createArray() or JsonBuffer::parseArray().
|
||||
// A JsonArray can be serialized to a JSON string via JsonArray::printTo().
|
||||
// It can also be deserialized from a JSON string via JsonBuffer::parseArray().
|
||||
class JsonArray : public Internals::JsonPrintable<JsonArray>,
|
||||
public Internals::ReferenceType,
|
||||
public Internals::List<JsonVariant>,
|
||||
public Internals::JsonBufferAllocated {
|
||||
public:
|
||||
// A meta-function that returns true if type T can be used in
|
||||
// JsonArray::set()
|
||||
template <typename T>
|
||||
struct CanSet {
|
||||
static const bool value = JsonVariant::IsConstructibleFrom<T>::value ||
|
||||
TypeTraits::IsSame<T, String &>::value ||
|
||||
TypeTraits::IsSame<T, const String &>::value;
|
||||
};
|
||||
|
||||
// Create an empty JsonArray attached to the specified JsonBuffer.
|
||||
// You should not call this constructor directly.
|
||||
// Instead, use JsonBuffer::createArray() or JsonBuffer::parseArray().
|
||||
explicit JsonArray(JsonBuffer *buffer)
|
||||
: Internals::List<JsonVariant>(buffer) {}
|
||||
|
||||
// Gets the value at the specified index
|
||||
JsonVariant operator[](size_t index) const {
|
||||
return get(index);
|
||||
}
|
||||
|
||||
// Gets or sets the value at specified index
|
||||
JsonArraySubscript operator[](size_t index);
|
||||
|
||||
// Adds the specified value at the end of the array.
|
||||
//
|
||||
// bool add(bool);
|
||||
// bool add(char);
|
||||
// bool add(long);
|
||||
// bool add(int);
|
||||
// bool add(short);
|
||||
// bool add(float value);
|
||||
// bool add(double value);
|
||||
// bool add(const char*);
|
||||
template <typename T>
|
||||
bool add(
|
||||
T value,
|
||||
typename TypeTraits::EnableIf<
|
||||
CanSet<T>::value && !TypeTraits::IsReference<T>::value>::type * = 0) {
|
||||
return addNode<T>(value);
|
||||
}
|
||||
// bool add(const String&)
|
||||
// bool add(const JsonVariant&);
|
||||
// bool add(JsonArray&);
|
||||
// bool add(JsonObject&);
|
||||
template <typename T>
|
||||
bool add(const T &value,
|
||||
typename TypeTraits::EnableIf<CanSet<T &>::value>::type * = 0) {
|
||||
return addNode<T &>(const_cast<T &>(value));
|
||||
}
|
||||
// bool add(float value, uint8_t decimals);
|
||||
// bool add(double value, uint8_t decimals);
|
||||
template <typename T>
|
||||
bool add(T value, uint8_t decimals,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
return addNode<JsonVariant>(JsonVariant(value, decimals));
|
||||
}
|
||||
|
||||
// Sets the value at specified index.
|
||||
//
|
||||
// bool set(size_t index, bool value);
|
||||
// bool set(size_t index, long value);
|
||||
// bool set(size_t index, int value);
|
||||
// bool set(size_t index, short value);
|
||||
template <typename T>
|
||||
bool set(
|
||||
size_t index, T value,
|
||||
typename TypeTraits::EnableIf<
|
||||
CanSet<T>::value && !TypeTraits::IsReference<T>::value>::type * = 0) {
|
||||
return setNodeAt<T>(index, value);
|
||||
}
|
||||
// bool set(size_t index, const String&)
|
||||
// bool set(size_t index, const JsonVariant&);
|
||||
// bool set(size_t index, JsonArray&);
|
||||
// bool set(size_t index, JsonObject&);
|
||||
template <typename T>
|
||||
bool set(size_t index, const T &value,
|
||||
typename TypeTraits::EnableIf<CanSet<T &>::value>::type * = 0) {
|
||||
return setNodeAt<T &>(index, const_cast<T &>(value));
|
||||
}
|
||||
// bool set(size_t index, float value, uint8_t decimals = 2);
|
||||
// bool set(size_t index, double value, uint8_t decimals = 2);
|
||||
template <typename T>
|
||||
bool set(size_t index, T value, uint8_t decimals,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
return setNodeAt<const JsonVariant &>(index, JsonVariant(value, decimals));
|
||||
}
|
||||
|
||||
// Gets the value at the specified index.
|
||||
JsonVariant get(size_t index) const {
|
||||
node_type *node = getNodeAt(index);
|
||||
return node ? node->content : JsonVariant();
|
||||
}
|
||||
|
||||
// Gets the value at the specified index.
|
||||
template <typename T>
|
||||
typename Internals::JsonVariantAs<T>::type get(size_t index) const {
|
||||
node_type *node = getNodeAt(index);
|
||||
return node ? node->content.as<T>() : JsonVariant::defaultValue<T>();
|
||||
}
|
||||
|
||||
// Check the type of the value at specified index.
|
||||
template <typename T>
|
||||
bool is(size_t index) const {
|
||||
node_type *node = getNodeAt(index);
|
||||
return node ? node->content.is<T>() : false;
|
||||
}
|
||||
|
||||
// Creates a JsonArray and adds a reference at the end of the array.
|
||||
// It's a shortcut for JsonBuffer::createArray() and JsonArray::add()
|
||||
JsonArray &createNestedArray();
|
||||
|
||||
// Creates a JsonObject and adds a reference at the end of the array.
|
||||
// It's a shortcut for JsonBuffer::createObject() and JsonArray::add()
|
||||
JsonObject &createNestedObject();
|
||||
|
||||
// Removes element at specified index.
|
||||
void removeAt(size_t index) {
|
||||
removeNode(getNodeAt(index));
|
||||
}
|
||||
|
||||
// Returns a reference an invalid JsonArray.
|
||||
// This object is meant to replace a NULL pointer.
|
||||
// This is used when memory allocation or JSON parsing fail.
|
||||
static JsonArray &invalid() {
|
||||
static JsonArray instance(NULL);
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Serialize the array to the specified JsonWriter.
|
||||
void writeTo(Internals::JsonWriter &writer) const {
|
||||
writer.beginArray();
|
||||
|
||||
const node_type *child = _firstNode;
|
||||
while (child) {
|
||||
child->content.writeTo(writer);
|
||||
|
||||
child = child->next;
|
||||
if (!child) break;
|
||||
|
||||
writer.writeComma();
|
||||
}
|
||||
|
||||
writer.endArray();
|
||||
}
|
||||
|
||||
// Imports a 1D array
|
||||
template <typename T, size_t N>
|
||||
bool copyFrom(T(&array)[N]) {
|
||||
return copyFrom(array, N);
|
||||
}
|
||||
|
||||
// Imports a 1D array
|
||||
template <typename T>
|
||||
bool copyFrom(T *array, size_t len) {
|
||||
bool ok = true;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
ok &= add(array[i]);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Imports a 2D array
|
||||
template <typename T, size_t N1, size_t N2>
|
||||
bool copyFrom(T(&array)[N1][N2]) {
|
||||
bool ok = true;
|
||||
for (size_t i = 0; i < N1; i++) {
|
||||
JsonArray &nestedArray = createNestedArray();
|
||||
for (size_t j = 0; j < N2; j++) {
|
||||
ok &= nestedArray.add(array[i][j]);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Exports a 1D array
|
||||
template <typename T, size_t N>
|
||||
size_t copyTo(T(&array)[N]) const {
|
||||
return copyTo(array, N);
|
||||
}
|
||||
|
||||
// Exports a 1D array
|
||||
template <typename T>
|
||||
size_t copyTo(T *array, size_t len) const {
|
||||
size_t i = 0;
|
||||
for (const_iterator it = begin(); it != end() && i < len; ++it)
|
||||
array[i++] = *it;
|
||||
return i;
|
||||
}
|
||||
|
||||
// Exports a 2D array
|
||||
template <typename T, size_t N1, size_t N2>
|
||||
void copyTo(T(&array)[N1][N2]) const {
|
||||
size_t i = 0;
|
||||
for (const_iterator it = begin(); it != end() && i < N1; ++it) {
|
||||
it->asArray().copyTo(array[i++]);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
node_type *getNodeAt(size_t index) const {
|
||||
node_type *node = _firstNode;
|
||||
while (node && index--) node = node->next;
|
||||
return node;
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
bool setNodeAt(size_t index, TValue value) {
|
||||
node_type *node = getNodeAt(index);
|
||||
return node != NULL && setNodeValue<TValue>(node, value);
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
bool addNode(TValue value) {
|
||||
node_type *node = addNewNode();
|
||||
return node != NULL && setNodeValue<TValue>(node, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool setNodeValue(node_type *node, T value) {
|
||||
node->content = value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonArray.hpp"
|
||||
#include "JsonObject.hpp"
|
||||
#include "JsonArraySubscript.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
template <>
|
||||
inline bool JsonArray::setNodeValue(node_type *node, String &value) {
|
||||
const char *copy = _buffer->strdup(value);
|
||||
if (!copy) return false;
|
||||
node->content = copy;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline JsonArray &JsonVariant::defaultValue<JsonArray>() {
|
||||
return JsonArray::invalid();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline JsonArray &JsonVariant::defaultValue<JsonArray &>() {
|
||||
return JsonArray::invalid();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const JsonArray &JsonVariant::defaultValue<const JsonArray>() {
|
||||
return JsonArray::invalid();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const JsonArray &JsonVariant::defaultValue<const JsonArray &>() {
|
||||
return JsonArray::invalid();
|
||||
}
|
||||
|
||||
inline JsonArray &JsonVariant::asArray() const {
|
||||
if (_type == Internals::JSON_ARRAY) return *_content.asArray;
|
||||
return JsonArray::invalid();
|
||||
}
|
||||
|
||||
inline JsonArray &JsonArray::createNestedArray() {
|
||||
if (!_buffer) return JsonArray::invalid();
|
||||
JsonArray &array = _buffer->createArray();
|
||||
add(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
inline JsonArray &JsonObject::createNestedArray(JsonObjectKey key) {
|
||||
if (!_buffer) return JsonArray::invalid();
|
||||
JsonArray &array = _buffer->createArray();
|
||||
setNodeAt<const JsonVariant &>(key, array);
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Configuration.hpp"
|
||||
#include "JsonVariantBase.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4522)
|
||||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript> {
|
||||
public:
|
||||
FORCE_INLINE JsonArraySubscript(JsonArray& array, size_t index)
|
||||
: _array(array), _index(index) {}
|
||||
|
||||
JsonArraySubscript& operator=(const JsonArraySubscript& src) {
|
||||
_array.set<const JsonVariant&>(_index, src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<JsonArray::CanSet<T&>::value,
|
||||
JsonArraySubscript>::type&
|
||||
operator=(const T& src) {
|
||||
_array.set<T&>(_index, const_cast<T&>(src));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<JsonArray::CanSet<T>::value,
|
||||
JsonArraySubscript>::type&
|
||||
operator=(T src) {
|
||||
_array.set<T>(_index, src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
FORCE_INLINE bool success() const {
|
||||
return _index < _array.size();
|
||||
}
|
||||
|
||||
FORCE_INLINE operator JsonVariant() const {
|
||||
return _array.get(_index);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
FORCE_INLINE typename Internals::JsonVariantAs<T>::type as() const {
|
||||
return _array.get<T>(_index);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
FORCE_INLINE bool is() const {
|
||||
return _array.is<T>(_index);
|
||||
}
|
||||
|
||||
void writeTo(Internals::JsonWriter& writer) const {
|
||||
_array.get(_index).writeTo(writer);
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
void set(TValue value) {
|
||||
_array.set(_index, value);
|
||||
}
|
||||
|
||||
private:
|
||||
JsonArray& _array;
|
||||
const size_t _index;
|
||||
};
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
inline std::ostream& operator<<(std::ostream& os,
|
||||
const JsonArraySubscript& source) {
|
||||
return source.printTo(os);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline JsonArraySubscript JsonArray::operator[](size_t index) {
|
||||
return JsonArraySubscript(*this, index);
|
||||
}
|
||||
|
||||
template <typename TImplem>
|
||||
inline const JsonArraySubscript JsonVariantBase<TImplem>::operator[](
|
||||
int index) const {
|
||||
return asArray()[index];
|
||||
}
|
||||
|
||||
} // namespace ArduinoJson
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
@@ -1,163 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stdint.h> // for uint8_t
|
||||
#include <string.h>
|
||||
|
||||
#include "JsonVariant.hpp"
|
||||
#include "String.hpp"
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic push
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
class JsonArray;
|
||||
class JsonObject;
|
||||
|
||||
// Entry point for using the library.
|
||||
//
|
||||
// Handle the memory management (done in derived classes) and calls the parser.
|
||||
// This abstract class is implemented by StaticJsonBuffer which implements a
|
||||
// fixed memory allocation.
|
||||
class JsonBuffer {
|
||||
public:
|
||||
// CAUTION: NO VIRTUAL DESTRUCTOR!
|
||||
// If we add a virtual constructor the Arduino compiler will add malloc() and
|
||||
// free() to the binary, adding 706 useless bytes.
|
||||
// virtual ~JsonBuffer() {}
|
||||
|
||||
// Allocates an empty JsonArray.
|
||||
//
|
||||
// Returns a reference to the new JsonArray or JsonArray::invalid() if the
|
||||
// allocation fails.
|
||||
JsonArray &createArray();
|
||||
|
||||
// Allocates an empty JsonObject.
|
||||
//
|
||||
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
|
||||
// allocation fails.
|
||||
JsonObject &createObject();
|
||||
|
||||
// Allocates and populate a JsonArray from a JSON string.
|
||||
//
|
||||
// The First argument is a pointer to the JSON string, the memory must be
|
||||
// writable
|
||||
// because the parser will insert null-terminators and replace escaped chars.
|
||||
//
|
||||
// The second argument set the nesting limit (see comment on DEFAULT_LIMIT)
|
||||
//
|
||||
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
|
||||
// allocation fails.
|
||||
JsonArray &parseArray(char *json, uint8_t nestingLimit = DEFAULT_LIMIT);
|
||||
|
||||
// Same with a const char*.
|
||||
// With this overload, the JsonBuffer will make a copy of the string
|
||||
JsonArray &parseArray(const char *json, uint8_t nesting = DEFAULT_LIMIT) {
|
||||
return parseArray(strdup(json), nesting);
|
||||
}
|
||||
|
||||
// Same as above with a String class
|
||||
JsonArray &parseArray(const String &json, uint8_t nesting = DEFAULT_LIMIT) {
|
||||
return parseArray(json.c_str(), nesting);
|
||||
}
|
||||
|
||||
// Allocates and populate a JsonObject from a JSON string.
|
||||
//
|
||||
// The First argument is a pointer to the JSON string, the memory must be
|
||||
// writable
|
||||
// because the parser will insert null-terminators and replace escaped chars.
|
||||
//
|
||||
// The second argument set the nesting limit (see comment on DEFAULT_LIMIT)
|
||||
//
|
||||
// Returns a reference to the new JsonObject or JsonObject::invalid() if the
|
||||
// allocation fails.
|
||||
JsonObject &parseObject(char *json, uint8_t nestingLimit = DEFAULT_LIMIT);
|
||||
|
||||
// Same with a const char*.
|
||||
// With this overload, the JsonBuffer will make a copy of the string
|
||||
JsonObject &parseObject(const char *json, uint8_t nesting = DEFAULT_LIMIT) {
|
||||
return parseObject(strdup(json), nesting);
|
||||
}
|
||||
|
||||
// Same as above with a String class
|
||||
JsonObject &parseObject(const String &json, uint8_t nesting = DEFAULT_LIMIT) {
|
||||
return parseObject(json.c_str(), nesting);
|
||||
}
|
||||
|
||||
// Generalized version of parseArray() and parseObject(), also works for
|
||||
// integral types.
|
||||
JsonVariant parse(char *json, uint8_t nestingLimit = DEFAULT_LIMIT);
|
||||
|
||||
// Same with a const char*.
|
||||
// With this overload, the JsonBuffer will make a copy of the string
|
||||
JsonVariant parse(const char *json, uint8_t nesting = DEFAULT_LIMIT) {
|
||||
return parse(strdup(json), nesting);
|
||||
}
|
||||
|
||||
// Same as above with a String class
|
||||
JsonVariant parse(const String &json, uint8_t nesting = DEFAULT_LIMIT) {
|
||||
return parse(json.c_str(), nesting);
|
||||
}
|
||||
|
||||
// Duplicate a string
|
||||
char *strdup(const char *src) {
|
||||
return src ? strdup(src, strlen(src)) : NULL;
|
||||
}
|
||||
char *strdup(const String &src) { return strdup(src.c_str(), src.length()); }
|
||||
|
||||
// Allocates n bytes in the JsonBuffer.
|
||||
// Return a pointer to the allocated memory or NULL if allocation fails.
|
||||
virtual void *alloc(size_t size) = 0;
|
||||
|
||||
protected:
|
||||
// Preserve aligment if nessary
|
||||
static FORCE_INLINE size_t round_size_up(size_t bytes) {
|
||||
#if ARDUINOJSON_ENABLE_ALIGNMENT
|
||||
const size_t x = sizeof(void *) - 1;
|
||||
return (bytes + x) & ~x;
|
||||
#else
|
||||
return bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
char *strdup(const char *, size_t);
|
||||
|
||||
// Default value of nesting limit of parseArray() and parseObject().
|
||||
//
|
||||
// The nesting limit is a contain on the level of nesting allowed in the
|
||||
// JSON
|
||||
// string.
|
||||
// If set to 0, only a flat array or objects can be parsed.
|
||||
// If set to 1, the object can contain nested arrays or objects but only 1
|
||||
// level deep.
|
||||
// And bigger values will allow more level of nesting.
|
||||
//
|
||||
// The purpose of this feature is to prevent stack overflow that could
|
||||
// lead to
|
||||
// a security risk.
|
||||
static const uint8_t DEFAULT_LIMIT = 10;
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Internals/JsonParser.hpp"
|
||||
|
||||
inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::createArray() {
|
||||
JsonArray *ptr = new (this) JsonArray(this);
|
||||
return ptr ? *ptr : JsonArray::invalid();
|
||||
}
|
||||
|
||||
inline ArduinoJson::JsonObject &ArduinoJson::JsonBuffer::createObject() {
|
||||
JsonObject *ptr = new (this) JsonObject(this);
|
||||
return ptr ? *ptr : JsonObject::invalid();
|
||||
}
|
||||
|
||||
inline ArduinoJson::JsonArray &ArduinoJson::JsonBuffer::parseArray(
|
||||
char *json, uint8_t nestingLimit) {
|
||||
Internals::JsonParser parser(this, json, nestingLimit);
|
||||
return parser.parseArray();
|
||||
}
|
||||
|
||||
inline ArduinoJson::JsonObject &ArduinoJson::JsonBuffer::parseObject(
|
||||
char *json, uint8_t nestingLimit) {
|
||||
Internals::JsonParser parser(this, json, nestingLimit);
|
||||
return parser.parseObject();
|
||||
}
|
||||
|
||||
inline ArduinoJson::JsonVariant ArduinoJson::JsonBuffer::parse(
|
||||
char *json, uint8_t nestingLimit) {
|
||||
Internals::JsonParser parser(this, json, nestingLimit);
|
||||
return parser.parseVariant();
|
||||
}
|
||||
|
||||
inline char *ArduinoJson::JsonBuffer::strdup(const char *source,
|
||||
size_t length) {
|
||||
size_t size = length + 1;
|
||||
char *dest = static_cast<char *>(alloc(size));
|
||||
if (dest != NULL) memcpy(dest, source, size);
|
||||
return dest;
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "String.hpp"
|
||||
#include "Internals/JsonBufferAllocated.hpp"
|
||||
#include "Internals/JsonPrintable.hpp"
|
||||
#include "Internals/List.hpp"
|
||||
#include "Internals/ReferenceType.hpp"
|
||||
#include "JsonPair.hpp"
|
||||
#include "TypeTraits/EnableIf.hpp"
|
||||
#include "TypeTraits/IsFloatingPoint.hpp"
|
||||
#include "TypeTraits/IsReference.hpp"
|
||||
#include "TypeTraits/IsSame.hpp"
|
||||
|
||||
// Returns the size (in bytes) of an object with n elements.
|
||||
// Can be very handy to determine the size of a StaticJsonBuffer.
|
||||
#define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \
|
||||
(sizeof(JsonObject) + (NUMBER_OF_ELEMENTS) * sizeof(JsonObject::node_type))
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// Forward declarations
|
||||
class JsonArray;
|
||||
class JsonBuffer;
|
||||
|
||||
// A dictionary of JsonVariant indexed by string (char*)
|
||||
//
|
||||
// The constructor is private, instances must be created via
|
||||
// JsonBuffer::createObject() or JsonBuffer::parseObject().
|
||||
// A JsonObject can be serialized to a JSON string via JsonObject::printTo().
|
||||
// It can also be deserialized from a JSON string via JsonBuffer::parseObject().
|
||||
class JsonObject : public Internals::JsonPrintable<JsonObject>,
|
||||
public Internals::ReferenceType,
|
||||
public Internals::List<JsonPair>,
|
||||
public Internals::JsonBufferAllocated {
|
||||
public:
|
||||
// A meta-function that returns true if type T can be used in
|
||||
// JsonObject::set()
|
||||
template <typename T>
|
||||
struct CanSet {
|
||||
static const bool value = JsonVariant::IsConstructibleFrom<T>::value ||
|
||||
TypeTraits::IsSame<T, String&>::value ||
|
||||
TypeTraits::IsSame<T, const String&>::value;
|
||||
};
|
||||
|
||||
// Create an empty JsonArray attached to the specified JsonBuffer.
|
||||
// You should not use this constructor directly.
|
||||
// Instead, use JsonBuffer::createObject() or JsonBuffer.parseObject().
|
||||
explicit JsonObject(JsonBuffer* buffer) : Internals::List<JsonPair>(buffer) {}
|
||||
|
||||
// Gets or sets the value associated with the specified key.
|
||||
JsonObjectSubscript<const char*> operator[](const char* key);
|
||||
JsonObjectSubscript<const String&> operator[](const String& key);
|
||||
|
||||
// Gets the value associated with the specified key.
|
||||
JsonVariant operator[](JsonObjectKey key) const {
|
||||
return get(key);
|
||||
}
|
||||
|
||||
// Sets the specified key with the specified value.
|
||||
// bool set(TKey key, bool value);
|
||||
// bool set(TKey key, char value);
|
||||
// bool set(TKey key, long value);
|
||||
// bool set(TKey key, int value);
|
||||
// bool set(TKey key, short value);
|
||||
// bool set(TKey key, float value);
|
||||
// bool set(TKey key, double value);
|
||||
// bool set(TKey key, const char* value);
|
||||
// bool set(TKey key, RawJson value);
|
||||
template <typename T>
|
||||
bool set(
|
||||
JsonObjectKey key, T value,
|
||||
typename TypeTraits::EnableIf<
|
||||
CanSet<T>::value && !TypeTraits::IsReference<T>::value>::type* = 0) {
|
||||
return setNodeAt<T>(key, value);
|
||||
}
|
||||
// bool set(Key, String&);
|
||||
// bool set(Key, JsonArray&);
|
||||
// bool set(Key, JsonObject&);
|
||||
// bool set(Key, JsonVariant&);
|
||||
template <typename T>
|
||||
bool set(JsonObjectKey key, const T& value,
|
||||
typename TypeTraits::EnableIf<CanSet<T&>::value>::type* = 0) {
|
||||
return setNodeAt<T&>(key, const_cast<T&>(value));
|
||||
}
|
||||
// bool set(Key, float value, uint8_t decimals);
|
||||
// bool set(Key, double value, uint8_t decimals);
|
||||
template <typename TValue>
|
||||
bool set(JsonObjectKey key, TValue value, uint8_t decimals,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsFloatingPoint<TValue>::value>::type* = 0) {
|
||||
return setNodeAt<const JsonVariant&>(key, JsonVariant(value, decimals));
|
||||
}
|
||||
|
||||
// Gets the value associated with the specified key.
|
||||
JsonVariant get(JsonObjectKey key) const {
|
||||
node_type* node = getNodeAt(key.c_str());
|
||||
return node ? node->content.value : JsonVariant();
|
||||
}
|
||||
|
||||
// Gets the value associated with the specified key.
|
||||
template <typename T>
|
||||
typename Internals::JsonVariantAs<T>::type get(JsonObjectKey key) const {
|
||||
node_type* node = getNodeAt(key.c_str());
|
||||
return node ? node->content.value.as<T>() : JsonVariant::defaultValue<T>();
|
||||
}
|
||||
|
||||
// Checks the type of the value associated with the specified key.
|
||||
template <typename T>
|
||||
bool is(JsonObjectKey key) const {
|
||||
node_type* node = getNodeAt(key.c_str());
|
||||
return node ? node->content.value.is<T>() : false;
|
||||
}
|
||||
|
||||
// Creates and adds a JsonArray.
|
||||
// This is a shortcut for JsonBuffer::createArray() and JsonObject::add().
|
||||
JsonArray& createNestedArray(JsonObjectKey key);
|
||||
|
||||
// Creates and adds a JsonObject.
|
||||
// This is a shortcut for JsonBuffer::createObject() and JsonObject::add().
|
||||
JsonObject& createNestedObject(JsonObjectKey key);
|
||||
|
||||
// Tells weither the specified key is present and associated with a value.
|
||||
bool containsKey(JsonObjectKey key) const {
|
||||
return getNodeAt(key.c_str()) != NULL;
|
||||
}
|
||||
|
||||
// Removes the specified key and the associated value.
|
||||
void remove(JsonObjectKey key) {
|
||||
removeNode(getNodeAt(key.c_str()));
|
||||
}
|
||||
|
||||
// Returns a reference an invalid JsonObject.
|
||||
// This object is meant to replace a NULL pointer.
|
||||
// This is used when memory allocation or JSON parsing fail.
|
||||
static JsonObject& invalid() {
|
||||
static JsonObject instance(NULL);
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Serialize the object to the specified JsonWriter
|
||||
void writeTo(Internals::JsonWriter& writer) const {
|
||||
writer.beginObject();
|
||||
|
||||
const node_type* node = _firstNode;
|
||||
while (node) {
|
||||
writer.writeString(node->content.key);
|
||||
writer.writeColon();
|
||||
node->content.value.writeTo(writer);
|
||||
|
||||
node = node->next;
|
||||
if (!node) break;
|
||||
|
||||
writer.writeComma();
|
||||
}
|
||||
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
private:
|
||||
// Returns the list node that matches the specified key.
|
||||
node_type* getNodeAt(const char* key) const {
|
||||
for (node_type* node = _firstNode; node; node = node->next) {
|
||||
if (!strcmp(node->content.key, key)) return node;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool setNodeAt(JsonObjectKey key, T value) {
|
||||
node_type* node = getNodeAt(key.c_str());
|
||||
if (!node) {
|
||||
node = addNewNode();
|
||||
if (!node || !setNodeKey(node, key)) return false;
|
||||
}
|
||||
return setNodeValue<T>(node, value);
|
||||
}
|
||||
|
||||
bool setNodeKey(node_type* node, JsonObjectKey key) {
|
||||
if (key.needs_copy()) {
|
||||
node->content.key = _buffer->strdup(key.c_str());
|
||||
if (node->content.key == NULL) return false;
|
||||
} else {
|
||||
node->content.key = key.c_str();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool setNodeValue(node_type* node, T value) {
|
||||
node->content.value = value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonArray.hpp"
|
||||
#include "JsonObject.hpp"
|
||||
#include "JsonObjectSubscript.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
template <>
|
||||
inline bool JsonObject::setNodeValue(node_type *node, String &value) {
|
||||
node->content.value = _buffer->strdup(value);
|
||||
return node->content.value;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool JsonObject::setNodeValue(node_type *node, const String &value) {
|
||||
node->content.value = _buffer->strdup(value);
|
||||
return node->content.value;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const JsonObject &JsonVariant::defaultValue<const JsonObject &>() {
|
||||
return JsonObject::invalid();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const JsonObject &JsonVariant::defaultValue<const JsonObject>() {
|
||||
return JsonObject::invalid();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline JsonObject &JsonVariant::defaultValue<JsonObject &>() {
|
||||
return JsonObject::invalid();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline JsonObject &JsonVariant::defaultValue<JsonObject>() {
|
||||
return JsonObject::invalid();
|
||||
}
|
||||
|
||||
inline JsonObject &JsonVariant::asObject() const {
|
||||
if (_type == Internals::JSON_OBJECT) return *_content.asObject;
|
||||
return JsonObject::invalid();
|
||||
}
|
||||
|
||||
inline JsonObject &JsonObject::createNestedObject(JsonObjectKey key) {
|
||||
if (!_buffer) return JsonObject::invalid();
|
||||
JsonObject &array = _buffer->createObject();
|
||||
setNodeAt<const JsonVariant &>(key, array);
|
||||
return array;
|
||||
}
|
||||
|
||||
inline JsonObject &JsonArray::createNestedObject() {
|
||||
if (!_buffer) return JsonObject::invalid();
|
||||
JsonObject &object = _buffer->createObject();
|
||||
add(object);
|
||||
return object;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "String.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// Represents a key in a JsonObject
|
||||
class JsonObjectKey {
|
||||
public:
|
||||
JsonObjectKey(const char* key) : _value(key), _needs_copy(false) {}
|
||||
JsonObjectKey(const String& key) : _value(key.c_str()), _needs_copy(true) {}
|
||||
|
||||
const char* c_str() const { return _value; }
|
||||
bool needs_copy() const { return _needs_copy; }
|
||||
|
||||
private:
|
||||
const char* _value;
|
||||
bool _needs_copy;
|
||||
};
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Configuration.hpp"
|
||||
#include "JsonVariantBase.hpp"
|
||||
#include "TypeTraits/EnableIf.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4522)
|
||||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
template <typename TKey>
|
||||
class JsonObjectSubscript : public JsonVariantBase<JsonObjectSubscript<TKey> > {
|
||||
public:
|
||||
FORCE_INLINE JsonObjectSubscript(JsonObject& object, TKey key)
|
||||
: _object(object), _key(key) {}
|
||||
|
||||
JsonObjectSubscript<TKey>& operator=(const JsonObjectSubscript<TKey>& src) {
|
||||
_object.set<const JsonVariant&>(_key, src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<JsonObject::CanSet<T&>::value,
|
||||
JsonObjectSubscript<TKey> >::type&
|
||||
operator=(const T& src) {
|
||||
_object.set<T&>(_key, const_cast<T&>(src));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<JsonObject::CanSet<T>::value,
|
||||
JsonObjectSubscript<TKey> >::type&
|
||||
operator=(T src) {
|
||||
_object.set<T>(_key, src);
|
||||
return *this;
|
||||
}
|
||||
|
||||
FORCE_INLINE bool success() const {
|
||||
return _object.containsKey(_key);
|
||||
}
|
||||
|
||||
FORCE_INLINE operator JsonVariant() const {
|
||||
return _object.get(_key);
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
FORCE_INLINE typename Internals::JsonVariantAs<TValue>::type as() const {
|
||||
return _object.get<TValue>(_key);
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
FORCE_INLINE bool is() const {
|
||||
return _object.is<TValue>(_key);
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
FORCE_INLINE bool set(TValue value) {
|
||||
return _object.set<TValue>(_key, value);
|
||||
}
|
||||
|
||||
template <typename TValue>
|
||||
FORCE_INLINE bool set(TValue value, uint8_t decimals) {
|
||||
return _object.set(_key, value, decimals);
|
||||
}
|
||||
|
||||
FORCE_INLINE JsonVariant get() {
|
||||
return _object.get(_key);
|
||||
}
|
||||
|
||||
void writeTo(Internals::JsonWriter& writer) const {
|
||||
_object.get(_key).writeTo(writer);
|
||||
}
|
||||
|
||||
private:
|
||||
JsonObject& _object;
|
||||
TKey _key;
|
||||
};
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& os, const JsonObjectSubscript<const String&>& source) {
|
||||
return source.printTo(os);
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& os, const JsonObjectSubscript<const char*>& source) {
|
||||
return source.printTo(os);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline JsonObjectSubscript<const char*> JsonObject::operator[](
|
||||
const char* key) {
|
||||
return JsonObjectSubscript<const char*>(*this, key);
|
||||
}
|
||||
|
||||
inline JsonObjectSubscript<const String&> JsonObject::operator[](
|
||||
const String& key) {
|
||||
return JsonObjectSubscript<const String&>(*this, key);
|
||||
}
|
||||
|
||||
template <typename TImplem>
|
||||
inline const JsonObjectSubscript<const char*> JsonVariantBase<TImplem>::
|
||||
operator[](const char* key) const {
|
||||
return asObject()[key];
|
||||
}
|
||||
|
||||
template <typename TImplem>
|
||||
inline const JsonObjectSubscript<const String&> JsonVariantBase<TImplem>::
|
||||
operator[](const String& key) const {
|
||||
return asObject()[key];
|
||||
}
|
||||
|
||||
} // namespace ArduinoJson
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonObjectKey.hpp"
|
||||
#include "JsonVariant.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// A key value pair for JsonObject.
|
||||
struct JsonPair {
|
||||
const char* key;
|
||||
JsonVariant value;
|
||||
};
|
||||
}
|
||||
@@ -1,367 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h> // for uint8_t
|
||||
|
||||
#include "Internals/JsonPrintable.hpp"
|
||||
#include "Internals/JsonVariantContent.hpp"
|
||||
#include "Internals/JsonVariantType.hpp"
|
||||
#include "JsonVariantBase.hpp"
|
||||
#include "RawJson.hpp"
|
||||
#include "TypeTraits/EnableIf.hpp"
|
||||
#include "TypeTraits/IsFloatingPoint.hpp"
|
||||
#include "TypeTraits/IsIntegral.hpp"
|
||||
#include "TypeTraits/IsSame.hpp"
|
||||
#include "TypeTraits/RemoveConst.hpp"
|
||||
#include "TypeTraits/RemoveReference.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// Forward declarations.
|
||||
class JsonArray;
|
||||
class JsonObject;
|
||||
|
||||
// A variant that can be a any value serializable to a JSON value.
|
||||
//
|
||||
// It can be set to:
|
||||
// - a boolean
|
||||
// - a char, short, int or a long (signed or unsigned)
|
||||
// - a string (const char*)
|
||||
// - a reference to a JsonArray or JsonObject
|
||||
class JsonVariant : public JsonVariantBase<JsonVariant> {
|
||||
public:
|
||||
template <typename T>
|
||||
struct IsConstructibleFrom;
|
||||
|
||||
// Creates an uninitialized JsonVariant
|
||||
JsonVariant() : _type(Internals::JSON_UNDEFINED) {}
|
||||
|
||||
// Create a JsonVariant containing a boolean value.
|
||||
// It will be serialized as "true" or "false" in JSON.
|
||||
JsonVariant(bool value) {
|
||||
using namespace Internals;
|
||||
_type = JSON_BOOLEAN;
|
||||
_content.asInteger = static_cast<JsonInteger>(value);
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing a floating point value.
|
||||
// The second argument specifies the number of decimal digits to write in
|
||||
// the JSON string.
|
||||
// JsonVariant(double value, uint8_t decimals);
|
||||
// JsonVariant(float value, uint8_t decimals);
|
||||
template <typename T>
|
||||
JsonVariant(T value, uint8_t decimals = 2,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsFloatingPoint<T>::value>::type * = 0) {
|
||||
using namespace Internals;
|
||||
_type = static_cast<JsonVariantType>(JSON_FLOAT_0_DECIMALS + decimals);
|
||||
_content.asFloat = static_cast<JsonFloat>(value);
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing an integer value.
|
||||
// JsonVariant(signed short)
|
||||
// JsonVariant(signed int)
|
||||
// JsonVariant(signed long)
|
||||
template <typename T>
|
||||
JsonVariant(T value,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSignedIntegral<T>::value>::type * = 0) {
|
||||
using namespace Internals;
|
||||
if (value >= 0) {
|
||||
_type = JSON_POSITIVE_INTEGER;
|
||||
_content.asInteger = static_cast<JsonUInt>(value);
|
||||
} else {
|
||||
_type = JSON_NEGATIVE_INTEGER;
|
||||
_content.asInteger = static_cast<JsonUInt>(-value);
|
||||
}
|
||||
}
|
||||
// JsonVariant(unsigned short)
|
||||
// JsonVariant(unsigned int)
|
||||
// JsonVariant(unsigned long)
|
||||
template <typename T>
|
||||
JsonVariant(T value,
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsUnsignedIntegral<T>::value>::type * = 0) {
|
||||
using namespace Internals;
|
||||
_type = JSON_POSITIVE_INTEGER;
|
||||
_content.asInteger = static_cast<JsonUInt>(value);
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing a string.
|
||||
JsonVariant(const char *value) {
|
||||
_type = Internals::JSON_STRING;
|
||||
_content.asString = value;
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing an unparsed string
|
||||
JsonVariant(RawJson value) {
|
||||
_type = Internals::JSON_UNPARSED;
|
||||
_content.asString = value;
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing a reference to an array.
|
||||
JsonVariant(JsonArray &array) {
|
||||
_type = Internals::JSON_ARRAY;
|
||||
_content.asArray = &array;
|
||||
}
|
||||
|
||||
// Create a JsonVariant containing a reference to an object.
|
||||
JsonVariant(JsonObject &object) {
|
||||
_type = Internals::JSON_OBJECT;
|
||||
_content.asObject = &object;
|
||||
}
|
||||
|
||||
// Get the variant as the specified type.
|
||||
//
|
||||
// short as<signed short>() const;
|
||||
// int as<signed int>() const;
|
||||
// long as<signed long>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsSignedIntegral<T>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return static_cast<T>(asInteger());
|
||||
}
|
||||
//
|
||||
// short as<unsigned short>() const;
|
||||
// int as<unsigned int>() const;
|
||||
// long as<unsigned long>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsUnsignedIntegral<T>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return static_cast<T>(asUnsignedInteger());
|
||||
}
|
||||
//
|
||||
// double as<double>() const;
|
||||
// float as<float>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return static_cast<T>(asFloat());
|
||||
}
|
||||
//
|
||||
// const String as<String>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, String>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return toString();
|
||||
}
|
||||
//
|
||||
// const char* as<const char*>() const;
|
||||
// const char* as<char*>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value ||
|
||||
TypeTraits::IsSame<T, char *>::value,
|
||||
const char *>::type
|
||||
as() const {
|
||||
return asString();
|
||||
}
|
||||
//
|
||||
// const bool as<bool>() const
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value,
|
||||
T>::type
|
||||
as() const {
|
||||
return asInteger() != 0;
|
||||
}
|
||||
//
|
||||
// JsonArray& as<JsonArray> const;
|
||||
// JsonArray& as<JsonArray&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
JsonArray>::value,
|
||||
JsonArray &>::type
|
||||
as() const {
|
||||
return asArray();
|
||||
}
|
||||
//
|
||||
// const JsonArray& as<const JsonArray&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
const JsonArray>::value,
|
||||
const JsonArray &>::type
|
||||
as() const {
|
||||
return asArray();
|
||||
}
|
||||
//
|
||||
// JsonObject& as<JsonObject> const;
|
||||
// JsonObject& as<JsonObject&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
JsonObject>::value,
|
||||
JsonObject &>::type
|
||||
as() const {
|
||||
return asObject();
|
||||
}
|
||||
//
|
||||
// JsonObject& as<const JsonObject> const;
|
||||
// JsonObject& as<const JsonObject&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<typename TypeTraits::RemoveReference<T>::type,
|
||||
const JsonObject>::value,
|
||||
const JsonObject &>::type
|
||||
as() const {
|
||||
return asObject();
|
||||
}
|
||||
|
||||
// Tells weither the variant has the specified type.
|
||||
// Returns true if the variant has type type T, false otherwise.
|
||||
//
|
||||
// short as<short>() const;
|
||||
// int as<int>() const;
|
||||
// long as<long>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsIntegral<T>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return isInteger();
|
||||
}
|
||||
//
|
||||
// double is<double>() const;
|
||||
// float is<float>() const;
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsFloatingPoint<T>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return isFloat();
|
||||
}
|
||||
//
|
||||
// const bool is<bool>() const
|
||||
template <typename T>
|
||||
const typename TypeTraits::EnableIf<TypeTraits::IsSame<T, bool>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return isBoolean();
|
||||
}
|
||||
//
|
||||
// bool is<const char*>() const;
|
||||
// bool is<char*>() const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<TypeTraits::IsSame<T, const char *>::value ||
|
||||
TypeTraits::IsSame<T, char *>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return isString();
|
||||
}
|
||||
//
|
||||
// bool is<JsonArray> const;
|
||||
// bool is<JsonArray&> const;
|
||||
// bool is<const JsonArray&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<
|
||||
typename TypeTraits::RemoveConst<
|
||||
typename TypeTraits::RemoveReference<T>::type>::type,
|
||||
JsonArray>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return isArray();
|
||||
}
|
||||
//
|
||||
// JsonObject& as<JsonObject> const;
|
||||
// JsonObject& as<JsonObject&> const;
|
||||
// JsonObject& as<const JsonObject&> const;
|
||||
template <typename T>
|
||||
typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<
|
||||
typename TypeTraits::RemoveConst<
|
||||
typename TypeTraits::RemoveReference<T>::type>::type,
|
||||
JsonObject>::value,
|
||||
bool>::type
|
||||
is() const {
|
||||
return isObject();
|
||||
}
|
||||
|
||||
// Returns true if the variant has a value
|
||||
bool success() const {
|
||||
return _type != Internals::JSON_UNDEFINED;
|
||||
}
|
||||
|
||||
// Serialize the variant to a JsonWriter
|
||||
void writeTo(Internals::JsonWriter &writer) const;
|
||||
|
||||
// Value returned if the variant has an incompatible type
|
||||
template <typename T>
|
||||
static typename Internals::JsonVariantAs<T>::type defaultValue() {
|
||||
return T();
|
||||
}
|
||||
|
||||
const char *asString() const;
|
||||
JsonArray &asArray() const;
|
||||
JsonObject &asObject() const;
|
||||
|
||||
private:
|
||||
// It's not allowed to store a char
|
||||
template <typename T>
|
||||
JsonVariant(T value, typename TypeTraits::EnableIf<
|
||||
TypeTraits::IsSame<T, char>::value>::type * = 0);
|
||||
|
||||
String toString() const;
|
||||
Internals::JsonFloat asFloat() const;
|
||||
Internals::JsonInteger asInteger() const;
|
||||
Internals::JsonUInt asUnsignedInteger() const;
|
||||
bool isBoolean() const;
|
||||
bool isFloat() const;
|
||||
bool isInteger() const;
|
||||
bool isArray() const {
|
||||
return _type == Internals::JSON_ARRAY;
|
||||
}
|
||||
bool isObject() const {
|
||||
return _type == Internals::JSON_OBJECT;
|
||||
}
|
||||
bool isString() const {
|
||||
return _type == Internals::JSON_STRING;
|
||||
}
|
||||
|
||||
// The current type of the variant
|
||||
Internals::JsonVariantType _type;
|
||||
|
||||
// The various alternatives for the value of the variant.
|
||||
Internals::JsonVariantContent _content;
|
||||
};
|
||||
|
||||
inline JsonVariant float_with_n_digits(float value, uint8_t digits) {
|
||||
return JsonVariant(value, digits);
|
||||
}
|
||||
|
||||
inline JsonVariant double_with_n_digits(double value, uint8_t digits) {
|
||||
return JsonVariant(value, digits);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct JsonVariant::IsConstructibleFrom {
|
||||
static const bool value =
|
||||
TypeTraits::IsIntegral<T>::value ||
|
||||
TypeTraits::IsFloatingPoint<T>::value ||
|
||||
TypeTraits::IsSame<T, bool>::value ||
|
||||
TypeTraits::IsSame<T, char *>::value ||
|
||||
TypeTraits::IsSame<T, const char *>::value ||
|
||||
TypeTraits::IsSame<T, RawJson>::value ||
|
||||
TypeTraits::IsSame<T, JsonArray &>::value ||
|
||||
TypeTraits::IsSame<T, const JsonArray &>::value ||
|
||||
TypeTraits::IsSame<T, JsonArraySubscript &>::value ||
|
||||
TypeTraits::IsSame<T, const JsonArraySubscript &>::value ||
|
||||
TypeTraits::IsSame<T, JsonObject &>::value ||
|
||||
TypeTraits::IsSame<T, const JsonObject &>::value ||
|
||||
TypeTraits::IsSame<T, JsonObjectSubscript<const char *> &>::value ||
|
||||
TypeTraits::IsSame<T, const JsonObjectSubscript<const char *> &>::value ||
|
||||
TypeTraits::IsSame<T, JsonObjectSubscript<String> &>::value ||
|
||||
TypeTraits::IsSame<T, const JsonObjectSubscript<String> &>::value ||
|
||||
TypeTraits::IsSame<T, JsonVariant &>::value ||
|
||||
TypeTraits::IsSame<T, const JsonVariant &>::value;
|
||||
};
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Configuration.hpp"
|
||||
#include "JsonVariant.hpp"
|
||||
#include "Internals/Parse.hpp"
|
||||
#include "JsonArray.hpp"
|
||||
#include "JsonObject.hpp"
|
||||
|
||||
#include <string.h> // for strcmp
|
||||
#include <errno.h> // for errno
|
||||
#include <stdlib.h> // for strtol, strtod
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
inline Internals::JsonInteger JsonVariant::asInteger() const {
|
||||
using namespace Internals;
|
||||
switch (_type) {
|
||||
case JSON_UNDEFINED:
|
||||
return 0;
|
||||
case JSON_POSITIVE_INTEGER:
|
||||
case JSON_BOOLEAN:
|
||||
return _content.asInteger;
|
||||
case JSON_NEGATIVE_INTEGER:
|
||||
return -static_cast<Internals::JsonInteger>(_content.asInteger);
|
||||
case JSON_STRING:
|
||||
case JSON_UNPARSED:
|
||||
if (!_content.asString) return 0;
|
||||
if (!strcmp("true", _content.asString)) return 1;
|
||||
return parse<Internals::JsonInteger>(_content.asString);
|
||||
default:
|
||||
return static_cast<Internals::JsonInteger>(_content.asFloat);
|
||||
}
|
||||
}
|
||||
|
||||
inline Internals::JsonUInt JsonVariant::asUnsignedInteger() const {
|
||||
using namespace Internals;
|
||||
switch (_type) {
|
||||
case JSON_UNDEFINED:
|
||||
return 0;
|
||||
case JSON_POSITIVE_INTEGER:
|
||||
case JSON_BOOLEAN:
|
||||
case JSON_NEGATIVE_INTEGER:
|
||||
return _content.asInteger;
|
||||
case JSON_STRING:
|
||||
case JSON_UNPARSED:
|
||||
if (!_content.asString) return 0;
|
||||
if (!strcmp("true", _content.asString)) return 1;
|
||||
return parse<Internals::JsonUInt>(_content.asString);
|
||||
default:
|
||||
return static_cast<Internals::JsonUInt>(_content.asFloat);
|
||||
}
|
||||
}
|
||||
|
||||
inline const char *JsonVariant::asString() const {
|
||||
using namespace Internals;
|
||||
if (_type == JSON_UNPARSED && _content.asString &&
|
||||
!strcmp("null", _content.asString))
|
||||
return NULL;
|
||||
if (_type == JSON_STRING || _type == JSON_UNPARSED) return _content.asString;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline Internals::JsonFloat JsonVariant::asFloat() const {
|
||||
using namespace Internals;
|
||||
switch (_type) {
|
||||
case JSON_UNDEFINED:
|
||||
return 0;
|
||||
case JSON_POSITIVE_INTEGER:
|
||||
case JSON_BOOLEAN:
|
||||
return static_cast<JsonFloat>(_content.asInteger);
|
||||
case JSON_NEGATIVE_INTEGER:
|
||||
return -static_cast<JsonFloat>(_content.asInteger);
|
||||
case JSON_STRING:
|
||||
case JSON_UNPARSED:
|
||||
return _content.asString ? parse<JsonFloat>(_content.asString) : 0;
|
||||
default:
|
||||
return _content.asFloat;
|
||||
}
|
||||
}
|
||||
|
||||
inline String JsonVariant::toString() const {
|
||||
using namespace Internals;
|
||||
String s;
|
||||
if ((_type == JSON_STRING || _type == JSON_UNPARSED) &&
|
||||
_content.asString != NULL)
|
||||
s = _content.asString;
|
||||
else
|
||||
printTo(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
inline bool JsonVariant::isBoolean() const {
|
||||
using namespace Internals;
|
||||
if (_type == JSON_BOOLEAN) return true;
|
||||
|
||||
if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
|
||||
|
||||
return !strcmp(_content.asString, "true") ||
|
||||
!strcmp(_content.asString, "false");
|
||||
}
|
||||
|
||||
inline bool JsonVariant::isInteger() const {
|
||||
using namespace Internals;
|
||||
if (_type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER)
|
||||
return true;
|
||||
|
||||
if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
|
||||
|
||||
char *end;
|
||||
errno = 0;
|
||||
strtol(_content.asString, &end, 10);
|
||||
|
||||
return *end == '\0' && errno == 0;
|
||||
}
|
||||
|
||||
inline bool JsonVariant::isFloat() const {
|
||||
using namespace Internals;
|
||||
if (_type >= JSON_FLOAT_0_DECIMALS) return true;
|
||||
|
||||
if (_type != JSON_UNPARSED || _content.asString == NULL) return false;
|
||||
|
||||
char *end;
|
||||
errno = 0;
|
||||
strtod(_content.asString, &end);
|
||||
|
||||
return *end == '\0' && errno == 0 && !is<long>();
|
||||
}
|
||||
|
||||
inline void JsonVariant::writeTo(Internals::JsonWriter &writer) const {
|
||||
using namespace Internals;
|
||||
switch (_type) {
|
||||
case JSON_UNDEFINED:
|
||||
return;
|
||||
|
||||
case JSON_ARRAY:
|
||||
_content.asArray->writeTo(writer);
|
||||
return;
|
||||
|
||||
case JSON_OBJECT:
|
||||
_content.asObject->writeTo(writer);
|
||||
return;
|
||||
|
||||
case JSON_STRING:
|
||||
writer.writeString(_content.asString);
|
||||
return;
|
||||
|
||||
case JSON_UNPARSED:
|
||||
writer.writeRaw(_content.asString);
|
||||
return;
|
||||
|
||||
case JSON_NEGATIVE_INTEGER:
|
||||
writer.writeRaw('-');
|
||||
case JSON_POSITIVE_INTEGER:
|
||||
writer.writeInteger(_content.asInteger);
|
||||
return;
|
||||
|
||||
case JSON_BOOLEAN:
|
||||
writer.writeBoolean(_content.asInteger != 0);
|
||||
return;
|
||||
|
||||
default:
|
||||
uint8_t decimals = static_cast<uint8_t>(_type - JSON_FLOAT_0_DECIMALS);
|
||||
writer.writeFloat(_content.asFloat, decimals);
|
||||
}
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
inline std::ostream &operator<<(std::ostream &os, const JsonVariant &source) {
|
||||
return source.printTo(os);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace ArduinoJson
|
||||
@@ -1,153 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Internals/JsonVariantAs.hpp"
|
||||
#include "JsonObjectKey.hpp"
|
||||
#include "Polyfills/attributes.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// Forward declarations.
|
||||
class JsonArraySubscript;
|
||||
template <typename TKey>
|
||||
class JsonObjectSubscript;
|
||||
|
||||
template <typename TImpl>
|
||||
class JsonVariantBase : public Internals::JsonPrintable<TImpl> {
|
||||
public:
|
||||
// DEPRECATED: use as<char*>() instead
|
||||
FORCE_INLINE const char *asString() const {
|
||||
return as<const char *>();
|
||||
}
|
||||
|
||||
// Gets the variant as an array.
|
||||
// Returns a reference to the JsonArray or JsonArray::invalid() if the
|
||||
// variant
|
||||
// is not an array.
|
||||
FORCE_INLINE operator JsonArray &() const {
|
||||
return as<JsonArray &>();
|
||||
}
|
||||
|
||||
// DEPRECATED: use as<JsonArray>() instead
|
||||
FORCE_INLINE JsonArray &asArray() const {
|
||||
return as<JsonArray &>();
|
||||
}
|
||||
|
||||
// Gets the variant as an object.
|
||||
// Returns a reference to the JsonObject or JsonObject::invalid() if the
|
||||
// variant is not an object.
|
||||
FORCE_INLINE operator JsonObject &() const {
|
||||
return as<JsonObject &>();
|
||||
}
|
||||
|
||||
// DEPRECATED: use as<JsonObject>() instead
|
||||
FORCE_INLINE JsonObject &asObject() const {
|
||||
return as<JsonObject &>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
FORCE_INLINE operator T() const {
|
||||
return as<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
FORCE_INLINE const typename Internals::JsonVariantAs<T>::type as() const {
|
||||
return impl()->template as<T>();
|
||||
}
|
||||
|
||||
// Mimics an array or an object.
|
||||
// Returns the size of the array or object if the variant has that type.
|
||||
// Returns 0 if the variant is neither an array nor an object
|
||||
size_t size() const {
|
||||
return asArray().size() + asObject().size();
|
||||
}
|
||||
|
||||
// Mimics an array.
|
||||
// Returns the element at specified index if the variant is an array.
|
||||
// Returns JsonVariant::invalid() if the variant is not an array.
|
||||
FORCE_INLINE const JsonArraySubscript operator[](int index) const;
|
||||
|
||||
// Mimics an object.
|
||||
// Returns the value associated with the specified key if the variant is
|
||||
// an object.
|
||||
// Return JsonVariant::invalid() if the variant is not an object.
|
||||
FORCE_INLINE const JsonObjectSubscript<const char *> operator[](
|
||||
const char *key) const;
|
||||
FORCE_INLINE const JsonObjectSubscript<const String &> operator[](
|
||||
const String &key) const;
|
||||
|
||||
// Serialize the variant to a JsonWriter
|
||||
void writeTo(Internals::JsonWriter &writer) const;
|
||||
|
||||
private:
|
||||
const TImpl *impl() const {
|
||||
return static_cast<const TImpl *>(this);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator==(const JsonVariantBase<TImpl> &left, TComparand right) {
|
||||
return left.template as<TComparand>() == right;
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator==(TComparand left, const JsonVariantBase<TImpl> &right) {
|
||||
return left == right.template as<TComparand>();
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator!=(const JsonVariantBase<TImpl> &left, TComparand right) {
|
||||
return left.template as<TComparand>() != right;
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator!=(TComparand left, const JsonVariantBase<TImpl> &right) {
|
||||
return left != right.template as<TComparand>();
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator<=(const JsonVariantBase<TImpl> &left, TComparand right) {
|
||||
return left.template as<TComparand>() <= right;
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator<=(TComparand left, const JsonVariantBase<TImpl> &right) {
|
||||
return left <= right.template as<TComparand>();
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator>=(const JsonVariantBase<TImpl> &left, TComparand right) {
|
||||
return left.template as<TComparand>() >= right;
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator>=(TComparand left, const JsonVariantBase<TImpl> &right) {
|
||||
return left >= right.template as<TComparand>();
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator<(const JsonVariantBase<TImpl> &left, TComparand right) {
|
||||
return left.template as<TComparand>() < right;
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator<(TComparand left, const JsonVariantBase<TImpl> &right) {
|
||||
return left < right.template as<TComparand>();
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator>(const JsonVariantBase<TImpl> &left, TComparand right) {
|
||||
return left.template as<TComparand>() > right;
|
||||
}
|
||||
|
||||
template <typename TImpl, typename TComparand>
|
||||
inline bool operator>(TComparand left, const JsonVariantBase<TImpl> &right) {
|
||||
return left > right.template as<TComparand>();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define FORCE_INLINE __forceinline
|
||||
#define NO_INLINE __declspec(noinline)
|
||||
#else
|
||||
#define FORCE_INLINE __attribute__((always_inline))
|
||||
#define NO_INLINE __attribute__((noinline))
|
||||
#endif
|
||||
@@ -1,111 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
// If Visual Studo <= 2012
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1700
|
||||
|
||||
#include <float.h>
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
template <typename T>
|
||||
bool isNaN(T x) {
|
||||
return _isnan(x) != 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool isInfinity(T x) {
|
||||
return !_finite(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// GCC warning: "conversion to 'float' from 'double' may alter its value"
|
||||
#ifdef __GNUC__
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic push
|
||||
#endif
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
|
||||
#pragma GCC diagnostic ignored "-Wfloat-conversion"
|
||||
#else
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Workaround for libs that #undef isnan or isinf
|
||||
// https://github.com/bblanchon/ArduinoJson/issues/284
|
||||
#if !defined(isnan) || !defined(isinf)
|
||||
namespace std {}
|
||||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
|
||||
template <typename T>
|
||||
bool isNaN(T x) {
|
||||
// Workaround for libs that #undef isnan
|
||||
// https://github.com/bblanchon/ArduinoJson/issues/284
|
||||
#ifndef isnan
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
return isnan(x);
|
||||
}
|
||||
|
||||
#if defined(_GLIBCXX_HAVE_ISNANL) && _GLIBCXX_HAVE_ISNANL
|
||||
template <>
|
||||
inline bool isNaN<double>(double x) {
|
||||
return isnanl(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_GLIBCXX_HAVE_ISNANF) && _GLIBCXX_HAVE_ISNANF
|
||||
template <>
|
||||
inline bool isNaN<float>(float x) {
|
||||
return isnanf(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
bool isInfinity(T x) {
|
||||
// Workaround for libs that #undef isinf
|
||||
// https://github.com/bblanchon/ArduinoJson/issues/284
|
||||
#ifndef isinf
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
return isinf(x);
|
||||
}
|
||||
|
||||
#if defined(_GLIBCXX_HAVE_ISINFL) && _GLIBCXX_HAVE_ISINFL
|
||||
template <>
|
||||
inline bool isInfinity<double>(double x) {
|
||||
return isinfl(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_GLIBCXX_HAVE_ISINFF) && _GLIBCXX_HAVE_ISINFF
|
||||
template <>
|
||||
inline bool isInfinity<float>(float x) {
|
||||
return isinff(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Polyfills {
|
||||
|
||||
#ifdef ARDUINO
|
||||
|
||||
// on embedded platform, favor code size over speed
|
||||
|
||||
template <typename T>
|
||||
short normalize(T& value) {
|
||||
short powersOf10 = 0;
|
||||
while (value && value < 1) {
|
||||
powersOf10--;
|
||||
value *= 10;
|
||||
}
|
||||
while (value > 10) {
|
||||
powersOf10++;
|
||||
value /= 10;
|
||||
}
|
||||
return powersOf10;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// on non-embedded platform, favor speed over code size
|
||||
|
||||
template <typename T>
|
||||
short normalize(T& value) {
|
||||
if (value == 0.0) return 0;
|
||||
|
||||
short powersOf10 = static_cast<short>(floor(log10(value)));
|
||||
value /= pow(T(10), powersOf10);
|
||||
|
||||
return powersOf10;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef ARDUINO
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ArduinoJson {
|
||||
// This class reproduces Arduino's Print class
|
||||
class Print {
|
||||
public:
|
||||
virtual ~Print() {}
|
||||
|
||||
virtual size_t write(uint8_t) = 0;
|
||||
|
||||
size_t print(const char* s) {
|
||||
size_t n = 0;
|
||||
while (*s) {
|
||||
n += write(*s++);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t println() { return write('\r') + write('\n'); }
|
||||
};
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <Print.h>
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// A special type of data that can be used to insert pregenerated JSON portions.
|
||||
class RawJson {
|
||||
public:
|
||||
explicit RawJson(const char* str) : _str(str) {}
|
||||
operator const char*() const { return _str; }
|
||||
|
||||
private:
|
||||
const char* _str;
|
||||
};
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonBuffer.hpp"
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic push
|
||||
#endif
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#endif
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
// Implements a JsonBuffer with fixed memory allocation.
|
||||
// The template paramenter CAPACITY specifies the capacity of the buffer in
|
||||
// bytes.
|
||||
template <size_t CAPACITY>
|
||||
class StaticJsonBuffer : public JsonBuffer {
|
||||
public:
|
||||
explicit StaticJsonBuffer() : _size(0) {}
|
||||
|
||||
size_t capacity() const {
|
||||
return CAPACITY;
|
||||
}
|
||||
size_t size() const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
virtual void* alloc(size_t bytes) {
|
||||
if (_size + bytes > CAPACITY) return NULL;
|
||||
void* p = &_buffer[_size];
|
||||
_size += round_size_up(bytes);
|
||||
return p;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t _buffer[CAPACITY];
|
||||
size_t _size;
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Configuration.hpp"
|
||||
|
||||
#if ARDUINOJSON_USE_ARDUINO_STRING
|
||||
|
||||
#include <WString.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ArduinoJson {
|
||||
typedef std::string String;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Configuration.hpp"
|
||||
#include "IsSame.hpp"
|
||||
#include "IsSignedIntegral.hpp"
|
||||
#include "IsUnsignedIntegral.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace TypeTraits {
|
||||
|
||||
// A meta-function that returns true if T is an integral type.
|
||||
template <typename T>
|
||||
struct IsIntegral {
|
||||
static const bool value = TypeTraits::IsSignedIntegral<T>::value ||
|
||||
TypeTraits::IsUnsignedIntegral<T>::value ||
|
||||
TypeTraits::IsSame<T, char>::value;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace TypeTraits {
|
||||
|
||||
// A meta-function that returns true if T is a reference
|
||||
template <typename T>
|
||||
struct IsReference {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IsReference<T&> {
|
||||
static const bool value = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Configuration.hpp"
|
||||
#include "IsSame.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace TypeTraits {
|
||||
|
||||
// A meta-function that returns true if T is an integral type.
|
||||
template <typename T>
|
||||
struct IsSignedIntegral {
|
||||
static const bool value = TypeTraits::IsSame<T, signed char>::value ||
|
||||
TypeTraits::IsSame<T, signed short>::value ||
|
||||
TypeTraits::IsSame<T, signed int>::value ||
|
||||
TypeTraits::IsSame<T, signed long>::value ||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
TypeTraits::IsSame<T, signed long long>::value ||
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_USE_INT64
|
||||
TypeTraits::IsSame<T, signed __int64>::value ||
|
||||
#endif
|
||||
false;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright Benoit Blanchon 2014-2016
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
// If you like this project, please add a star!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../Configuration.hpp"
|
||||
#include "IsSame.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace TypeTraits {
|
||||
|
||||
// A meta-function that returns true if T is an integral type.
|
||||
template <typename T>
|
||||
struct IsUnsignedIntegral {
|
||||
static const bool value = TypeTraits::IsSame<T, unsigned char>::value ||
|
||||
TypeTraits::IsSame<T, unsigned short>::value ||
|
||||
TypeTraits::IsSame<T, unsigned int>::value ||
|
||||
TypeTraits::IsSame<T, unsigned long>::value ||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
TypeTraits::IsSame<T, unsigned long long>::value ||
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_USE_INT64
|
||||
TypeTraits::IsSame<T, unsigned __int64>::value ||
|
||||
#endif
|
||||
false;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ JsonArray KEYWORD1
|
||||
JsonObject KEYWORD1
|
||||
JsonVariant KEYWORD1
|
||||
StaticJsonBuffer KEYWORD1
|
||||
DynamicJsonBuffer KEYWORD1
|
||||
add KEYWORD2
|
||||
createArray KEYWORD2
|
||||
createNestedArray KEYWORD2
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
{
|
||||
"name": "Json",
|
||||
"name": "ArduinoJson",
|
||||
"keywords": "json, rest, http, web",
|
||||
"description": "An elegant and efficient JSON library for embedded systems",
|
||||
"homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bblanchon/ArduinoJson.git"
|
||||
},
|
||||
"version": "5.6.4",
|
||||
"version": "5.13.2",
|
||||
"authors": {
|
||||
"name": "Benoit Blanchon",
|
||||
"url": "http://blog.benoitblanchon.fr"
|
||||
"url": "https://blog.benoitblanchon.fr"
|
||||
},
|
||||
"exclude": [
|
||||
"fuzzing",
|
||||
"scripts",
|
||||
"src/ArduinoJson.h",
|
||||
"test",
|
||||
"third-party"
|
||||
],
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
name=ArduinoJson
|
||||
version=5.6.4
|
||||
version=5.13.2
|
||||
author=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
|
||||
sentence=An efficient and elegant JSON library for Arduino.
|
||||
paragraph=Like this project? Please star it on GitHub!
|
||||
paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ fixed allocation, ✔ zero-copy, ✔ streams, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation.
|
||||
category=Data Processing
|
||||
url=https://github.com/bblanchon/ArduinoJson
|
||||
url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
|
||||
architectures=*
|
||||
repository=https://github.com/bblanchon/ArduinoJson.git
|
||||
license=MIT
|
||||
|
||||
@@ -12,7 +12,7 @@ rm -f $OUTPUT
|
||||
7z a $OUTPUT \
|
||||
ArduinoJson/CHANGELOG.md \
|
||||
ArduinoJson/examples \
|
||||
ArduinoJson/include \
|
||||
ArduinoJson/src \
|
||||
ArduinoJson/keywords.txt \
|
||||
ArduinoJson/library.properties \
|
||||
ArduinoJson/LICENSE.md \
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
TAG=$(git describe)
|
||||
RE_INCLUDE='^#include[[:space:]]*["<](.*)[">]'
|
||||
RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
|
||||
|
||||
declare -A INCLUDED
|
||||
|
||||
process()
|
||||
{
|
||||
local PARENT=$1
|
||||
local FOLDER=$(dirname $1)
|
||||
local SHOW_COMMENT=$2
|
||||
while IFS= read -r LINE; do
|
||||
if [[ $LINE =~ $RE_INCLUDE ]]; then
|
||||
local CHILD=${BASH_REMATCH[1]}
|
||||
pushd "$FOLDER" > /dev/null
|
||||
if [[ -e $CHILD ]]; then
|
||||
local CHILD_PATH=$(realpath $CHILD)
|
||||
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
|
||||
#echo "// $PARENT -> $CHILD"
|
||||
INCLUDED[$CHILD_PATH]=true
|
||||
process "$CHILD" false
|
||||
fi
|
||||
else
|
||||
if [[ ! ${INCLUDED[$CHILD]} ]]; then
|
||||
echo "$LINE"
|
||||
INCLUDED[$CHILD]=true
|
||||
fi
|
||||
fi
|
||||
popd > /dev/null
|
||||
elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
|
||||
echo "$LINE"
|
||||
elif [[ ! $LINE =~ $RE_EMPTY ]]; then
|
||||
echo "$LINE"
|
||||
fi
|
||||
done < $PARENT
|
||||
}
|
||||
|
||||
cd $(dirname $0)/../
|
||||
INCLUDED=()
|
||||
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
|
||||
g++ -x c++ -c -o ../smoketest.o - <<END
|
||||
#include "../ArduinoJson-$TAG.h"
|
||||
int main() {}
|
||||
END
|
||||
|
||||
INCLUDED=()
|
||||
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
|
||||
g++ -x c++ -c -o ../smoketest.o - <<END
|
||||
#include "../ArduinoJson-$TAG.hpp"
|
||||
int main() {}
|
||||
END
|
||||
@@ -1,5 +0,0 @@
|
||||
CPPLINT="python third-party/cpplint/cpplint.py"
|
||||
FLAGS="--filter=-runtime/printf,-runtime/int,-readability/todo,-build/namespace,-runtime/references,-readability/streams"
|
||||
|
||||
cd ..
|
||||
$CPPLINT $FLAGS $(find include src test -regex ".*\.[hc]pp$")
|
||||
@@ -1,7 +0,0 @@
|
||||
cd ..
|
||||
FILES=$(find include src test -regex ".*\.[ch]pp$")
|
||||
|
||||
clang-format -style=Google -i $FILES
|
||||
|
||||
# insert newline at end of file
|
||||
sed -i -e '$a\' $FILES
|
||||
@@ -0,0 +1,2 @@
|
||||
/.vagrant/
|
||||
*.log
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
# A virtual machine to run https://github.com/google/oss-fuzz
|
||||
Vagrant.configure(2) do |config|
|
||||
config.vm.box = "ubuntu/xenial64"
|
||||
|
||||
config.vm.synced_folder "E:\\Git\\Arduino\\libraries\\ArduinoJson", "/host/ArduinoJson"
|
||||
config.vm.synced_folder "E:\\Git\\oss-fuzz", "/host/oss-fuzz"
|
||||
|
||||
config.vm.network "forwarded_port", guest: 8001, host: 8001
|
||||
|
||||
config.vm.provision "shell", privileged: false, inline: <<-SHELL
|
||||
set -x
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y make git docker.io zip
|
||||
sudo groupadd docker
|
||||
sudo usermod -aG docker $USER
|
||||
|
||||
git clone https://github.com/google/fuzzer-test-suite.git FTS
|
||||
./FTS/tutorial/install-deps.sh # Get deps
|
||||
./FTS/tutorial/install-clang.sh # Get fresh clang binaries
|
||||
# Get libFuzzer sources and build it
|
||||
svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
|
||||
Fuzzer/build.sh
|
||||
sudo mv libFuzzer.a /usr/local/lib/
|
||||
|
||||
echo "export PROJECT_NAME='arduinojson'" >> $HOME/.profile
|
||||
echo "export CC='clang'" >> $HOME/.profile
|
||||
echo "export CXX='clang++'" >> $HOME/.profile
|
||||
echo "export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/" >> $HOME/.profile
|
||||
|
||||
echo "Run /host/ArduinoJson/fuzzing/fuzz.sh" | sudo tee /etc/motd
|
||||
SHELL
|
||||
end
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILE=../bin/ArduinoJsonTests.exe
|
||||
MD5=""
|
||||
|
||||
file_changed() {
|
||||
[[ ! -f "$FILE" ]] && return 1
|
||||
NEW_MD5=$(md5sum $FILE)
|
||||
[[ "$MD5" == "$NEW_MD5" ]] && return 1
|
||||
MD5=$NEW_MD5
|
||||
return 0
|
||||
}
|
||||
|
||||
test_succeed() {
|
||||
echo -en "\007"{,}
|
||||
}
|
||||
|
||||
test_failed() {
|
||||
echo -en "\007"{,,,,,,,,,,,}
|
||||
}
|
||||
|
||||
run_tests() {
|
||||
$FILE
|
||||
case $? in
|
||||
0)
|
||||
test_succeed
|
||||
;;
|
||||
1)
|
||||
test_failed
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
while true
|
||||
do
|
||||
if file_changed
|
||||
then
|
||||
run_tests
|
||||
else
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh -eux
|
||||
|
||||
URL=https://cmake.org/files/v3.4/cmake-3.4.3-Darwin-x86_64.tar.gz
|
||||
|
||||
curl -sS $URL | tar xz -C /tmp --strip 1
|
||||
|
||||
/tmp/CMake.app/Contents/bin/cmake .
|
||||
make
|
||||
make test
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user