some fixes
This commit is contained in:
@ -13,7 +13,7 @@
|
|||||||
#include <Metro.h>
|
#include <Metro.h>
|
||||||
|
|
||||||
|
|
||||||
byte MQTT_BROKER[] = { 192, 168, 75, 1 };
|
byte MQTT_BROKER[] = { 172, 16, 2, 16 };
|
||||||
const uint16_t MQTT_PORT = 1883;
|
const uint16_t MQTT_PORT = 1883;
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ void MqttClient::sendResponse(uint8_t *responseBuffer, uint16_t responseBufferLe
|
|||||||
if (m_disconnectState == 0) {
|
if (m_disconnectState == 0) {
|
||||||
//Serial << "publishing " << strbuf << endl;
|
//Serial << "publishing " << strbuf << endl;
|
||||||
//Serial << "length: " << buf.length() << endl;
|
//Serial << "length: " << buf.length() << endl;
|
||||||
m_mqttClient.publish("MeterbusHub.Measurement", strbuf);
|
m_mqttClient.publish("MeterbusHub/Measurement", strbuf);
|
||||||
} else {
|
} else {
|
||||||
Serial << "no MQTT connection, message lost: " << endl <<
|
Serial << "no MQTT connection, message lost: " << endl <<
|
||||||
strbuf << endl;
|
strbuf << endl;
|
||||||
@ -80,7 +80,7 @@ void MqttClient::sendError(uint8_t code, uint8_t token) {
|
|||||||
if (m_disconnectState == 0) {
|
if (m_disconnectState == 0) {
|
||||||
//Serial << "publishing " << msg << endl;
|
//Serial << "publishing " << msg << endl;
|
||||||
//Serial << "length: " << msg.length() << endl;
|
//Serial << "length: " << msg.length() << endl;
|
||||||
m_mqttClient.publish("MeterbusHub.Measurement", (char*)msg.c_str());
|
m_mqttClient.publish("MeterbusHub/Measurement", (char*)msg.c_str());
|
||||||
} else {
|
} else {
|
||||||
Serial << "no MQTT connection, message lost: " << msg << endl;
|
Serial << "no MQTT connection, message lost: " << msg << endl;
|
||||||
}
|
}
|
||||||
@ -119,6 +119,7 @@ void MqttClient::exec() {
|
|||||||
m_disconnectTime = millis();
|
m_disconnectTime = millis();
|
||||||
m_disconnectState = 0;
|
m_disconnectState = 0;
|
||||||
} else {
|
} else {
|
||||||
|
Serial << "no success" << endl;
|
||||||
m_disconnectState = 1;
|
m_disconnectState = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -132,12 +133,12 @@ void MqttClient::exec() {
|
|||||||
m_uptime++;
|
m_uptime++;
|
||||||
//Serial << "Tick " << m_uptime << endl;
|
//Serial << "Tick " << m_uptime << endl;
|
||||||
|
|
||||||
// String msg = String("{ \"metadata\": { \"device\": \"MeterbusHub\" }, \"data\": { \"uptime\": ") + m_uptime + String("}}");
|
String msg = String("{ \"metadata\": { \"device\": \"MeterbusHub\" }, \"data\": { \"uptime\": ") + m_uptime + String("}}");
|
||||||
// if (m_disconnectState == 0) {
|
if (m_disconnectState == 0) {
|
||||||
// m_mqttClient.publish("MeterbusHub.Heartbeat", (char*)msg.c_str());
|
m_mqttClient.publish("MeterbusHub/Heartbeat", (char*)msg.c_str());
|
||||||
// } else {
|
} else {
|
||||||
// Serial << "no MQTT connection, message lost: " << msg << endl;
|
Serial << "no MQTT connection, message lost: " << msg << endl;
|
||||||
// }
|
}
|
||||||
|
|
||||||
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)) {
|
||||||
|
@ -173,7 +173,7 @@ void MeterBusMaster::prepareResponse(bool err, uint8_t in) {
|
|||||||
static int16_t expectedChars = -1;
|
static int16_t expectedChars = -1;
|
||||||
static uint8_t state = 0;
|
static uint8_t state = 0;
|
||||||
|
|
||||||
//Serial << "r1" << endl;
|
//Serial << "r0" << endl;
|
||||||
if (err) {
|
if (err) {
|
||||||
//Serial << "r1" << endl;
|
//Serial << "r1" << endl;
|
||||||
if (m_responseCallback != 0) {
|
if (m_responseCallback != 0) {
|
||||||
|
Reference in New Issue
Block a user