some fixes
This commit is contained in:
parent
4c16611390
commit
30ebdde28e
13 changed files with 162 additions and 85 deletions
24
src/Utils.h
24
src/Utils.h
|
|
@ -14,6 +14,26 @@
|
|||
|
||||
namespace utils {
|
||||
|
||||
static bytes readHex(std::string d) {
|
||||
std::string delimiter = ":";
|
||||
std::string token;
|
||||
size_t pos = 0;
|
||||
bytes arr = { };
|
||||
int hex;
|
||||
byte b;
|
||||
while ((pos = d.find(delimiter)) != std::string::npos) {
|
||||
token = d.substr(0, pos);
|
||||
sscanf(token.c_str(), "%x", &hex);
|
||||
d.erase(0, pos + delimiter.length());
|
||||
b = hex & 0xFF;
|
||||
arr.push_back(b);
|
||||
}
|
||||
sscanf(d.c_str(), "%x", &hex);
|
||||
b = hex & 0xFF;
|
||||
arr.push_back(b);
|
||||
return arr;
|
||||
}
|
||||
|
||||
static void printHex(bytes d) {
|
||||
if (d.size() > 0)
|
||||
printf("%.2X", d[0]);
|
||||
|
|
@ -22,14 +42,14 @@ static void printHex(bytes d) {
|
|||
}
|
||||
}
|
||||
|
||||
static void print(byteArray<6> d) {
|
||||
static void print(macAddr d) {
|
||||
printf("%.2X", d[0]);
|
||||
for (unsigned i = 1; i < 6; i++) {
|
||||
printf(":%.2X", d[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void print(byteArray<4> d) {
|
||||
static void print(inetAddr d) {
|
||||
printf("%.1d", d[0]);
|
||||
for (unsigned i = 1; i < 4; i++) {
|
||||
printf(".%.1d", d[i]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue