# HG changeset patch # User William Welliver # Date 1688833282 14400 # Sat Jul 08 12:21:22 2023 -0400 # Node ID 79dbbdaec31cfd1178a54831d7b127e0ff05fd4b # Parent 4505692abb795053136668bd690aa6ddb17e59a4 don't use buffered string, which was causing extraneous zero length packets to be transmitted. diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -103,7 +103,7 @@ // FUNCTIONS WiFiUDP ntpUdp; -NTPClient timeClient(ntpUdp); +NTPClient timeClient(ntpUdp, "192.168.5.155"); //MQTT PubSubClient MQTTClient(wifiClient); @@ -632,7 +632,7 @@ Serial.begin(115200); DEBUG("Startup"); - +//resetEverything(); //Set up software serial at 104 baud to read from AC pinMode(BUS_TX, OUTPUT); @@ -750,12 +750,12 @@ lastReport = tsm; #ifdef WANT_NTP ts = timeClient.getEpochTime(); +Serial.println(timeClient.getFormattedTime()); #endif /* WANT_NTP */ // always send the hub message StaticJsonDocument<220> doc; - WriteBufferingStream bufferedFile{udp, 64}; doc["serial_number"] = hubsn; doc["type"] = "hub_status"; @@ -765,14 +765,12 @@ doc["timestamp"] = ts; udp.beginPacket(br_adr, SMARTWEATHER_PORT); - serializeJson(doc, bufferedFile); - bufferedFile.flush(); + serializeJson(doc, udp); udp.endPacket(); reportcnt++; if (sensorPresent) { StaticJsonDocument<220> doc; - WriteBufferingStream bufferedFile{udp, 64}; doc["serial_number"] = airsn; doc["hub_sn"] = hubsn; doc["type"] = "device_status"; @@ -784,8 +782,7 @@ doc["timestamp"] = ts; udp.beginPacket(br_adr, SMARTWEATHER_PORT); - serializeJson(doc, bufferedFile); - bufferedFile.flush(); + serializeJson(doc, udp); udp.endPacket(); } }