Tune some functionality

Tune some functionality
This commit is contained in:
Theo Arends 2019-03-30 13:03:45 +01:00
parent d9bd959119
commit eb9617e3f9
10 changed files with 30 additions and 35 deletions

View File

@ -2355,7 +2355,7 @@ bool Xdrv01(uint8_t function)
case FUNC_LOOP:
PollDnsWebserver();
#ifdef USE_EMULATION
if (Settings.flag2.emulation) PollUdp();
if (Settings.flag2.emulation) { PollUdp(); }
#endif // USE_EMULATION
break;
case FUNC_COMMAND:

View File

@ -50,7 +50,6 @@ bool mqtt_allowed = false; // MQTT enabled and parameters valid
* void MqttDisconnect()
* void MqttSubscribeLib(char *topic)
* bool MqttPublishLib(const char* topic, bool retained)
* void MqttLoop()
\*********************************************************************************************/
#include <PubSubClient.h>
@ -91,11 +90,6 @@ bool MqttPublishLib(const char* topic, bool retained)
return result;
}
void MqttLoop(void)
{
MqttClient.loop();
}
/*********************************************************************************************/
#ifdef USE_DISCOVERY
@ -425,7 +419,8 @@ void MqttReconnect(void)
UdpDisconnect();
#endif // USE_EMULATION
AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_ATTEMPTING_CONNECTION));
// AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_ATTEMPTING_CONNECTION));
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "(%d) " D_ATTEMPTING_CONNECTION), ESP.getFreeHeap()/1024);
mqtt_connected = false;
mqtt_retry_counter = Settings.mqtt_retry;
@ -816,6 +811,9 @@ bool Xdrv02(uint8_t function)
if (Settings.flag.mqtt_enabled) {
switch (function) {
case FUNC_LOOP:
if (MqttIsConnected()) { MqttClient.loop(); }
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_ADD_BUTTON:
WSContentSend_P(HTTP_BTN_MENU_MQTT);
@ -824,9 +822,6 @@ bool Xdrv02(uint8_t function)
WebServer->on("/" WEB_HANDLE_MQTT, HandleMqttConfiguration);
break;
#endif // USE_WEBSERVER
case FUNC_LOOP:
if (!global_state.mqtt_down) { MqttLoop(); }
break;
case FUNC_COMMAND:
result = MqttCommand();
break;

View File

@ -689,15 +689,15 @@ bool Xdrv03(uint8_t function)
}
else if (energy_flg) {
switch (function) {
case FUNC_LOOP:
XnrgCall(FUNC_LOOP);
break;
case FUNC_COMMAND:
result = EnergyCommand();
break;
case FUNC_SET_POWER:
EnergySetPowerSteadyCounter();
break;
case FUNC_LOOP:
XnrgCall(FUNC_LOOP);
break;
case FUNC_SERIAL:
result = XnrgCall(FUNC_SERIAL);
break;

View File

@ -172,12 +172,12 @@ bool Xdrv08(uint8_t function)
if (serial_bridge_active) {
switch (function) {
case FUNC_PRE_INIT:
SerialBridgeInit();
break;
case FUNC_LOOP:
if (SerialBridgeSerial) { SerialBridgeInput(); }
break;
case FUNC_PRE_INIT:
SerialBridgeInit();
break;
case FUNC_COMMAND:
result = SerialBridgeCommand();
break;

View File

@ -1223,6 +1223,9 @@ bool Xdrv11(uint8_t function)
{
bool result = false;
switch (function) {
case FUNC_LOOP:
if (!global_state.wifi_down) { knx.loop(); } // Process knx events
break;
case FUNC_PRE_INIT:
KNX_INIT();
break;
@ -1236,9 +1239,6 @@ bool Xdrv11(uint8_t function)
break;
#endif // USE_KNX_WEB_MENU
#endif // USE_WEBSERVER
case FUNC_LOOP:
if (!global_state.wifi_down) { knx.loop(); } // Process knx events
break;
case FUNC_EVERY_50_MSECOND:
if (toggle_inhibit) {
toggle_inhibit--;

View File

@ -393,15 +393,15 @@ bool Xdrv16(uint8_t function)
if (TUYA_DIMMER == my_module_type) {
switch (function) {
case FUNC_LOOP:
if (TuyaSerial) { TuyaSerialInput(); }
break;
case FUNC_MODULE_INIT:
result = TuyaModuleSelected();
break;
case FUNC_INIT:
TuyaInit();
break;
case FUNC_LOOP:
if (TuyaSerial) { TuyaSerialInput(); }
break;
case FUNC_SET_DEVICE_POWER:
result = TuyaSetPower();
break;

View File

@ -170,15 +170,15 @@ bool Xdrv18(uint8_t function)
if (ARMTRONIX_DIMMERS == my_module_type) {
switch (function) {
case FUNC_LOOP:
if (ArmtronixSerial) { ArmtronixSerialInput(); }
break;
case FUNC_MODULE_INIT:
result = ArmtronixModuleSelected();
break;
case FUNC_INIT:
ArmtronixInit();
break;
case FUNC_LOOP:
if (ArmtronixSerial) { ArmtronixSerialInput(); }
break;
case FUNC_EVERY_SECOND:
if (ArmtronixSerial) {
if (armtronix_wifi_state!=WifiState()) { ArmtronixSetWifiLed(); }

View File

@ -223,15 +223,15 @@ bool Xdrv19(uint8_t function)
if (PS_16_DZ == my_module_type) {
switch (function) {
case FUNC_LOOP:
if (PS16DZSerial) { PS16DZSerialInput(); }
break;
case FUNC_MODULE_INIT:
result = PS16DZModuleSelected();
break;
case FUNC_INIT:
PS16DZInit();
break;
case FUNC_LOOP:
if (PS16DZSerial) { PS16DZSerialInput(); }
break;
case FUNC_SET_DEVICE_POWER:
result = PS16DZSetPower();
break;

View File

@ -497,12 +497,12 @@ bool Xdrv99(uint8_t function)
bool result = false;
switch (function) {
case FUNC_PRE_INIT:
CPU_last_millis = millis();
break;
case FUNC_LOOP:
CpuLoadLoop();
break;
case FUNC_PRE_INIT:
CPU_last_millis = millis();
break;
case FUNC_COMMAND:
result = DebugCommand();
break;

View File

@ -652,12 +652,12 @@ int Xnrg04(uint8_t function)
}
else if (XNRG_04 == energy_flg) {
switch (function) {
case FUNC_INIT:
McpSnsInit();
break;
case FUNC_LOOP:
if (McpSerial) { McpSerialInput(); }
break;
case FUNC_INIT:
McpSnsInit();
break;
case FUNC_EVERY_SECOND:
if (McpSerial) { McpEverySecond(); }
break;