From 5b2df9253e9965df4f1d763b9ae7f66d518c4cbc Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 28 Jan 2019 21:15:39 +0000 Subject: [PATCH] Revert to default MAC string format for `getMAC` method in `AccessPointClass` and `StationClass` Fixes #1583, so by default reverts to previous behaviour, but supports alternative formats. --- Sming/SmingCore/Platform/AccessPoint.cpp | 4 ++-- Sming/SmingCore/Platform/AccessPoint.h | 3 ++- Sming/SmingCore/Platform/Station.cpp | 4 ++-- Sming/SmingCore/Platform/Station.h | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Sming/SmingCore/Platform/AccessPoint.cpp b/Sming/SmingCore/Platform/AccessPoint.cpp index 704cca246b..5d4a687f7b 100644 --- a/Sming/SmingCore/Platform/AccessPoint.cpp +++ b/Sming/SmingCore/Platform/AccessPoint.cpp @@ -138,11 +138,11 @@ bool AccessPointClass::setIP(IPAddress address) return true; } -String AccessPointClass::getMAC() +String AccessPointClass::getMAC(char sep) { uint8 hwaddr[6]; if(wifi_get_macaddr(SOFTAP_IF, hwaddr)) - return makeHexString(hwaddr, sizeof(hwaddr), ':'); + return makeHexString(hwaddr, sizeof(hwaddr), sep); else return nullptr; } diff --git a/Sming/SmingCore/Platform/AccessPoint.h b/Sming/SmingCore/Platform/AccessPoint.h index ac063cb299..3edca54257 100644 --- a/Sming/SmingCore/Platform/AccessPoint.h +++ b/Sming/SmingCore/Platform/AccessPoint.h @@ -70,9 +70,10 @@ class AccessPointClass : protected ISystemReadyHandler bool setIP(IPAddress address); /** @brief Get WiFi AP MAC address + * @param optional separator between bytes (e.g. ':') * @retval String WiFi AP MAC address */ - String getMAC(); + String getMAC(char sep = '\0'); /** @brief Get WiFi AP network mask * @retval IPAddress WiFi AP network mask diff --git a/Sming/SmingCore/Platform/Station.cpp b/Sming/SmingCore/Platform/Station.cpp index 454dbcc319..cb21e4867b 100644 --- a/Sming/SmingCore/Platform/Station.cpp +++ b/Sming/SmingCore/Platform/Station.cpp @@ -157,11 +157,11 @@ IPAddress StationClass::getIP() return info.ip; } -String StationClass::getMAC() +String StationClass::getMAC(char sep) { uint8 hwaddr[6]; if(wifi_get_macaddr(STATION_IF, hwaddr)) - return makeHexString(hwaddr, sizeof(hwaddr), ':'); + return makeHexString(hwaddr, sizeof(hwaddr), sep); else return nullptr; } diff --git a/Sming/SmingCore/Platform/Station.h b/Sming/SmingCore/Platform/Station.h index 5f7ea483bb..874a4e1e76 100644 --- a/Sming/SmingCore/Platform/Station.h +++ b/Sming/SmingCore/Platform/Station.h @@ -157,9 +157,10 @@ class StationClass : protected ISystemReadyHandler IPAddress getIP(); /** @brief Get WiFi station MAC address + * @param optional separator between bytes (e.g. ':') * @retval String WiFi station MAC address */ - String getMAC(); + String getMAC(char sep = '\0'); /** @brief Get WiFi station network mask * @retval IPAddress WiFi station network mask