From 8d6777d2cd56b35f2681a6a6e2411a201b8152a8 Mon Sep 17 00:00:00 2001 From: fredlcore Date: Thu, 16 Nov 2023 15:39:52 +0800 Subject: [PATCH] Added script to regularly send date and time to heater --- .../Send_NTP_time_to_heater/BSB_LAN_custom.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 BSB_LAN/custom_functions/Send_NTP_time_to_heater/BSB_LAN_custom.h diff --git a/BSB_LAN/custom_functions/Send_NTP_time_to_heater/BSB_LAN_custom.h b/BSB_LAN/custom_functions/Send_NTP_time_to_heater/BSB_LAN_custom.h new file mode 100644 index 00000000..47c93d10 --- /dev/null +++ b/BSB_LAN/custom_functions/Send_NTP_time_to_heater/BSB_LAN_custom.h @@ -0,0 +1,17 @@ +/* + * This script sends the current time and date to the heater every 10 minutes. + * For this to make sense, you must have the USE_NTP definement enabled in BSB_LAN_config.h, in addition to the CUSTOM_COMMANDS definement. + * Works only on ESP32-based microcontrollers, not (yet) Arduino Due! +*/ +#if defined(ESP32) +if (custom_timer > custom_timer_compare+600000) { // every 10 minutes + custom_timer_compare = millis(); + char date_string[20]; + struct tm now; + getLocalTime(&now,100); + sprintf_P(date_string,PSTR("%02d.%02d.%d_%02d:%02d:%02d"), now.tm_mday, now.tm_mon + 1, now.tm_year + 1900, now.tm_hour,now.tm_min,now.tm_sec); + if (now.tm_year > 100 && now.tm_hour > 4) { // only send time after 04:00 in case that day the heater changes time because of daylight saving + set(0,date_string,1); + } +} +#endif