mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-04-28 21:08:15 +00:00
Some changes
This commit is contained in:
@@ -62,7 +62,7 @@ Timezone* tz;
|
|||||||
AmsWebServer ws(&Debug, &hw);
|
AmsWebServer ws(&Debug, &hw);
|
||||||
|
|
||||||
MQTTClient *mqtt = NULL;
|
MQTTClient *mqtt = NULL;
|
||||||
WiFiClient *mqttClient = NULL;
|
WiFiClient *mqttClient = new WiFiClient();
|
||||||
WiFiClientSecure *mqttSecureClient = NULL;
|
WiFiClientSecure *mqttSecureClient = NULL;
|
||||||
AmsMqttHandler* mqttHandler = NULL;
|
AmsMqttHandler* mqttHandler = NULL;
|
||||||
|
|
||||||
@@ -72,7 +72,6 @@ SoftwareSerial *swSerial = NULL;
|
|||||||
GpioConfig gpioConfig;
|
GpioConfig gpioConfig;
|
||||||
MeterConfig meterConfig;
|
MeterConfig meterConfig;
|
||||||
bool mqttEnabled = false;
|
bool mqttEnabled = false;
|
||||||
uint8_t payloadFormat = 0;
|
|
||||||
String topic = "ams";
|
String topic = "ams";
|
||||||
AmsData meterState;
|
AmsData meterState;
|
||||||
bool ntpEnabled = false;
|
bool ntpEnabled = false;
|
||||||
@@ -920,7 +919,6 @@ void MQTT_connect() {
|
|||||||
|
|
||||||
mqttEnabled = true;
|
mqttEnabled = true;
|
||||||
ws.setMqttEnabled(true);
|
ws.setMqttEnabled(true);
|
||||||
payloadFormat = mqttConfig.payloadFormat;
|
|
||||||
topic = String(mqttConfig.publishTopic);
|
topic = String(mqttConfig.publishTopic);
|
||||||
|
|
||||||
if(mqttHandler != NULL) {
|
if(mqttHandler != NULL) {
|
||||||
@@ -1002,6 +1000,7 @@ void MQTT_connect() {
|
|||||||
if(Debug.isActive(RemoteDebug::INFO)) {
|
if(Debug.isActive(RemoteDebug::INFO)) {
|
||||||
debugI("Connecting to MQTT %s:%d", mqttConfig.host, mqttConfig.port);
|
debugI("Connecting to MQTT %s:%d", mqttConfig.host, mqttConfig.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
mqtt->begin(mqttConfig.host, mqttConfig.port, *mqttClient);
|
mqtt->begin(mqttConfig.host, mqttConfig.port, *mqttClient);
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ bool JsonMqttHandler::publishTemperatures(AmsConfiguration* config, HwTools* hw)
|
|||||||
bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
|
bool JsonMqttHandler::publishPrices(EntsoeApi* eapi) {
|
||||||
if(topic.isEmpty() || !mqtt->connected())
|
if(topic.isEmpty() || !mqtt->connected())
|
||||||
return false;
|
return false;
|
||||||
if(strcmp(eapi->getToken(), "") == 0)
|
if(strlen(eapi->getToken()) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user