mirror of https://github.com/arendst/Tasmota.git
Add serial receive poll during sleep
Add serial receive poll during sleep for tuya and serial bridge
This commit is contained in:
parent
b7f6a7b00a
commit
6f00b455e7
|
@ -378,7 +378,7 @@ enum LightTypes { LT_BASIC, LT_PWM1, LT_PWM2, LT_PWM3, LT_PWM4, LT
|
|||
LT_NU8, LT_SERIAL1, LT_SERIAL2, LT_RGB, LT_RGBW, LT_RGBWC, LT_NU14, LT_NU15 }; // Do not insert new fields
|
||||
|
||||
enum XsnsFunctions {FUNC_SETTINGS_OVERRIDE, FUNC_PIN_STATE, FUNC_I2C_INIT, FUNC_MODULE_INIT, FUNC_PRE_INIT, FUNC_INIT,
|
||||
FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_100_MSECOND, FUNC_EVERY_200_MSECOND, FUNC_EVERY_250_MSECOND, FUNC_EVERY_SECOND,
|
||||
FUNC_LOOP, FUNC_SLEEP_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_100_MSECOND, FUNC_EVERY_200_MSECOND, FUNC_EVERY_250_MSECOND, FUNC_EVERY_SECOND,
|
||||
FUNC_SAVE_SETTINGS, FUNC_SAVE_AT_MIDNIGHT, FUNC_SAVE_BEFORE_RESTART,
|
||||
FUNC_AFTER_TELEPERIOD, FUNC_JSON_APPEND, FUNC_WEB_SENSOR, FUNC_WEB_COL_SENSOR, FUNC_COMMAND, FUNC_COMMAND_SENSOR, FUNC_COMMAND_DRIVER,
|
||||
FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA,
|
||||
|
|
|
@ -619,8 +619,7 @@ void setup(void) {
|
|||
}
|
||||
#endif // USE_BERRY
|
||||
|
||||
XdrvCall(FUNC_PRE_INIT);
|
||||
XsnsCall(FUNC_PRE_INIT);
|
||||
XdrvXsnsCall(FUNC_PRE_INIT);
|
||||
|
||||
TasmotaGlobal.init_state = INIT_GPIOS;
|
||||
|
||||
|
@ -638,8 +637,7 @@ void setup(void) {
|
|||
ArduinoOTAInit();
|
||||
#endif // USE_ARDUINO_OTA
|
||||
|
||||
XdrvCall(FUNC_INIT);
|
||||
XsnsCall(FUNC_INIT);
|
||||
XdrvXsnsCall(FUNC_INIT);
|
||||
#ifdef USE_SCRIPT
|
||||
if (bitRead(Settings->rule_enabled, 0)) Run_Scripter(">BS",3,0);
|
||||
#endif
|
||||
|
@ -684,6 +682,7 @@ void SleepDelay(uint32_t mseconds) {
|
|||
if (!TasmotaGlobal.backlog_nodelay && mseconds) {
|
||||
uint32_t wait = millis() + mseconds;
|
||||
while (!TimeReached(wait) && !Serial.available() && !TasmotaGlobal.skip_sleep) { // We need to service serial buffer ASAP as otherwise we get uart buffer overrun
|
||||
XdrvCall(FUNC_SLEEP_LOOP);
|
||||
delay(1);
|
||||
}
|
||||
} else {
|
||||
|
@ -692,8 +691,7 @@ void SleepDelay(uint32_t mseconds) {
|
|||
}
|
||||
|
||||
void Scheduler(void) {
|
||||
XdrvCall(FUNC_LOOP);
|
||||
XsnsCall(FUNC_LOOP);
|
||||
XdrvXsnsCall(FUNC_LOOP);
|
||||
|
||||
// check LEAmDNS.h
|
||||
// MDNS.update() needs to be called in main loop
|
||||
|
@ -721,32 +719,28 @@ void Scheduler(void) {
|
|||
#ifdef ROTARY_V1
|
||||
RotaryHandler();
|
||||
#endif // ROTARY_V1
|
||||
XdrvCall(FUNC_EVERY_50_MSECOND);
|
||||
XsnsCall(FUNC_EVERY_50_MSECOND);
|
||||
XdrvXsnsCall(FUNC_EVERY_50_MSECOND);
|
||||
}
|
||||
|
||||
static uint32_t state_100msecond = 0; // State 100msecond timer
|
||||
if (TimeReached(state_100msecond)) {
|
||||
SetNextTimeInterval(state_100msecond, 100);
|
||||
Every100mSeconds();
|
||||
XdrvCall(FUNC_EVERY_100_MSECOND);
|
||||
XsnsCall(FUNC_EVERY_100_MSECOND);
|
||||
XdrvXsnsCall(FUNC_EVERY_100_MSECOND);
|
||||
}
|
||||
|
||||
static uint32_t state_250msecond = 0; // State 250msecond timer
|
||||
if (TimeReached(state_250msecond)) {
|
||||
SetNextTimeInterval(state_250msecond, 250);
|
||||
Every250mSeconds();
|
||||
XdrvCall(FUNC_EVERY_250_MSECOND);
|
||||
XsnsCall(FUNC_EVERY_250_MSECOND);
|
||||
XdrvXsnsCall(FUNC_EVERY_250_MSECOND);
|
||||
}
|
||||
|
||||
static uint32_t state_second = 0; // State second timer
|
||||
if (TimeReached(state_second)) {
|
||||
SetNextTimeInterval(state_second, 1000);
|
||||
PerformEverySecond();
|
||||
XdrvCall(FUNC_EVERY_SECOND);
|
||||
XsnsCall(FUNC_EVERY_SECOND);
|
||||
XdrvXsnsCall(FUNC_EVERY_SECOND);
|
||||
}
|
||||
|
||||
if (!TasmotaGlobal.serial_local) { SerialInput(); }
|
||||
|
|
|
@ -367,8 +367,7 @@ void SettingsSaveAll(void) {
|
|||
} else {
|
||||
Settings->power = 0;
|
||||
}
|
||||
XsnsCall(FUNC_SAVE_BEFORE_RESTART);
|
||||
XdrvCall(FUNC_SAVE_BEFORE_RESTART);
|
||||
XsnsXdrvCall(FUNC_SAVE_BEFORE_RESTART);
|
||||
SettingsSave(0);
|
||||
}
|
||||
|
||||
|
@ -603,8 +602,7 @@ void SettingsSave(uint8_t rotate) {
|
|||
* stop_flash_rotate 1 = Allow only eeprom flash slot use (SetOption12 1)
|
||||
*/
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
XsnsCall(FUNC_SAVE_SETTINGS);
|
||||
XdrvCall(FUNC_SAVE_SETTINGS);
|
||||
XsnsXdrvCall(FUNC_SAVE_SETTINGS);
|
||||
UpdateBackwardCompatibility();
|
||||
if ((GetSettingsCrc32() != settings_crc32) || rotate) {
|
||||
if (1 == rotate) { // Use eeprom flash slot only and disable flash rotate from now on (upgrade)
|
||||
|
|
|
@ -221,6 +221,16 @@ void ZeroCrossInit(uint32_t offset) {
|
|||
|
||||
/********************************************************************************************/
|
||||
|
||||
void XdrvXsnsCall(uint32_t function) {
|
||||
XdrvCall(function);
|
||||
XsnsCall(function);
|
||||
}
|
||||
|
||||
void XsnsXdrvCall(uint32_t function) {
|
||||
XsnsCall(function);
|
||||
XdrvCall(function);
|
||||
}
|
||||
|
||||
void SetLatchingRelay(power_t lpower, uint32_t state) {
|
||||
// TasmotaGlobal.power xx00 - toggle REL1 (Off) and REL3 (Off) - device 1 Off, device 2 Off
|
||||
// TasmotaGlobal.power xx01 - toggle REL2 (On) and REL3 (Off) - device 1 On, device 2 Off
|
||||
|
@ -276,8 +286,7 @@ void SetDevicePower(power_t rpower, uint32_t source) {
|
|||
}
|
||||
|
||||
XdrvMailbox.index = rpower;
|
||||
XdrvCall(FUNC_SET_POWER); // Signal power state
|
||||
XsnsCall(FUNC_SET_POWER); // Signal power state
|
||||
XdrvXsnsCall(FUNC_SET_POWER); // Signal power state
|
||||
|
||||
XdrvMailbox.index = rpower;
|
||||
XdrvMailbox.payload = source;
|
||||
|
@ -889,8 +898,7 @@ void GetSensorValues(void) {
|
|||
char *start = ResponseData();
|
||||
int data_start = ResponseLength();
|
||||
|
||||
XsnsCall(FUNC_JSON_APPEND);
|
||||
XdrvCall(FUNC_JSON_APPEND);
|
||||
XsnsXdrvCall(FUNC_JSON_APPEND);
|
||||
|
||||
if (data_start == ResponseLength()) { return; }
|
||||
|
||||
|
@ -1137,8 +1145,7 @@ void PerformEverySecond(void)
|
|||
MqttPublishTeleState();
|
||||
MqttPublishTeleperiodSensor();
|
||||
|
||||
XsnsCall(FUNC_AFTER_TELEPERIOD);
|
||||
XdrvCall(FUNC_AFTER_TELEPERIOD);
|
||||
XsnsXdrvCall(FUNC_AFTER_TELEPERIOD);
|
||||
} else {
|
||||
// Global values (Temperature, Humidity and Pressure) update every 10 seconds
|
||||
if (!(TasmotaGlobal.tele_period % 10)) {
|
||||
|
|
|
@ -597,8 +597,7 @@ void StartWebserver(int type, IPAddress ipweb)
|
|||
// Webserver->on(F("/u2"), HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call
|
||||
Webserver->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
XdrvCall(FUNC_WEB_ADD_HANDLER);
|
||||
XsnsCall(FUNC_WEB_ADD_HANDLER);
|
||||
XdrvXsnsCall(FUNC_WEB_ADD_HANDLER);
|
||||
#endif // Not FIRMWARE_MINIMAL
|
||||
|
||||
if (!Web.initial_config) {
|
||||
|
@ -1085,8 +1084,7 @@ uint32_t WebUseManagementSubmenu(void) {
|
|||
|
||||
if (!management_count) {
|
||||
XdrvMailbox.index = 1;
|
||||
XdrvCall(FUNC_WEB_ADD_CONSOLE_BUTTON);
|
||||
XsnsCall(FUNC_WEB_ADD_CONSOLE_BUTTON);
|
||||
XdrvXsnsCall(FUNC_WEB_ADD_CONSOLE_BUTTON);
|
||||
XdrvCall(FUNC_WEB_ADD_MANAGEMENT_BUTTON);
|
||||
management_count = XdrvMailbox.index;
|
||||
}
|
||||
|
@ -1288,8 +1286,7 @@ void HandleRoot(void)
|
|||
}
|
||||
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
XdrvCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
||||
XsnsCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
||||
XdrvXsnsCall(FUNC_WEB_ADD_MAIN_BUTTON);
|
||||
#endif // Not FIRMWARE_MINIMAL
|
||||
|
||||
if (HTTP_ADMIN == Web.state) {
|
||||
|
@ -1442,8 +1439,7 @@ bool HandleRootStatusRefresh(void)
|
|||
}
|
||||
#endif // USE_ZIGBEE
|
||||
|
||||
XsnsCall(FUNC_WEB_GET_ARG);
|
||||
XdrvCall(FUNC_WEB_GET_ARG);
|
||||
XsnsXdrvCall(FUNC_WEB_GET_ARG);
|
||||
|
||||
#ifdef USE_WEB_SSE
|
||||
WSContentBegin(200, CT_STREAM);
|
||||
|
@ -1455,8 +1451,7 @@ bool HandleRootStatusRefresh(void)
|
|||
if (Settings->web_time_end) {
|
||||
WSContentSend_P(PSTR("{s}" D_TIMER_TIME "{m}%s{e}"), GetDateAndTime(DT_LOCAL).substring(Settings->web_time_start, Settings->web_time_end).c_str());
|
||||
}
|
||||
XsnsCall(FUNC_WEB_SENSOR);
|
||||
XdrvCall(FUNC_WEB_SENSOR);
|
||||
XsnsXdrvCall(FUNC_WEB_SENSOR);
|
||||
|
||||
WSContentSend_P(PSTR("</table>"));
|
||||
|
||||
|
@ -1522,8 +1517,7 @@ void HandleConfiguration(void)
|
|||
WSContentButton(BUTTON_MODULE);
|
||||
WSContentButton(BUTTON_WIFI);
|
||||
|
||||
XdrvCall(FUNC_WEB_ADD_BUTTON);
|
||||
XsnsCall(FUNC_WEB_ADD_BUTTON);
|
||||
XdrvXsnsCall(FUNC_WEB_ADD_BUTTON);
|
||||
|
||||
WSContentButton(BUTTON_LOGGING);
|
||||
WSContentButton(BUTTON_OTHER);
|
||||
|
@ -3106,8 +3100,7 @@ void HandleManagement(void)
|
|||
WSContentButton(BUTTON_CONSOLE);
|
||||
|
||||
XdrvMailbox.index = 0;
|
||||
XdrvCall(FUNC_WEB_ADD_CONSOLE_BUTTON);
|
||||
XsnsCall(FUNC_WEB_ADD_CONSOLE_BUTTON);
|
||||
XdrvXsnsCall(FUNC_WEB_ADD_CONSOLE_BUTTON);
|
||||
|
||||
WSContentSend_P(PSTR("<div></div>")); // 5px padding
|
||||
XdrvCall(FUNC_WEB_ADD_MANAGEMENT_BUTTON);
|
||||
|
|
|
@ -293,6 +293,7 @@ bool Xdrv08(uint8_t function) {
|
|||
else if (serial_bridge_buffer) {
|
||||
switch (function) {
|
||||
case FUNC_LOOP:
|
||||
case FUNC_SLEEP_LOOP:
|
||||
SerialBridgeInput();
|
||||
break;
|
||||
case FUNC_COMMAND:
|
||||
|
|
|
@ -1566,6 +1566,7 @@ bool Xdrv16(uint8_t function) {
|
|||
else if (Tuya.active) {
|
||||
switch (function) {
|
||||
case FUNC_LOOP:
|
||||
case FUNC_SLEEP_LOOP:
|
||||
if (TuyaSerial) { TuyaSerialInput(); }
|
||||
break;
|
||||
case FUNC_PRE_INIT:
|
||||
|
|
|
@ -334,8 +334,7 @@ void TM1621Init(void) {
|
|||
uint32_t TM1621GetSensors(bool refresh) {
|
||||
if (refresh) {
|
||||
ResponseClear();
|
||||
XsnsCall(FUNC_JSON_APPEND);
|
||||
XdrvCall(FUNC_JSON_APPEND);
|
||||
XsnsXdrvCall(FUNC_JSON_APPEND);
|
||||
ResponseJsonStart(); // Overwrite first comma
|
||||
ResponseJsonEnd(); // Append }
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TM1: Sensors %s"), ResponseData());
|
||||
|
|
Loading…
Reference in New Issue