Change command Time 1/2/3 for legacy reason

Change command Time 1/2/3 to select JSON time format ISO, ISO + Epoch or Epoch for legacy reason
This commit is contained in:
Theo Arends 2019-09-06 15:46:40 +02:00
parent 1d4fac0128
commit 2fa583392a
3 changed files with 6 additions and 5 deletions

View File

@ -2,6 +2,7 @@
* 6.6.0.10 20190905
* Redesign Tuya support by Shantur Rathore (#6353)
* Add command Reset 99 to reset bootcount to zero (#684, #6351)
* Change command Time 1/2/3 to select JSON time format ISO, ISO + Epoch or Epoch for legacy reason
*
* 6.6.0.9 20190828
* Change theoretical baudrate range to 300..19660500 bps in 300 increments (#6294)

View File

@ -876,13 +876,13 @@ char* ResponseGetTime(uint32_t format, char* time_str)
{
switch (format) {
case 1:
snprintf_P(time_str, TIMESZ, PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
snprintf_P(time_str, TIMESZ, PSTR("{\"" D_JSON_TIME "\":\"%s\",\"Epoch\":%u"), GetDateAndTime(DT_LOCAL).c_str(), UtcTime());
break;
case 2:
snprintf_P(time_str, TIMESZ, PSTR("{\"" D_JSON_TIME "\":%u"), UtcTime());
break;
default:
snprintf_P(time_str, TIMESZ, PSTR("{\"" D_JSON_TIME "\":\"%s\",\"Epoch\":%u"), GetDateAndTime(DT_LOCAL).c_str(), UtcTime());
snprintf_P(time_str, TIMESZ, PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
}
return time_str;
}

View File

@ -1271,8 +1271,8 @@ void CmndReset(void)
void CmndTime(void)
{
// payload 0 = (re-)enable NTP
// payload 1 = Time format {"Time":"2019-09-04T14:31:29","Epoch":1567600289}
// payload 2 = Time format {"Time":"2019-09-04T14:31:29"}
// payload 1 = Time format {"Time":"2019-09-04T14:31:29"}
// payload 2 = Time format {"Time":"2019-09-04T14:31:29","Epoch":1567600289}
// payload 3 = Time format {"Time":1567600289}
// payload 4 = reserved
// payload 1451602800 - disable NTP and set time to epoch
@ -1283,7 +1283,7 @@ void CmndTime(void)
Settings.flag2.time_format = XdrvMailbox.payload -1;
format = Settings.flag2.time_format;
} else {
format = 0; // {"Time":"2019-09-04T14:31:29","Epoch":1567600289}
format = 1; // {"Time":"2019-09-04T14:31:29","Epoch":1567600289}
RtcSetTime(XdrvMailbox.payload);
}
}