diff --git a/src/hex/hex.cpp b/src/hex/hex.cpp index b56cd0f..95901f1 100644 --- a/src/hex/hex.cpp +++ b/src/hex/hex.cpp @@ -28,9 +28,14 @@ namespace arduino { namespace hex { } bool decode(const String in, uint8_t* out, uint32_t size) { + return decode(in.c_str(), out, size); + } + + bool decode(const char *in, uint8_t* out, uint32_t size) { unsigned int byteNumber; - byteNumber = chex_decode(out, size, in.begin(), in.length()); - return byteNumber * 2 == in.length(); + size_t len = strlen(in); + byteNumber = chex_decode(out, size, in, len); + return byteNumber * 2 == len; } }} // arduino::hex diff --git a/src/hex/hex.h b/src/hex/hex.h index 3344ed4..0d41b36 100644 --- a/src/hex/hex.h +++ b/src/hex/hex.h @@ -20,7 +20,7 @@ namespace arduino { namespace hex { String encode(const uint8_t* in, uint32_t size); String encodeUpper(const uint8_t* in, uint32_t size); - + bool decode(const char *in, uint8_t* out, uint32_t size); bool decode(const String in, uint8_t* out, uint32_t size); }} // arduino::hex @@ -37,4 +37,7 @@ class THEXT { return arduino::hex::decode(in, out, size); } + static inline bool decode(const char *in, uint8_t* out, uint32_t size) { + return arduino::hex::decode(in, out, size); + } };