mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
general cleanup
This commit is contained in:
@@ -32,7 +32,6 @@ build_flags =
|
|||||||
-D ONEWIRE_CRC16=0
|
-D ONEWIRE_CRC16=0
|
||||||
-D NO_GLOBAL_ARDUINOOTA
|
-D NO_GLOBAL_ARDUINOOTA
|
||||||
-D ARDUINOJSON_ENABLE_STD_STRING=1
|
-D ARDUINOJSON_ENABLE_STD_STRING=1
|
||||||
-D PROGMEM_WWW
|
|
||||||
-D CORS_ORIGIN=\"http://localhost:3000\"
|
-D CORS_ORIGIN=\"http://localhost:3000\"
|
||||||
|
|
||||||
build_unflags = -Wall
|
build_unflags = -Wall
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ def buildWeb():
|
|||||||
wwwPath = Path("../data/www")
|
wwwPath = Path("../data/www")
|
||||||
if wwwPath.exists() and wwwPath.is_dir():
|
if wwwPath.exists() and wwwPath.is_dir():
|
||||||
rmtree(wwwPath)
|
rmtree(wwwPath)
|
||||||
if not flagExists("PROGMEM_WWW"):
|
|
||||||
print("Copying interface to data directory")
|
|
||||||
copytree(buildPath, wwwPath)
|
|
||||||
finally:
|
finally:
|
||||||
chdir("..")
|
chdir("..")
|
||||||
|
|
||||||
|
|||||||
@@ -39,57 +39,55 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
EMSESP::logger().info(F("WiFi Connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
EMSESP::logger().info(F("WiFi Connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Lower WiFi tx power to free up current for bus-powered
|
|
||||||
/*
|
/*
|
||||||
WIFI_POWER_19_5dBm = 78,// 19.5dBm <-- default
|
|
||||||
WIFI_POWER_19dBm = 76,// 19dBm
|
|
||||||
WIFI_POWER_18_5dBm = 74,// 18.5dBm
|
|
||||||
WIFI_POWER_17dBm = 68,// 17dBm
|
|
||||||
WIFI_POWER_15dBm = 60,// 15dBm
|
|
||||||
WIFI_POWER_13dBm = 52,// 13dBm
|
|
||||||
WIFI_POWER_11dBm = 44,// 11dBm
|
|
||||||
WIFI_POWER_8_5dBm = 34,// 8.5dBm
|
|
||||||
WIFI_POWER_7dBm = 28,// 7dBm
|
|
||||||
WIFI_POWER_5dBm = 20,// 5dBm
|
|
||||||
WIFI_POWER_2dBm = 8,// 2dBm
|
|
||||||
WIFI_POWER_MINUS_1dBm = -4// -1dBm
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
// Lower WiFi tx power to free up current for bus-powered
|
||||||
|
// WIFI_POWER_19_5dBm = 78,// 19.5dBm <-- default
|
||||||
|
// WIFI_POWER_19dBm = 76,// 19dBm
|
||||||
|
// WIFI_POWER_18_5dBm = 74,// 18.5dBm
|
||||||
|
// WIFI_POWER_17dBm = 68,// 17dBm
|
||||||
|
// WIFI_POWER_15dBm = 60,// 15dBm
|
||||||
|
// WIFI_POWER_13dBm = 52,// 13dBm
|
||||||
|
// WIFI_POWER_11dBm = 44,// 11dBm
|
||||||
|
// WIFI_POWER_8_5dBm = 34,// 8.5dBm
|
||||||
|
// WIFI_POWER_7dBm = 28,// 7dBm
|
||||||
|
// WIFI_POWER_5dBm = 20,// 5dBm
|
||||||
|
// WIFI_POWER_2dBm = 8,// 2dBm
|
||||||
|
// WIFI_POWER_MINUS_1dBm = -4// -1dBm
|
||||||
|
|
||||||
wifi_power_t a1 = WiFi.getTxPower();
|
wifi_power_t a1 = WiFi.getTxPower();
|
||||||
// bool ok = WiFi.setTxPower(WIFI_POWER_17dBm); // lower power
|
|
||||||
bool ok = WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
bool ok = WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
||||||
wifi_power_t a2 = WiFi.getTxPower();
|
wifi_power_t a2 = WiFi.getTxPower();
|
||||||
LOG_INFO("Adjusting Wifi Tx power from %d to %d (%s)", a1, a2, ok ? "ok" : "failed");
|
LOG_INFO("Adjusting Wifi Tx power from %d to %d (%s)", a1, a2, ok ? "ok" : "failed");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EMSESP::system_.init_network(); // send out heartbeat MQTT as soon as we have a connection
|
EMSESP::system_.network_init(); // send out heartbeat MQTT as soon as we have a connection
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_START:
|
case SYSTEM_EVENT_ETH_START:
|
||||||
EMSESP::logger().info(F("Ethernet Started"));
|
EMSESP::logger().info(F("Ethernet Started"));
|
||||||
ETH.setHostname(emsesp::System::hostname().c_str());
|
ETH.setHostname(EMSESP::system_.hostname().c_str());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||||
// prevent double calls
|
// prevent double calls
|
||||||
if (!System::ethernet_connected()) {
|
if (!EMSESP::system_.ethernet_connected()) {
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
EMSESP::logger().info(F("Ethernet Connected with IP=%s, speed %d Mbps"), ETH.localIP().toString().c_str(), ETH.linkSpeed());
|
EMSESP::logger().info(F("Ethernet Connected with IP=%s, speed %d Mbps"), ETH.localIP().toString().c_str(), ETH.linkSpeed());
|
||||||
#endif
|
#endif
|
||||||
EMSESP::system_.init_network(); // send out heartbeat MQTT as soon as we have a connection
|
EMSESP::system_.network_init(); // send out heartbeat MQTT as soon as we have a connection
|
||||||
System::ethernet_connected(true);
|
EMSESP::system_.ethernet_connected(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||||
EMSESP::logger().info(F("Ethernet Disconnected"));
|
EMSESP::logger().info(F("Ethernet Disconnected"));
|
||||||
System::ethernet_connected(false);
|
EMSESP::system_.ethernet_connected(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSTEM_EVENT_ETH_STOP:
|
case SYSTEM_EVENT_ETH_STOP:
|
||||||
EMSESP::logger().info(F("Ethernet Stopped"));
|
EMSESP::logger().info(F("Ethernet Stopped"));
|
||||||
System::ethernet_connected(false);
|
EMSESP::system_.ethernet_connected(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ void EMSESPShell::display_banner() {
|
|||||||
add_console_commands();
|
add_console_commands();
|
||||||
|
|
||||||
// turn off watch, unless is test mode
|
// turn off watch, unless is test mode
|
||||||
emsesp::EMSESP::watch_id(WATCH_ID_NONE);
|
EMSESP::watch_id(WATCH_ID_NONE);
|
||||||
#if defined(EMSESP_STANDALONE)
|
#if defined(EMSESP_STANDALONE)
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_ON);
|
EMSESP::watch(EMSESP::WATCH_ON);
|
||||||
#else
|
#else
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_OFF);
|
EMSESP::watch(EMSESP::WATCH_OFF);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,18 +266,18 @@ void EMSESPShell::add_console_commands() {
|
|||||||
if (!arguments.empty()) {
|
if (!arguments.empty()) {
|
||||||
// get raw/pretty
|
// get raw/pretty
|
||||||
if (arguments[0] == read_flash_string(F_(raw))) {
|
if (arguments[0] == read_flash_string(F_(raw))) {
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_RAW); // raw
|
EMSESP::watch(EMSESP::WATCH_RAW); // raw
|
||||||
} else if (arguments[0] == read_flash_string(F_(on))) {
|
} else if (arguments[0] == read_flash_string(F_(on))) {
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_ON); // on
|
EMSESP::watch(EMSESP::WATCH_ON); // on
|
||||||
} else if (arguments[0] == read_flash_string(F_(off))) {
|
} else if (arguments[0] == read_flash_string(F_(off))) {
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_OFF); // off
|
EMSESP::watch(EMSESP::WATCH_OFF); // off
|
||||||
} else if (arguments[0] == read_flash_string(F_(unknown))) {
|
} else if (arguments[0] == read_flash_string(F_(unknown))) {
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_UNKNOWN); // unknown
|
EMSESP::watch(EMSESP::WATCH_UNKNOWN); // unknown
|
||||||
watch_id = WATCH_ID_NONE;
|
watch_id = WATCH_ID_NONE;
|
||||||
} else {
|
} else {
|
||||||
watch_id = Helpers::hextoint(arguments[0].c_str());
|
watch_id = Helpers::hextoint(arguments[0].c_str());
|
||||||
if (watch_id && ((emsesp::EMSESP::watch() == EMSESP::WATCH_OFF) || (emsesp::EMSESP::watch() == EMSESP::WATCH_UNKNOWN))) {
|
if (watch_id && ((EMSESP::watch() == EMSESP::WATCH_OFF) || (EMSESP::watch() == EMSESP::WATCH_UNKNOWN))) {
|
||||||
emsesp::EMSESP::watch(EMSESP::WATCH_ON); // on
|
EMSESP::watch(EMSESP::WATCH_ON); // on
|
||||||
} else if (!watch_id) {
|
} else if (!watch_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,10 +288,10 @@ void EMSESPShell::add_console_commands() {
|
|||||||
watch_id = Helpers::hextoint(arguments[1].c_str());
|
watch_id = Helpers::hextoint(arguments[1].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
emsesp::EMSESP::watch_id(watch_id);
|
EMSESP::watch_id(watch_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t watch = emsesp::EMSESP::watch();
|
uint8_t watch = EMSESP::watch();
|
||||||
if (watch == EMSESP::WATCH_OFF) {
|
if (watch == EMSESP::WATCH_OFF) {
|
||||||
shell.printfln(F("Watching telegrams is off"));
|
shell.printfln(F("Watching telegrams is off"));
|
||||||
return;
|
return;
|
||||||
@@ -311,7 +311,7 @@ void EMSESPShell::add_console_commands() {
|
|||||||
shell.printfln(F("Watching unknown telegrams")); // WATCH_UNKNOWN
|
shell.printfln(F("Watching unknown telegrams")); // WATCH_UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
watch_id = emsesp::EMSESP::watch_id();
|
watch_id = EMSESP::watch_id();
|
||||||
if (watch_id > 0x80) {
|
if (watch_id > 0x80) {
|
||||||
shell.printfln(F("Filtering only telegrams that match a telegram type of 0x%02X"), watch_id);
|
shell.printfln(F("Filtering only telegrams that match a telegram type of 0x%02X"), watch_id);
|
||||||
} else if (watch_id != WATCH_ID_NONE) {
|
} else if (watch_id != WATCH_ID_NONE) {
|
||||||
@@ -637,7 +637,7 @@ void Console::start() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// turn watch off in case it was still set in the last session
|
// turn watch off in case it was still set in the last session
|
||||||
// emsesp::EMSESP::watch(EMSESP::WATCH_OFF);
|
// EMSESP::watch(EMSESP::WATCH_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles telnet sync and logging to console
|
// handles telnet sync and logging to console
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ class DallasSensor {
|
|||||||
static constexpr uint8_t CMD_CONVERT_TEMP = 0x44;
|
static constexpr uint8_t CMD_CONVERT_TEMP = 0x44;
|
||||||
static constexpr uint8_t CMD_READ_SCRATCHPAD = 0xBE;
|
static constexpr uint8_t CMD_READ_SCRATCHPAD = 0xBE;
|
||||||
|
|
||||||
static constexpr int8_t SCAN_START = -3;
|
static constexpr int8_t SCAN_START = -3;
|
||||||
static constexpr int8_t SCAN_MAX = 5;
|
static constexpr int8_t SCAN_MAX = 5;
|
||||||
|
|
||||||
static uuid::log::Logger logger_;
|
static uuid::log::Logger logger_;
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ WebAPIService EMSESP::webAPIService = WebAPIService(&webServer);
|
|||||||
using DeviceFlags = EMSdevice;
|
using DeviceFlags = EMSdevice;
|
||||||
using DeviceType = EMSdevice::DeviceType;
|
using DeviceType = EMSdevice::DeviceType;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<EMSdevice>> EMSESP::emsdevices; // array of all the detected EMS devices
|
std::vector<std::unique_ptr<EMSdevice>> EMSESP::emsdevices; // array of all the detected EMS devices
|
||||||
std::vector<emsesp::EMSESP::Device_record> EMSESP::device_library_; // library of all our known EMS devices, in heap
|
std::vector<EMSESP::Device_record> EMSESP::device_library_; // library of all our known EMS devices, in heap
|
||||||
|
|
||||||
uuid::log::Logger EMSESP::logger_{F_(emsesp), uuid::log::Facility::KERN};
|
uuid::log::Logger EMSESP::logger_{F_(emsesp), uuid::log::Facility::KERN};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef EMSESP_EMSESP_H
|
#ifndef EMSESP_EMSESP_H
|
||||||
#define EMSESP_EMSESP_H
|
#define EMSESP_EMSESP_H
|
||||||
|
|
||||||
@@ -35,6 +34,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ESP8266React.h>
|
#include <ESP8266React.h>
|
||||||
|
|
||||||
#include "WebStatusService.h"
|
#include "WebStatusService.h"
|
||||||
#include "WebDevicesService.h"
|
#include "WebDevicesService.h"
|
||||||
#include "WebSettingsService.h"
|
#include "WebSettingsService.h"
|
||||||
@@ -50,8 +50,7 @@
|
|||||||
#include "shower.h"
|
#include "shower.h"
|
||||||
#include "roomcontrol.h"
|
#include "roomcontrol.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
#include "version.h"
|
||||||
#include "devices/boiler.h"
|
|
||||||
|
|
||||||
#define WATCH_ID_NONE 0 // no watch id set
|
#define WATCH_ID_NONE 0 // no watch id set
|
||||||
|
|
||||||
|
|||||||
@@ -108,14 +108,14 @@ void Shower::send_mqtt_stat(bool state) {
|
|||||||
StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_HA_CONFIG> doc;
|
||||||
doc["name"] = FJSON("Shower Active");
|
doc["name"] = FJSON("Shower Active");
|
||||||
doc["uniq_id"] = FJSON("shower_active");
|
doc["uniq_id"] = FJSON("shower_active");
|
||||||
doc["~"] = System::hostname(); // default ems-esp
|
doc["~"] = EMSESP::system_.hostname(); // default ems-esp
|
||||||
doc["stat_t"] = FJSON("~/shower_active");
|
doc["stat_t"] = FJSON("~/shower_active");
|
||||||
JsonObject dev = doc.createNestedObject("dev");
|
JsonObject dev = doc.createNestedObject("dev");
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add("ems-esp");
|
ids.add("ems-esp");
|
||||||
|
|
||||||
char topic[100];
|
char topic[100];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/%s/shower_active/config"), System::hostname().c_str());
|
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/%s/shower_active/config"), EMSESP::system_.hostname().c_str());
|
||||||
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
Mqtt::publish_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
|||||||
Mqtt::dallas_format(1);
|
Mqtt::dallas_format(1);
|
||||||
Mqtt::ha_climate_format(1);
|
Mqtt::ha_climate_format(1);
|
||||||
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
|
EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS);
|
||||||
emsesp::EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw
|
EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw
|
||||||
|
|
||||||
std::string command(20, '\0');
|
std::string command(20, '\0');
|
||||||
if ((cmd.empty()) || (cmd == "default")) {
|
if ((cmd.empty()) || (cmd == "default")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user