wip
This commit is contained in:
@@ -38,6 +38,17 @@ std::string Network::getHostname() const {
|
||||
return WiFi.getHostname();
|
||||
}
|
||||
|
||||
const std::string Network::getMacAddress() const {
|
||||
std::string mac = WiFi.macAddress().c_str(); // format: "AA:BB:CC:DD:EE:FF"
|
||||
std::string hexMac = "0x";
|
||||
for (size_t i = 0; i < mac.size(); ++i) {
|
||||
if (mac[i] != ':') {
|
||||
hexMac += mac[i];
|
||||
}
|
||||
}
|
||||
return hexMac;
|
||||
}
|
||||
|
||||
bool Network::setHostname(const std::string_view &hostname) {
|
||||
this->hostname = std::string(hostname);
|
||||
return WiFi.setHostname(this->hostname.c_str());
|
||||
|
||||
@@ -9,6 +9,7 @@ public:
|
||||
void reconnect();
|
||||
bool isConnected() const;
|
||||
std::string getHostname() const;
|
||||
const std::string getMacAddress() const;
|
||||
bool setHostname(const std::string_view &hostname);
|
||||
void registerMDNS();
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user