Initial commit

This commit is contained in:
2026-05-06 09:34:32 +02:00
commit 81eebf1cff
3 changed files with 159 additions and 0 deletions

36
utils.ino Normal file
View File

@@ -0,0 +1,36 @@
void splitBySpaces(String input, String parts[], int maxSpaces) {
int partIndex = 0;
int startIndex = 0;
for (int i = 0; i < input.length() && partIndex < maxSpaces; i++) {
if (input.charAt(i) == ' ') {
parts[partIndex++] = input.substring(startIndex, i);
startIndex = i + 1;
}
}
parts[partIndex] = input.substring(startIndex);
for (int i = partIndex + 1; i <= maxSpaces; i++) {
parts[i] = "";
}
}
int countSpaces(String s) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ' ') {
count++;
}
}
return count;
}
void macStringToBytes(String macStr, uint8_t macBytes[6]) {
int byteIndex = 0;
for (int i = 0; i < 6; i++) {
String byteString = macStr.substring(i * 3, i * 3 + 2); // "28", "05", ...
macBytes[i] = strtoul(byteString.c_str(), NULL, 16); // из hex в uint8_t
}
}