Quellcode durchsuchen

Keep MAC accessor used by MQTT publishing

SybexXx vor 2 Tagen
Ursprung
Commit
37e686e2a1
2 geänderte Dateien mit 13 neuen und 0 gelöschten Zeilen
  1. 11 0
      code/components/jomjol_helper/Helper.cpp
  2. 2 0
      code/components/jomjol_helper/Helper.h

+ 11 - 0
code/components/jomjol_helper/Helper.cpp

@@ -1050,6 +1050,17 @@ string RundeOutput(double _in, int _anzNachkomma)
 }
 }
 
 
 
 
+string getMac(void)
+{
+	uint8_t macInt[6];
+	char macFormated[6 * 2 + 5 + 1]; // AA:BB:CC:DD:EE:FF
+
+	esp_read_mac(macInt, ESP_MAC_WIFI_STA);
+	sprintf(macFormated, "%02X:%02X:%02X:%02X:%02X:%02X", macInt[0], macInt[1], macInt[2], macInt[3], macInt[4], macInt[5]);
+
+	return macFormated;
+}
+
 void setSystemStatusFlag(SystemStatusFlag_t flag)
 void setSystemStatusFlag(SystemStatusFlag_t flag)
 {
 {
 	systemStatus = systemStatus | flag; // set bit
 	systemStatus = systemStatus | flag; // set bit

+ 2 - 0
code/components/jomjol_helper/Helper.h

@@ -107,4 +107,6 @@ int clipInt(int input, int high, int low);
 bool numericStrToBool(std::string input);
 bool numericStrToBool(std::string input);
 bool stringToBoolean(std::string input);
 bool stringToBoolean(std::string input);
 
 
+string getMac(void);
+
 #endif //HELPER_H
 #endif //HELPER_H