mirror of
https://gitlab.com/wirelos/sprocket-plugin-mqtt.git
synced 2025-12-18 07:16:39 +01:00
hardcode in/out topics, add chat example
This commit is contained in:
@@ -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;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user