hardcode in/out topics, add chat example

This commit is contained in:
2018-11-19 20:31:34 +01:00
parent e1d605c615
commit a195307fc1
6 changed files with 157 additions and 31 deletions

View File

@@ -6,7 +6,7 @@
#define JSON_MQTT_CLIENT_NAME "mqttClientName"
#define JSON_MQTT_BROKER_HOST "mqttBrokerHost"
#define JSON_MQTT_BROKER_PORT "mqttBrokerPort"
#define JSON_MQTT_IN_TOPIC_ROOT "mqttInTopicRoot"
#define JSON_MQTT_TOPIC_ROOT "mqttTopicRoot"
#define JSON_MQTT_OUT_TOPIC_ROOT "mqttOutTopicRoot"
struct MqttConfig
@@ -14,8 +14,7 @@ struct MqttConfig
const char *clientName;
const char *brokerHost;
int brokerPort;
const char *inTopicRoot;
const char *outTopicRoot;
const char *topicRoot;
};
struct MqttConfigJson : public MqttConfig, public JsonStruct
@@ -25,8 +24,7 @@ struct MqttConfigJson : public MqttConfig, public JsonStruct
root[JSON_MQTT_CLIENT_NAME] = clientName;
root[JSON_MQTT_BROKER_HOST] = brokerHost;
root[JSON_MQTT_BROKER_PORT] = brokerPort;
root[JSON_MQTT_IN_TOPIC_ROOT] = inTopicRoot;
root[JSON_MQTT_OUT_TOPIC_ROOT] = outTopicRoot;
root[JSON_MQTT_TOPIC_ROOT] = topicRoot;
}
void fromJsonObject(JsonObject &json)
{
@@ -39,8 +37,7 @@ struct MqttConfigJson : public MqttConfig, public JsonStruct
clientName = getAttr(json, JSON_MQTT_CLIENT_NAME);
brokerHost = getAttr(json, JSON_MQTT_BROKER_HOST);
brokerPort = getIntAttrFromJson(json, JSON_MQTT_BROKER_PORT);
inTopicRoot = getAttr(json, JSON_MQTT_IN_TOPIC_ROOT);
outTopicRoot = getAttr(json, JSON_MQTT_OUT_TOPIC_ROOT);
topicRoot = getAttr(json, JSON_MQTT_TOPIC_ROOT);
valid = 1;
};
};