Skip to content

Commit 03b4d18

Browse files
committed
MbedSocketClass: add flag to reverse macAddress
1 parent aacd17c commit 03b4d18

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

libraries/SocketWrapper/src/SocketHelpers.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#include "SocketHelpers.h"
22

3-
uint8_t* arduino::MbedSocketClass::macAddress(uint8_t* mac) {
3+
uint8_t* arduino::MbedSocketClass::macAddress(uint8_t* mac, bool reversed) {
44
const char* mac_str = getNetwork()->get_mac_address();
55
for (int b = 0; b < 6; b++) {
66
uint32_t tmp;
77
sscanf(&mac_str[b * 2 + (b)], "%02x", (unsigned int*)&tmp);
8-
mac[5 - b] = (uint8_t)tmp;
8+
if (reversed) {
9+
mac[5 - b] = (uint8_t)tmp;
10+
} else {
11+
mac[b] = (uint8_t)tmp;
12+
}
913
}
1014
//sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &mac[5], &mac[4], &mac[3], &mac[2], &mac[1], &mac[0]);
1115
return mac;

libraries/SocketWrapper/src/SocketHelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class MbedSocketClass {
128128

129129
int hostByName(const char* aHostname, IPAddress& aResult);
130130

131-
uint8_t* macAddress(uint8_t* mac);
131+
uint8_t* macAddress(uint8_t* mac, bool reversed = false);
132132
String macAddress();
133133

134134
void setFeedWatchdogFunc(voidFuncPtr func);

0 commit comments

Comments
 (0)