try fix restart bad work, condition fonction removed
This commit is contained in:
parent
efa325b044
commit
80dac772f5
71
src/main.cpp
71
src/main.cpp
|
@ -39,11 +39,21 @@ NTPClient TimeClient(NtpUDP, "europe.pool.ntp.org", 7200, 60000);
|
|||
//-------------------- CONDITION --------------------//
|
||||
|
||||
|
||||
/**
|
||||
* @brief test if the time is good for restart or refresh memory
|
||||
*
|
||||
* @param hours
|
||||
* @param minutes
|
||||
* @param restart bool to choose which the restart time bool or the resfres time bool will be returned
|
||||
* @return true It's time to refresh or restart
|
||||
* @return false It's not the time to refresh or restart
|
||||
*/
|
||||
bool testTime (int hours, int minutes, bool restart){
|
||||
Serial.println('\n');
|
||||
Serial.println((REFRESHTIMES * TIME_TO_SLEEP) / 3600,DEC);
|
||||
Serial.println(((REFRESHTIMES * TIME_TO_SLEEP) % 3600) / 60,DEC);
|
||||
Serial.println('\n');
|
||||
// debug parts
|
||||
// Serial.println('\n');
|
||||
// Serial.println((REFRESHTIMES * TIME_TO_SLEEP) / 3600,DEC);
|
||||
// Serial.println(((REFRESHTIMES * TIME_TO_SLEEP) % 3600) / 60,DEC);
|
||||
// Serial.println('\n');
|
||||
|
||||
if (restart){ // restart parts
|
||||
if(hours < (RESTARTTIMES * TIME_TO_SLEEP) / 3600) return true;
|
||||
|
@ -65,59 +75,6 @@ bool testTime (int hours, int minutes, bool restart){
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Time hour for restart or time for refresh restart persistant mem
|
||||
*
|
||||
* @param hours
|
||||
* @param restart bool at true for restart or at false for resfresh memory
|
||||
* @return true right hour for restart or refresh
|
||||
* @return false bad hour for restart or refresh
|
||||
*/
|
||||
bool ishour(int hours, bool restart){
|
||||
if (restart){
|
||||
Serial.println('\n');
|
||||
Serial.println((RESTARTTIMES * TIME_TO_SLEEP) / 3600,DEC);
|
||||
Serial.println('\n');
|
||||
return hours <= (RESTARTTIMES * TIME_TO_SLEEP) / 3600;
|
||||
}
|
||||
// Then refresh time
|
||||
return (hours >= (RESTARTTIMES * TIME_TO_SLEEP) / 3600) && (hours <= (REFRESHTIMES * TIME_TO_SLEEP) / 3600);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Time minute for restart or time for refresh restart persistant mem
|
||||
*
|
||||
* @param minutes
|
||||
* @param restart bool at true for restart or at false for resfresh memory
|
||||
* @return true right minute for restart or refresh
|
||||
* @return false bad minute for restart or refresh
|
||||
*/
|
||||
bool isminute(int minutes, bool restart){
|
||||
if (restart){
|
||||
Serial.println(((RESTARTTIMES * TIME_TO_SLEEP) % 3600) / 60,DEC);
|
||||
Serial.println('\n');
|
||||
return minutes <= ((RESTARTTIMES * TIME_TO_SLEEP) % 3600) / 60;
|
||||
}
|
||||
// Then refresh time
|
||||
return (minutes >= ((RESTARTTIMES * TIME_TO_SLEEP) % 3600) / 60) && (minutes <= ((REFRESHTIMES * TIME_TO_SLEEP) % 3600) / 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Time seconde for restart or time for refresh restart persistant mem
|
||||
*
|
||||
* @param secondes
|
||||
* @param restart bool at true for restart or at false for resfresh memory
|
||||
* @return true right secondes for restart or refresh
|
||||
* @return false bad secondes for restart or refresh
|
||||
*/
|
||||
// bool issecond(int secondes, bool restart){
|
||||
// if (restart){
|
||||
// return secondes <= ((2 * TIME_TO_SLEEP) - 1 ) % 60;
|
||||
// }
|
||||
// // Then refresh time
|
||||
// return (secondes > ((2 * TIME_TO_SLEEP) - 1 ) % 60) && (secondes <= ((4 * TIME_TO_SLEEP) - 1 ) % 60);
|
||||
// }
|
||||
|
||||
//-------------------- FONCTIONS --------------------//
|
||||
|
||||
//-------------- Connexion MQTT --------------//
|
||||
|
|
Loading…
Reference in a new issue