mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 01:09:51 +03:00
merge with txmode2 branch
This commit is contained in:
@@ -35,6 +35,8 @@ MyESP::MyESP() {
|
||||
_general_hostname = strdup("myesp");
|
||||
_app_name = strdup("MyESP");
|
||||
_app_version = strdup(MYESP_VERSION);
|
||||
_app_helpurl = nullptr;
|
||||
_app_updateurl = nullptr;
|
||||
|
||||
// general
|
||||
_timerequest = false;
|
||||
@@ -633,6 +635,7 @@ void MyESP::_printSetCommands() {
|
||||
myDebug_P(PSTR(" set <wifi_ssid | wifi_password> [value]"));
|
||||
myDebug_P(PSTR(" set mqtt_enabled <on | off>"));
|
||||
myDebug_P(PSTR(" set <mqtt_ip | mqtt_username | mqtt_password> [value]"));
|
||||
myDebug_P(PSTR(" set mqtt_heartbeat <on | off>"));
|
||||
myDebug_P(PSTR(" set mqtt_base [value]"));
|
||||
myDebug_P(PSTR(" set mqtt_port [value]"));
|
||||
myDebug_P(PSTR(" set ntp_enabled <on | off>"));
|
||||
@@ -687,9 +690,9 @@ void MyESP::_printSetCommands() {
|
||||
myDebug_P(PSTR(" mqtt_base="));
|
||||
}
|
||||
myDebug_P(PSTR(" mqtt_port=%d"), _mqtt_port);
|
||||
myDebug_P(PSTR(" mqtt_heartbeat=%s"), (_mqtt_heartbeat) ? "on" : "off");
|
||||
|
||||
myDebug_P(PSTR(" serial=%s"), (_general_serial) ? "on" : "off");
|
||||
myDebug_P(PSTR(" heartbeat=%s"), (_mqtt_heartbeat) ? "on" : "off");
|
||||
myDebug_P(PSTR(" ntp_enabled=%s"), (_ntp_enabled) ? "on" : "off");
|
||||
|
||||
// print any custom settings
|
||||
@@ -825,7 +828,7 @@ bool MyESP::_changeSetting(uint8_t wc, const char * setting, const char * value)
|
||||
}
|
||||
}
|
||||
|
||||
} else if (strcmp(setting, "heartbeat") == 0) {
|
||||
} else if (strcmp(setting, "mqtt_heartbeat") == 0) {
|
||||
save_config = true;
|
||||
if (value) {
|
||||
if (strcmp(value, "on") == 0) {
|
||||
@@ -2362,8 +2365,8 @@ void MyESP::_sendStatus() {
|
||||
|
||||
char uptime[200];
|
||||
uint32_t t = _getUptime(); // seconds
|
||||
uint32_t d = t / 86400L;
|
||||
uint32_t h = ((t % 86400L) / 3600L) % 60;
|
||||
uint8_t d = t / 86400L;
|
||||
uint8_t h = ((t % 86400L) / 3600L) % 60;
|
||||
uint32_t rem = t % 3600L;
|
||||
uint8_t m = rem / 60;
|
||||
uint8_t sec = rem % 60;
|
||||
|
||||
@@ -33,12 +33,6 @@ time_t now() {
|
||||
return (time_t)sysTime;
|
||||
}
|
||||
|
||||
// indicates if time has been set and recently synchronized
|
||||
timeStatus_t timeStatus() {
|
||||
now(); // required to actually update the status
|
||||
return Status;
|
||||
}
|
||||
|
||||
void setSyncProvider(getExternalTime getTimeFunction) {
|
||||
getTimePtr = getTimeFunction;
|
||||
nextSyncTime = sysTime;
|
||||
@@ -103,37 +97,6 @@ void breakTime(time_t timeInput, tmElements_t & tm) {
|
||||
tm.Day = time + 1; // day of month
|
||||
}
|
||||
|
||||
time_t makeTime(const tmElements_t & tm) {
|
||||
// assemble time elements into time_t
|
||||
// note year argument is offset from 1970 (see macros in time.h to convert to other formats)
|
||||
// previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9
|
||||
|
||||
int i;
|
||||
uint32_t seconds;
|
||||
|
||||
// seconds from 1970 till 1 jan 00:00:00 of the given year
|
||||
seconds = tm.Year * (SECS_PER_DAY * 365);
|
||||
for (i = 0; i < tm.Year; i++) {
|
||||
if (LEAP_YEAR(i)) {
|
||||
seconds += SECS_PER_DAY; // add extra days for leap years
|
||||
}
|
||||
}
|
||||
|
||||
// add days for this year, months start from 1
|
||||
for (i = 1; i < tm.Month; i++) {
|
||||
if ((i == 2) && LEAP_YEAR(tm.Year)) {
|
||||
seconds += SECS_PER_DAY * 29;
|
||||
} else {
|
||||
seconds += SECS_PER_DAY * monthDays[i - 1]; //monthDay array starts from 0
|
||||
}
|
||||
}
|
||||
seconds += (tm.Day - 1) * SECS_PER_DAY;
|
||||
seconds += tm.Hour * SECS_PER_HOUR;
|
||||
seconds += tm.Minute * SECS_PER_MIN;
|
||||
seconds += tm.Second;
|
||||
return (time_t)seconds;
|
||||
}
|
||||
|
||||
void refreshCache(time_t t) {
|
||||
if (t != cacheTime) {
|
||||
breakTime(t, tm);
|
||||
@@ -166,11 +129,6 @@ int hour(time_t t) { // the hour for the given time
|
||||
return tm.Hour;
|
||||
}
|
||||
|
||||
int weekday(time_t t) {
|
||||
refreshCache(t);
|
||||
return tm.Wday;
|
||||
}
|
||||
|
||||
int year(time_t t) { // the year for the given time
|
||||
refreshCache(t);
|
||||
return tmYearToCalendar(tm.Year);
|
||||
|
||||
22
src/ems.cpp
22
src/ems.cpp
@@ -726,9 +726,6 @@ void ems_dumpBuffer(const char * prefix, uint8_t * telegram, uint8_t length) {
|
||||
static char output_str[200] = {0};
|
||||
static char buffer[16] = {0};
|
||||
|
||||
if (EMS_Sys_Status.emsLogging != EMS_SYS_LOGGING_JABBER)
|
||||
return;
|
||||
|
||||
/*
|
||||
// we only care about known devices
|
||||
if (length) {
|
||||
@@ -779,14 +776,9 @@ void ems_dumpBuffer(const char * prefix, uint8_t * telegram, uint8_t length) {
|
||||
* When a telegram is processed we forcefully erase it from the stack to prevent overflow
|
||||
*/
|
||||
void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
||||
static uint32_t _last_emsPollFrequency = 0;
|
||||
|
||||
ems_dumpBuffer("ems_parseTelegram: ", telegram, length);
|
||||
/*
|
||||
* check if we just received a single byte
|
||||
* it could well be a Poll request from the boiler for us, which will have a value of 0x8B (0x0B | 0x80)
|
||||
* or either a return code like 0x01 or 0x04 from the last Write command
|
||||
*/
|
||||
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_JABBER) {
|
||||
ems_dumpBuffer("ems_parseTelegram: ", telegram, length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect the EMS bus type - Buderus or Junkers - and set emsIDMask accordingly.
|
||||
@@ -812,8 +804,14 @@ void ems_parseTelegram(uint8_t * telegram, uint8_t length) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* check if we just received a single byte
|
||||
* it could well be a Poll request from the boiler for us, which will have a value of 0x8B (0x0B | 0x80)
|
||||
* or either a return code like 0x01 or 0x04 from the last Write command
|
||||
*/
|
||||
if (length == 1) {
|
||||
uint8_t value = telegram[0]; // 1st byte of data package
|
||||
uint8_t value = telegram[0]; // 1st byte of data package
|
||||
static uint32_t _last_emsPollFrequency = 0;
|
||||
|
||||
// check first for a Poll for us
|
||||
if ((value ^ 0x80 ^ EMS_Sys_Status.emsIDMask) == EMS_ID_ME) {
|
||||
|
||||
@@ -167,7 +167,6 @@ typedef struct {
|
||||
bool emsTxCapable; // able to send via Tx
|
||||
bool emsTxDisabled; // true to prevent all Tx
|
||||
uint8_t txRetryCount; // # times the last Tx was re-sent
|
||||
uint8_t emsTxMode; // handles Tx logic
|
||||
uint8_t emsIDMask; // Buderus: 0x00, Junkers: 0x80
|
||||
uint8_t emsPollAck[1]; // acknowledge buffer
|
||||
} _EMS_Sys_Status;
|
||||
@@ -409,7 +408,6 @@ void ems_testTelegram(uint8_t test_num);
|
||||
void ems_startupTelegrams();
|
||||
bool ems_checkEMSBUSAlive();
|
||||
void ems_clearDeviceList();
|
||||
void ems_setTxMode(uint8_t mode);
|
||||
|
||||
void ems_setThermostatTemp(float temperature, uint8_t temptype = 0);
|
||||
void ems_setThermostatMode(uint8_t mode);
|
||||
@@ -425,7 +423,6 @@ void ems_setWarmWaterModeComfort(uint8_t comfort);
|
||||
void ems_setModels();
|
||||
void ems_setTxDisabled(bool b);
|
||||
bool ems_getTxDisabled();
|
||||
uint8_t ems_getTxMode();
|
||||
|
||||
char * ems_getThermostatDescription(char * buffer, bool name_only = false);
|
||||
char * ems_getBoilerDescription(char * buffer, bool name_only = false);
|
||||
|
||||
@@ -175,7 +175,11 @@ void ICACHE_FLASH_ATTR emsuart_start() {
|
||||
*/
|
||||
_EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
||||
_EMS_TX_STATUS result = EMS_TX_STATUS_OK;
|
||||
ems_dumpBuffer("emsuart_tx_buffer: ", buf, len); // validate and transmit the EMS buffer, excluding the BRK
|
||||
|
||||
if (EMS_Sys_Status.emsLogging == EMS_SYS_LOGGING_JABBER) {
|
||||
ems_dumpBuffer("emsuart_tx_buffer: ", buf, len); // validate and transmit the EMS buffer, excluding the BRK
|
||||
}
|
||||
|
||||
if (len) {
|
||||
LA_PULSE(50);
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user