diff --git a/include/main.h b/include/main.h index 2345d36..aaefad8 100644 --- a/include/main.h +++ b/include/main.h @@ -15,7 +15,7 @@ #include #include -#define TOPIC "test-alex" +#define TOPIC "prod" #define MQTT_ADDRESS "185.233.103.24" #define MQTT_PORT 1883 #define ESPNAME "esp32-bastien" diff --git a/src/main.cpp b/src/main.cpp index ad3ceb1..a323a9a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,8 +35,8 @@ WiFiUDP NtpUDP; * * @param 7200: jet lag europe time from France (2 * 3600 sec) */ -NTPClient TimeClient(NtpUDP, "europe.pool.ntp.org" , 7200 , 60000); -//NTPClient TimeClient(NtpUDP, "pool.ntp.org"); +//NTPClient TimeClient(NtpUDP, "europe.pool.ntp.org" , 7200 , 60000); // ancienne configuration +NTPClient TimeClient(NtpUDP, "europe.pool.ntp.org"); //-------------------- CONDITION --------------------// @@ -369,6 +369,7 @@ void setup() TimeClient.begin(); + TimeClient.update(); //int rawtime = (TimeClient.getEpochTime()) % 86400; // 86400 = 60sec*60minutes*24heures unsigned long rawtime = getTime(); @@ -424,7 +425,7 @@ void loop() writeMessage(msg, temp, hum, SENSORS_NUMBER); TimeClient.update(); - TimeClient.getFormattedTime().toCharArray(time, 30); + //TimeClient.getFormattedTime().toCharArray(time, 30); //tie(year, month, day) = getDate(); @@ -439,36 +440,8 @@ void loop() now = getTime(); - //TimeClient.update(); - //Serial.println(TimeClient.getFormattedTime()); - //Solution to the issue generated by the Ntpclient for the horodatage midnight at two o'clock - // if (time[0] == '0' && (time[1] == '0' || time[1] == '1')){ - // if (day == 31){ - // if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){ - // day = 1; - // month++; - // if(month == 13){ - // month == 1; - // year++; - // } - // } - // }else if (day == 30){ - // if(month == 4 || month == 6 || month == 9 || month == 11){ - // day = 1; - // month++; - // } - // }else if(day == 29){ - // if(month == 2){ - // day = 1; - // month++; - // } - // }else{ - // day++; - // } - // } - - lenght = sprintf(date,"%s|", ultoa(now, date, 10) /* "|%d-%d-%d ", year, month, day */); + lenght = sprintf(date,"%s", ultoa(now, date, 10) /* "|%d-%d-%d ", year, month, day */); sprintf(date + lenght, time); sprintf(date + strlen(date), msg); MqttClient.publish(TOPIC, date);