17 lines
568 B
C++
17 lines
568 B
C++
#pragma once
|
|
#include "master.h"
|
|
#include <Arduino.h>
|
|
|
|
std::array<uint8_t, 6> macStringToBytes(const char *macStr) {
|
|
std::array<uint8_t, 6> bytes;
|
|
sscanf(macStr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &bytes[0], &bytes[1],
|
|
&bytes[2], &bytes[3], &bytes[4], &bytes[5]);
|
|
return bytes;
|
|
}
|
|
|
|
std::string macToString(const std::array<uint8_t, 6> &macBytes) {
|
|
char macStr[18];
|
|
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x", macBytes[0],
|
|
macBytes[1], macBytes[2], macBytes[3], macBytes[4], macBytes[5]);
|
|
return std::string(macStr);
|
|
} |