Files
SyncHome/trunk/Arduino/esp32-cam-webserver/src/parsebytes.cpp

17 lines
552 B
C++
Raw Normal View History

2023-03-17 11:40:49 +00:00
/*
* 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
}
}