17 lines
552 B
C++
17 lines
552 B
C++
/*
|
|
* From https://stackoverflow.com/a/35236734
|
|
*/
|
|
|
|
#include <Arduino.h>
|
|
|
|
void parseBytes(const char* str, char sep, byte* bytes, int maxBytes, int base) {
|
|
for (int i = 0; i < maxBytes; i++) {
|
|
bytes[i] = strtoul(str, NULL, base); // Convert byte
|
|
str = strchr(str, sep); // Find next separator
|
|
if (str == NULL || *str == '\0') {
|
|
break; // No more separators, exit
|
|
}
|
|
str++; // Point to next character after separator
|
|
}
|
|
}
|