Skip to content

Commit a8b52ea

Browse files
committed
add hex decode function with const char*
1 parent f20f033 commit a8b52ea

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/hex/hex.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ namespace arduino { namespace hex {
2828
}
2929

3030
bool decode(const String in, uint8_t* out, uint32_t size) {
31+
return decode(in.c_str(), out, size);
32+
}
33+
34+
bool decode(const char *in, uint8_t* out, uint32_t size) {
3135
unsigned int byteNumber;
32-
byteNumber = chex_decode(out, size, in.begin(), in.length());
33-
return byteNumber * 2 == in.length();
36+
byteNumber = chex_decode(out, size, in, strlen(in));
37+
return byteNumber * 2 == strlen(in);
3438
}
3539

3640
}} // arduino::hex

src/hex/hex.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace arduino { namespace hex {
2020

2121
String encode(const uint8_t* in, uint32_t size);
2222
String encodeUpper(const uint8_t* in, uint32_t size);
23-
23+
bool decode(const char *in, uint8_t* out, uint32_t size);
2424
bool decode(const String in, uint8_t* out, uint32_t size);
2525
}} // arduino::hex
2626

@@ -37,4 +37,7 @@ class THEXT {
3737
return arduino::hex::decode(in, out, size);
3838
}
3939

40+
static inline bool decode(const char *in, uint8_t* out, uint32_t size) {
41+
return arduino::hex::decode(in, out, size);
42+
}
4043
};

0 commit comments

Comments
 (0)