diff --git a/ampel-firmware/ampel-firmware.ino b/ampel-firmware/ampel-firmware.ino index a640ff2455b3fa8cc9e9f9565e44c4b86dc69a4e..e8eef2f414953c155f0f2e781d0da75f35623c97 100644 --- a/ampel-firmware/ampel-firmware.ino +++ b/ampel-firmware/ampel-firmware.ino @@ -85,7 +85,7 @@ void setup() { Serial.print(F("Sensor ID: ")); Serial.println(ampel.sensorId); Serial.print(F("Board : ")); - Serial.println(BOARD); + Serial.println(ampel.board); #ifdef AMPEL_WIFI WiFiConnect(ampel.sensorId); diff --git a/ampel-firmware/util.cpp b/ampel-firmware/util.cpp index 06c74243a02c47e1d22f5ea0ef7b7b4e1f3ef4e0..b555b1a3ec815938933d16052da002b032d1c314 100644 --- a/ampel-firmware/util.cpp +++ b/ampel-firmware/util.cpp @@ -5,6 +5,14 @@ namespace config { const long utc_offset_in_seconds = UTC_OFFSET_IN_SECONDS; // UTC+1 } +#if defined(ESP8266) +const char *current_board = "ESP8266"; +#elif defined(ESP32) +const char *current_board = "ESP32"; +#else +const char *current_board = "UNKNOWN"; +#endif + // Get last 3 bytes of ESP MAC (worldwide unique) String macToID() { uint8_t mac[6]; @@ -58,7 +66,7 @@ void Ampel::showFreeSpace() { } Ampel::Ampel() : - sensorId("ESP" + macToID()), max_loop_duration(0) { + board(current_board), sensorId("ESP" + macToID()), max_loop_duration(0) { sensor_console::defineIntCommand("set_time", ntp::setLocalTime, " 1618829570 (Sets time to the given UNIX time)"); sensor_console::defineCommand("free", Ampel::showFreeSpace, " (Displays available heap space)"); sensor_console::defineCommand("reset", []() { diff --git a/ampel-firmware/util.h b/ampel-firmware/util.h index 1cb3dc56d9a847d08f2c884d3887bf81449df9ba..b99a5d52d6c137c92372223da317ae7e2bf2ad64 100644 --- a/ampel-firmware/util.h +++ b/ampel-firmware/util.h @@ -8,15 +8,11 @@ #include "src/lib/NTPClient-master/NTPClient.h" // NTP #if defined(ESP8266) -# define BOARD "ESP8266" //TODO: Move to ampel.board? # include <ESP8266WiFi.h> // required to get MAC address # define get_free_heap_size() system_get_free_heap_size() #elif defined(ESP32) -# define BOARD "ESP32" # include <WiFi.h> // required to get MAC address # define get_free_heap_size() esp_get_free_heap_size() -#else -# define BOARD "Unknown" #endif namespace ntp { @@ -40,6 +36,7 @@ class Ampel { private: static void showFreeSpace(); public: + const char *board; const String sensorId; uint32_t max_loop_duration; Ampel(); diff --git a/ampel-firmware/web_server.cpp b/ampel-firmware/web_server.cpp index 4788b009c0a076b01712c158e7714f28f43c508b..ee20bf43cf57c5171a0b28a5915354c9cdf8dc48 100644 --- a/ampel-firmware/web_server.cpp +++ b/ampel-firmware/web_server.cpp @@ -239,7 +239,7 @@ namespace web_server { #endif config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", ampel.sensorId.c_str(), ampel.sensorId.c_str(), WiFi.localIP().toString().c_str(), WiFi.localIP().toString().c_str(), - get_free_heap_size(), ampel.max_loop_duration, BOARD, dd, hh, mm, ss); + get_free_heap_size(), ampel.max_loop_duration, ampel.board, dd, hh, mm, ss); Serial.print(F(" - Body size : ")); http.sendContent(content);