Query enable switch added
This commit is contained in:
		@@ -48,6 +48,12 @@ String MqttConfig::exec(String params) {
 | 
				
			|||||||
    *out << "           about a minute" << endl;
 | 
					    *out << "           about a minute" << endl;
 | 
				
			||||||
    *out << endl;
 | 
					    *out << endl;
 | 
				
			||||||
    res = "done";
 | 
					    res = "done";
 | 
				
			||||||
 | 
					  } else if (params.equalsIgnoreCase("enable")) {
 | 
				
			||||||
 | 
					    mc->m_enabled = true;
 | 
				
			||||||
 | 
					    *out << "Query timers enabled" << endl;
 | 
				
			||||||
 | 
					  } else if (params.equalsIgnoreCase("disable")) {
 | 
				
			||||||
 | 
					    mc->m_enabled = false;
 | 
				
			||||||
 | 
					    *out << "Query timers disabled" << endl;
 | 
				
			||||||
  } else if (params.equalsIgnoreCase("show")) {
 | 
					  } else if (params.equalsIgnoreCase("show")) {
 | 
				
			||||||
    // show the whole configuration
 | 
					    // show the whole configuration
 | 
				
			||||||
    *out << "Clients:" << endl;
 | 
					    *out << "Clients:" << endl;
 | 
				
			||||||
@@ -190,7 +196,8 @@ Metro secondTick = Metro(1000);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
MqttClient::MqttClient(RequestSender *meterBusMaster) : m_mqttConfig(this),
 | 
					MqttClient::MqttClient(RequestSender *meterBusMaster) : m_mqttConfig(this),
 | 
				
			||||||
                m_client(), m_meterBusMaster(meterBusMaster), m_mqttClient(m_client),
 | 
					                m_client(), m_meterBusMaster(meterBusMaster), m_mqttClient(m_client),
 | 
				
			||||||
                m_disconnectState(3), m_disconnectTime(millis()), m_uptime(0), m_deviceIdx(0)
 | 
					                m_disconnectState(3), m_disconnectTime(millis()), m_uptime(0), m_deviceIdx(0),
 | 
				
			||||||
 | 
					                m_enabled(true)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -266,7 +273,6 @@ void MqttClient::begin(CmdServer *cmdServer) {
 | 
				
			|||||||
  configRead(CONFIG_DEVICES, sizeof(m_mbusDevTuple), (char*)m_mbusDevTuple);
 | 
					  configRead(CONFIG_DEVICES, sizeof(m_mbusDevTuple), (char*)m_mbusDevTuple);
 | 
				
			||||||
  configRead(CONFIG_BROKER, sizeof(m_mqttBroker), (char*)m_mqttBroker);
 | 
					  configRead(CONFIG_BROKER, sizeof(m_mqttBroker), (char*)m_mqttBroker);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  m_mqttClient = PubSubClient(m_mqttBroker, MQTT_PORT, callback, m_client);
 | 
					  m_mqttClient = PubSubClient(m_mqttBroker, MQTT_PORT, callback, m_client);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -333,6 +339,7 @@ void MqttClient::exec() {
 | 
				
			|||||||
      Serial << "no MQTT connection, message lost: " << msg << endl;
 | 
					      Serial << "no MQTT connection, message lost: " << msg << endl;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (m_enabled) {
 | 
				
			||||||
      for (uint8_t i = 0; i < NUM_OF_DEVICES; i++) {
 | 
					      for (uint8_t i = 0; i < NUM_OF_DEVICES; i++) {
 | 
				
			||||||
        if ((m_mbusDevTuple[i].address != 0) && (m_mbusDevTuple[i].timer != 0)) {
 | 
					        if ((m_mbusDevTuple[i].address != 0) && (m_mbusDevTuple[i].timer != 0)) {
 | 
				
			||||||
          m_mbusDevTuple[i].timer -= 1;
 | 
					          m_mbusDevTuple[i].timer -= 1;
 | 
				
			||||||
@@ -343,6 +350,9 @@ void MqttClient::exec() {
 | 
				
			|||||||
          //        }
 | 
					          //        }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      Serial << "Query timers disabled" << endl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //Serial << "while in" << endl;
 | 
					    //Serial << "while in" << endl;
 | 
				
			||||||
    while (true) {
 | 
					    while (true) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,6 +57,7 @@ private:
 | 
				
			|||||||
  uint32_t m_disconnectTime;
 | 
					  uint32_t m_disconnectTime;
 | 
				
			||||||
  uint32_t m_uptime;
 | 
					  uint32_t m_uptime;
 | 
				
			||||||
  uint8_t m_deviceIdx;
 | 
					  uint8_t m_deviceIdx;
 | 
				
			||||||
 | 
					  bool m_enabled;
 | 
				
			||||||
  mbusDevTuple_t m_mbusDevTuple[NUM_OF_DEVICES];
 | 
					  mbusDevTuple_t m_mbusDevTuple[NUM_OF_DEVICES];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								info.cpp
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								info.cpp
									
									
									
									
									
								
							@@ -16,7 +16,7 @@ String InfoCmd::exec(String params) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  *out << "Meterbus Hub" << endl;
 | 
					  *out << "Meterbus Hub" << endl;
 | 
				
			||||||
  *out << "Project/Repo: NetMeterBusMaster2" << endl;
 | 
					  *out << "Project/Repo: NetMeterBusMaster2" << endl;
 | 
				
			||||||
  *out << "Repo Tag: First_MQTT" << endl;
 | 
					  *out << "Repo Tag: Second_MQTT" << endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return "done";
 | 
					  return "done";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user