mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-28 17:30:24 +00:00
Some serious restructuring to be able to swap between implementations
This commit is contained in:
23
lib/AmsConfiguration/src/hexutils.cpp
Normal file
23
lib/AmsConfiguration/src/hexutils.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "hexutils.h"
|
||||
|
||||
String toHex(uint8_t* in) {
|
||||
return toHex(in, sizeof(in)*2);
|
||||
}
|
||||
|
||||
String toHex(uint8_t* in, uint16_t size) {
|
||||
String hex;
|
||||
for(int i = 0; i < size; i++) {
|
||||
if(in[i] < 0x10) {
|
||||
hex += '0';
|
||||
}
|
||||
hex += String(in[i], HEX);
|
||||
}
|
||||
hex.toUpperCase();
|
||||
return hex;
|
||||
}
|
||||
|
||||
void fromHex(uint8_t *out, String in, uint16_t size) {
|
||||
for(int i = 0; i < size*2; i += 2) {
|
||||
out[i/2] = strtol(in.substring(i, i+2).c_str(), 0, 16);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user