|
@ -71,7 +71,7 @@ uint32_t lastTransmit = 0; |
|
|
|
|
|
|
|
|
//Variables for the mqtt packages and topics
|
|
|
//Variables for the mqtt packages and topics
|
|
|
String commandTopic; |
|
|
String commandTopic; |
|
|
String bme280Topic; |
|
|
String weatherTopic; |
|
|
String statusTopic; |
|
|
String statusTopic; |
|
|
|
|
|
|
|
|
void setup() { |
|
|
void setup() { |
|
@ -89,7 +89,7 @@ void setup() { |
|
|
|
|
|
|
|
|
//Configure the MQTT topics
|
|
|
//Configure the MQTT topics
|
|
|
commandTopic = "esp32-node/cmd/" + iot.hostname + "/play"; |
|
|
commandTopic = "esp32-node/cmd/" + iot.hostname + "/play"; |
|
|
bme280Topic = "esp32-node/stat/" + iot.hostname + "/bme280"; |
|
|
weatherTopic = "esp32-node/stat/" + iot.hostname + "/weather"; |
|
|
statusTopic = "esp32-node/stat/" + iot.hostname + "/status"; |
|
|
statusTopic = "esp32-node/stat/" + iot.hostname + "/status"; |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
@ -246,11 +246,10 @@ void transmitStatus() { |
|
|
root["temperature"] = internal_temp; |
|
|
root["temperature"] = internal_temp; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
char sensorBuf[root.measureLength()+1]; |
|
|
char weatherBuf[root.measureLength()+1]; |
|
|
root.printTo(sensorBuf, sizeof(sensorBuf)); |
|
|
root.printTo(weatherBuf, sizeof(weatherBuf)); |
|
|
uint16_t statusPacketIdSub; |
|
|
uint16_t statusPacketIdSub; |
|
|
statusPacketIdSub = iot.mqtt.publish(bme280Topic.c_str(), 0, false, sensorBuf); |
|
|
statusPacketIdSub = iot.mqtt.publish(weatherTopic.c_str(), 0, false, weatherBuf); |
|
|
// statusPacketIdSub = iot.mqtt.publish(bme280Topic.c_str(), 1, true, sensorBuf);
|
|
|
|
|
|
|
|
|
|
|
|
StaticJsonBuffer<200> jsonBuffer2; |
|
|
StaticJsonBuffer<200> jsonBuffer2; |
|
|
JsonObject& root2 = jsonBuffer2.createObject(); |
|
|
JsonObject& root2 = jsonBuffer2.createObject(); |
|
@ -258,7 +257,7 @@ void transmitStatus() { |
|
|
root2["rssi"] = WiFi.RSSI(); |
|
|
root2["rssi"] = WiFi.RSSI(); |
|
|
root2["heap"] = ESP.getFreeHeap(); |
|
|
root2["heap"] = ESP.getFreeHeap(); |
|
|
char statusBuf[root2.measureLength()+1]; |
|
|
char statusBuf[root2.measureLength()+1]; |
|
|
root2.printTo(sensorBuf, sizeof(sensorBuf)); |
|
|
root2.printTo(statusBuf, sizeof(statusBuf)); |
|
|
statusPacketIdSub = iot.mqtt.publish(statusTopic.c_str(), 0, false, statusBuf); |
|
|
statusPacketIdSub = iot.mqtt.publish(statusTopic.c_str(), 0, false, statusBuf); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|