some fixes

This commit is contained in:
hg
2015-05-10 18:32:11 +02:00
parent 424d9d2a6e
commit 4e84527a4f
2 changed files with 11 additions and 10 deletions

View File

@ -13,7 +13,7 @@
#include <Metro.h>
byte MQTT_BROKER[] = { 192, 168, 75, 1 };
byte MQTT_BROKER[] = { 172, 16, 2, 16 };
const uint16_t MQTT_PORT = 1883;
@ -67,7 +67,7 @@ void MqttClient::sendResponse(uint8_t *responseBuffer, uint16_t responseBufferLe
if (m_disconnectState == 0) {
//Serial << "publishing " << strbuf << endl;
//Serial << "length: " << buf.length() << endl;
m_mqttClient.publish("MeterbusHub.Measurement", strbuf);
m_mqttClient.publish("MeterbusHub/Measurement", strbuf);
} else {
Serial << "no MQTT connection, message lost: " << endl <<
strbuf << endl;
@ -80,7 +80,7 @@ void MqttClient::sendError(uint8_t code, uint8_t token) {
if (m_disconnectState == 0) {
//Serial << "publishing " << msg << 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 {
Serial << "no MQTT connection, message lost: " << msg << endl;
}
@ -119,6 +119,7 @@ void MqttClient::exec() {
m_disconnectTime = millis();
m_disconnectState = 0;
} else {
Serial << "no success" << endl;
m_disconnectState = 1;
}
break;
@ -132,12 +133,12 @@ void MqttClient::exec() {
m_uptime++;
//Serial << "Tick " << m_uptime << endl;
// String msg = String("{ \"metadata\": { \"device\": \"MeterbusHub\" }, \"data\": { \"uptime\": ") + m_uptime + String("}}");
// if (m_disconnectState == 0) {
// m_mqttClient.publish("MeterbusHub.Heartbeat", (char*)msg.c_str());
// } else {
// Serial << "no MQTT connection, message lost: " << msg << endl;
// }
String msg = String("{ \"metadata\": { \"device\": \"MeterbusHub\" }, \"data\": { \"uptime\": ") + m_uptime + String("}}");
if (m_disconnectState == 0) {
m_mqttClient.publish("MeterbusHub/Heartbeat", (char*)msg.c_str());
} else {
Serial << "no MQTT connection, message lost: " << msg << endl;
}
for (uint8_t i = 0; i < NUM_OF_DEVICES; i++) {
if ((m_mbusDevTuple[i].address != 0) && (m_mbusDevTuple[i].timer != 0)) {

View File

@ -173,7 +173,7 @@ void MeterBusMaster::prepareResponse(bool err, uint8_t in) {
static int16_t expectedChars = -1;
static uint8_t state = 0;
//Serial << "r1" << endl;
//Serial << "r0" << endl;
if (err) {
//Serial << "r1" << endl;
if (m_responseCallback != 0) {