Commit 1a4864e4 authored by Eric Duminil's avatar Eric Duminil
Browse files

ampel.board

parent 9d1c951d
...@@ -85,7 +85,7 @@ void setup() { ...@@ -85,7 +85,7 @@ void setup() {
Serial.print(F("Sensor ID: ")); Serial.print(F("Sensor ID: "));
Serial.println(ampel.sensorId); Serial.println(ampel.sensorId);
Serial.print(F("Board : ")); Serial.print(F("Board : "));
Serial.println(BOARD); Serial.println(ampel.board);
#ifdef AMPEL_WIFI #ifdef AMPEL_WIFI
WiFiConnect(ampel.sensorId); WiFiConnect(ampel.sensorId);
......
...@@ -5,6 +5,14 @@ namespace config { ...@@ -5,6 +5,14 @@ namespace config {
const long utc_offset_in_seconds = UTC_OFFSET_IN_SECONDS; // UTC+1 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) // Get last 3 bytes of ESP MAC (worldwide unique)
String macToID() { String macToID() {
uint8_t mac[6]; uint8_t mac[6];
...@@ -58,7 +66,7 @@ void Ampel::showFreeSpace() { ...@@ -58,7 +66,7 @@ void Ampel::showFreeSpace() {
} }
Ampel::Ampel() : 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::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("free", Ampel::showFreeSpace, " (Displays available heap space)");
sensor_console::defineCommand("reset", []() { sensor_console::defineCommand("reset", []() {
......
...@@ -8,15 +8,11 @@ ...@@ -8,15 +8,11 @@
#include "src/lib/NTPClient-master/NTPClient.h" // NTP #include "src/lib/NTPClient-master/NTPClient.h" // NTP
#if defined(ESP8266) #if defined(ESP8266)
# define BOARD "ESP8266" //TODO: Move to ampel.board?
# include <ESP8266WiFi.h> // required to get MAC address # include <ESP8266WiFi.h> // required to get MAC address
# define get_free_heap_size() system_get_free_heap_size() # define get_free_heap_size() system_get_free_heap_size()
#elif defined(ESP32) #elif defined(ESP32)
# define BOARD "ESP32"
# include <WiFi.h> // required to get MAC address # include <WiFi.h> // required to get MAC address
# define get_free_heap_size() esp_get_free_heap_size() # define get_free_heap_size() esp_get_free_heap_size()
#else
# define BOARD "Unknown"
#endif #endif
namespace ntp { namespace ntp {
...@@ -40,6 +36,7 @@ class Ampel { ...@@ -40,6 +36,7 @@ class Ampel {
private: private:
static void showFreeSpace(); static void showFreeSpace();
public: public:
const char *board;
const String sensorId; const String sensorId;
uint32_t max_loop_duration; uint32_t max_loop_duration;
Ampel(); Ampel();
......
...@@ -239,7 +239,7 @@ namespace web_server { ...@@ -239,7 +239,7 @@ namespace web_server {
#endif #endif
config::temperature_offset, config::auto_calibrate_sensor ? "Yes" : "No", ampel.sensorId.c_str(), 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(), 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 : ")); Serial.print(F(" - Body size : "));
http.sendContent(content); http.sendContent(content);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment