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

ampel.board

parent 9d1c951d
......@@ -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);
......
......@@ -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", []() {
......
......@@ -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();
......
......@@ -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);
......
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