Now it compiles.
This commit is contained in:
parent
096cf070b2
commit
d513fce941
@ -1,3 +1,10 @@
|
|||||||
|
char * Concatenate(char *first, char *second) {
|
||||||
|
static char buf[30];
|
||||||
|
strcpy(buf,first);
|
||||||
|
strcat(buf,second);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectMQTT() {
|
void ConnectMQTT() {
|
||||||
Serial.println("connecting MQTT...");
|
Serial.println("connecting MQTT...");
|
||||||
while (!mqtt_client.connect("brewhouse", MQTT_USER, MQTT_PASSWORD)) {
|
while (!mqtt_client.connect("brewhouse", MQTT_USER, MQTT_PASSWORD)) {
|
||||||
@ -7,8 +14,7 @@ void ConnectMQTT() {
|
|||||||
|
|
||||||
Serial.println("\nconnected!");
|
Serial.println("\nconnected!");
|
||||||
|
|
||||||
String topic = TOPIC_PREFIX + BKTOPIC;
|
mqtt_client.subscribe(Concatenate(TOPIC_PREFIX, BKTOPIC));
|
||||||
mqtt_client.subscribe(topic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageReceived(String &topic, String &payload) {
|
void MessageReceived(String &topic, String &payload) {
|
||||||
@ -27,9 +33,7 @@ void MessageReceived(String &topic, String &payload) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String subscribed = TOPIC_PREFIX + BKTOPIC;
|
if (topic == Concatenate(TOPIC_PREFIX, BKTOPIC)) {
|
||||||
|
|
||||||
if (topic == subscribed) {
|
|
||||||
// Update PWM setpoint.
|
// Update PWM setpoint.
|
||||||
String name = doc["entity"];
|
String name = doc["entity"];
|
||||||
String setting = doc["setpoint"];
|
String setting = doc["setpoint"];
|
||||||
@ -41,7 +45,7 @@ void MessageReceived(String &topic, String &payload) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupMQTT(String broker) {
|
void SetupMQTT(char *broker) {
|
||||||
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
|
// Note: Local domain names (e.g. "Computer.local" on OSX) are not supported
|
||||||
// by Arduino. You need to set the IP address directly.
|
// by Arduino. You need to set the IP address directly.
|
||||||
Serial.println("Setup MQTT client.");
|
Serial.println("Setup MQTT client.");
|
||||||
@ -64,9 +68,6 @@ static void SendSensorData() {
|
|||||||
String jstr;
|
String jstr;
|
||||||
serializeJson(doc, jstr);
|
serializeJson(doc, jstr);
|
||||||
|
|
||||||
String topic = TOPIC_PREFIX;
|
mqtt_client.publish(Concatenate(TOPIC_PREFIX, "sensor/boil_kettle"), jstr);
|
||||||
topic += "sensor/boil_kettle";
|
|
||||||
|
|
||||||
mqtt_client.publish(topic, jstr);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user