Skip to content

Commit b1b3fe9

Browse files
committed
Remove dep on DebugLog
1 parent 8c75835 commit b1b3fe9

File tree

3 files changed

+0
-51
lines changed

3 files changed

+0
-51
lines changed

src/MsgPack.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22
#ifndef HT_SERIAL_MSGPACK_H
33
#define HT_SERIAL_MSGPACK_H
44

5-
#include <DebugLog.h>
6-
#ifdef MSGPACK_DEBUGLOG_ENABLE
7-
#include <DebugLogEnable.h>
8-
#else
9-
#include <DebugLogDisable.h>
10-
#endif
11-
125
#include "MsgPack/Types.h"
136
#include "MsgPack/Packer.h"
147
#include "MsgPack/Unpacker.h"
158
#include "MsgPack/Utility.h"
169

1710
namespace MsgPack = arduino::msgpack;
1811

19-
#include <DebugLogRestoreState.h>
20-
2112
#endif // ARDUINOMSGPACK_H

src/MsgPack/Packer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
#include "Types.h"
2828
#include "Unpacker.h"
29-
#include <DebugLog.h>
3029

3130
namespace arduino {
3231
namespace msgpack {
@@ -101,8 +100,6 @@ namespace msgpack {
101100
size_t size = sizeof...(args);
102101
if ((size % 2) == 0)
103102
serialize(map_size_t(size / 2), std::forward<Args>(args)...);
104-
else
105-
LOG_ERROR(F("serialize arg size must be even for map:"), size);
106103
}
107104

108105
const bin_t<uint8_t>& packet() const {

src/MsgPack/Unpacker.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#endif // TEENSYDUINO
2525

2626
#include "Types.h"
27-
#include <DebugLog.h>
2827

2928
namespace arduino {
3029
namespace msgpack {
@@ -38,7 +37,6 @@ namespace msgpack {
3837

3938
#define MSGPACK_DECODABLE_CHECK(T) \
4039
if (curr_index >= indices.size()) { \
41-
LOG_ERROR(F("no more decodable objects")); \
4240
b_decode_success = false; \
4341
return T(); \
4442
} else { \
@@ -55,19 +53,16 @@ namespace msgpack {
5553
for (size_t i = 0; i < size; i += getElementSize(indices.size() - 1)) indices.emplace_back(i);
5654
const size_t decoded_size = indices.back() + getElementSize(indices.size() - 1);
5755
b_size_matched = (size == decoded_size);
58-
if (!b_size_matched) LOG_ERROR(F("decoded binary size"), decoded_size, F("not matched to"), size);
5956
return b_size_matched;
6057
}
6158

6259
template <typename First, typename... Rest>
6360
bool deserialize(First& first, Rest&&... rest) {
6461
if (!b_size_matched || indices.empty()) {
65-
LOG_WARN(F("correct binary data was not supplied yet"));
6662
b_decode_success = false;
6763
return b_decode_success;
6864
}
6965
if (curr_index >= indices.size()) {
70-
LOG_ERROR(F("too many args: obj index overflow"));
7166
b_decode_success = false;
7267
return b_decode_success;
7368
}
@@ -80,7 +75,6 @@ namespace msgpack {
8075

8176
bool deserialize() {
8277
if (curr_index > indices.size()) {
83-
LOG_ERROR("index overflow:", curr_index, "must be <=", indices.size());
8478
b_decode_success = false;
8579
}
8680

@@ -97,7 +91,6 @@ namespace msgpack {
9791
bool deserialize_arduinojson(JsonDocument& doc) {
9892
auto err = deserializeMsgPack(doc, raw_data);
9993
if (err) {
100-
LOG_ERROR("deserializeJson() faled: ", err.c_str());
10194
b_decode_success = false;
10295
} else {
10396
b_decode_success = true;
@@ -128,7 +121,6 @@ namespace msgpack {
128121
static map_size_t sz;
129122
return deserialize(sz, std::forward<Args>(args)...);
130123
} else {
131-
LOG_ERROR(F("arg size must be even for map:"), sizeof...(args));
132124
b_decode_success = false;
133125
return b_decode_success;
134126
}
@@ -309,7 +301,6 @@ namespace msgpack {
309301
if (N == size)
310302
for (auto& a : arr) unpack(a);
311303
else {
312-
LOG_ERROR(F("array size mismatch:"), size, F("must be"), N);
313304
b_decode_success = false;
314305
}
315306
return b_decode_success;
@@ -329,7 +320,6 @@ namespace msgpack {
329320
unpack(arr.first);
330321
unpack(arr.second);
331322
} else {
332-
LOG_ERROR(F("array size mismatch:"), size, F("must be"), 2);
333323
b_decode_success = false;
334324
}
335325
return b_decode_success;
@@ -341,7 +331,6 @@ namespace msgpack {
341331
if (sizeof...(Args) == size) {
342332
to_tuple(t);
343333
} else {
344-
LOG_ERROR(F("array size mismatch:"), size, F("must be"), sizeof...(Args));
345334
b_decode_success = false;
346335
}
347336
return b_decode_success;
@@ -358,7 +347,6 @@ namespace msgpack {
358347
const size_t arr_size = std::distance(arr.begin(), arr.end());
359348
const size_t size = unpackArraySize();
360349
if (size == 0) {
361-
LOG_ERROR(F("array size mismatch:"), size, F("must be"), arr_size);
362350
b_decode_success = false;
363351
} else if (arr_size == size)
364352
for (auto& a : arr) unpack(a);
@@ -492,7 +480,6 @@ namespace msgpack {
492480
case Type::UINT64:
493481
return (T)unpackUInt64();
494482
default:
495-
LOG_ERROR("type error");
496483
return type_error<T>();
497484
}
498485
}
@@ -525,7 +512,6 @@ namespace msgpack {
525512
case Type::UINT64:
526513
return uint_to_int<T, uint64_t, int64_t>(unpackUInt64());
527514
default:
528-
LOG_ERROR("type error");
529515
return type_error<T>();
530516
}
531517
}
@@ -562,7 +548,6 @@ namespace msgpack {
562548
case Type::FLOAT64:
563549
return (T)unpackFloat64();
564550
default:
565-
LOG_ERROR("type error");
566551
return type_error<T>();
567552
}
568553
}
@@ -581,7 +566,6 @@ namespace msgpack {
581566
case Type::STR32:
582567
return unpackStringUnchecked32();
583568
default:
584-
LOG_ERROR("type error");
585569
return type_error<str_t>();
586570
}
587571
}
@@ -600,7 +584,6 @@ namespace msgpack {
600584
case Type::BIN32:
601585
return unpackBinaryUnchecked32<T>();
602586
default:
603-
LOG_ERROR("type error");
604587
return type_error<bin_t<T>>();
605588
}
606589
}
@@ -620,7 +603,6 @@ namespace msgpack {
620603
case Type::BIN32:
621604
return unpackBinaryUnchecked32<T, N>();
622605
default:
623-
LOG_ERROR("type error");
624606
return type_error<std::array<T, N>>();
625607
}
626608
}
@@ -639,7 +621,6 @@ namespace msgpack {
639621
case Type::ARRAY32:
640622
return unpackArraySizeUnchecked32();
641623
default:
642-
LOG_ERROR("type error");
643624
return type_error<size_t>();
644625
}
645626
}
@@ -656,7 +637,6 @@ namespace msgpack {
656637
case Type::MAP32:
657638
return unpackMapSizeUnchecked32();
658639
default:
659-
LOG_ERROR("type error");
660640
return type_error<size_t>();
661641
}
662642
}
@@ -683,7 +663,6 @@ namespace msgpack {
683663
case Type::EXT32:
684664
return unpackExtUnchecked32();
685665
default:
686-
LOG_ERROR("type error");
687666
return type_error<object::ext>();
688667
}
689668
}
@@ -701,7 +680,6 @@ namespace msgpack {
701680
else if (isTimestamp96())
702681
return unpackTimestampUnchecked96();
703682
else {
704-
LOG_ERROR("type error");
705683
return type_error<object::timespec>();
706684
}
707685
}
@@ -1792,7 +1770,6 @@ namespace msgpack {
17921770
template <typename DataType>
17931771
DataType getRawBytes(const size_t idx, const size_t offset) const {
17941772
if (idx >= indices.size()) {
1795-
LOG_ERROR(F("index overrun: idx"), idx, F("must be <"), indices.size());
17961773
return DataType();
17971774
}
17981775
DataType data;
@@ -1807,7 +1784,6 @@ namespace msgpack {
18071784

18081785
uint8_t* getRawBytePtr(const size_t idx, const size_t offset) const {
18091786
if (idx >= indices.size()) {
1810-
LOG_ERROR(F("index overrun: idx"), idx, F("must be <"), indices.size());
18111787
return nullptr;
18121788
}
18131789
auto index = indices[idx] + offset;
@@ -1816,7 +1792,6 @@ namespace msgpack {
18161792

18171793
Type getType(const size_t idx) const {
18181794
if (idx >= indices.size()) {
1819-
LOG_ERROR(F("index overrun: idx"), idx, F("must be <"), indices.size());
18201795
return Type::NA;
18211796
}
18221797

@@ -1898,23 +1873,12 @@ namespace msgpack {
18981873
case Type::EXT32:
18991874
return (size_t)getRawBytes<uint32_t>(i, 1) + sizeof(uint32_t) + 1 + 1;
19001875
default:
1901-
LOG_ERROR(F("undefined type:"), (int)type);
19021876
return 0;
19031877
}
19041878
}
19051879

19061880
template <typename T>
19071881
T type_error(const Type type = Type::NA) {
1908-
if (type == Type::NA)
1909-
LOG_ERROR(F("unknown type in index"), curr_index, F(": type byte"), (int)getType());
1910-
else
1911-
LOG_ERROR(
1912-
F("unpack type mimatch in index"),
1913-
curr_index,
1914-
F(": type byte"),
1915-
(int)getType(),
1916-
F("must be"),
1917-
(int)type);
19181882
b_decode_success = false;
19191883
++curr_index;
19201884
return T();
@@ -1941,7 +1905,6 @@ namespace msgpack {
19411905
{
19421906
const size_t size = unpackArraySize();
19431907
if (size == 0) {
1944-
LOG_ERROR(F("array size mismatch:"), size, F("must be"), arr.size());
19451908
b_decode_success = false;
19461909
} else if (arr.size() == size)
19471910
for (auto& a : arr) unpack(a);
@@ -1964,7 +1927,6 @@ namespace msgpack {
19641927
{
19651928
const size_t size = unpackArraySize();
19661929
if (size == 0) {
1967-
LOG_ERROR(F("array size mismatch:"), size, F("must be"), arr.size());
19681930
b_decode_success = false;
19691931
} else {
19701932
arr.clear();
@@ -1985,7 +1947,6 @@ namespace msgpack {
19851947
#endif // Do not have libstdc++11
19861948
const size_t size = unpackMapSize();
19871949
if (size == 0) {
1988-
LOG_ERROR(F("map size mismatch:"), size, F("must be"), mp.size());
19891950
b_decode_success = false;
19901951
} else {
19911952
mp.clear();

0 commit comments

Comments
 (0)