Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/hex/hex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion src/hex/hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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);
}
};
Loading