From 40d7ec3846121e766820cd20584cf915dec68739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Tue, 2 Jan 2024 12:27:16 +0100 Subject: [PATCH 1/3] Simple Weather Service : Fix timestamp In the documentation, specify that the timestamp is expressed in seconds from epoch (instead of nanoseconds). SimpleWeatherService now uses "localtime" (GetCurrentDateTime()) instead of UTC time. --- doc/SimpleWeatherService.md | 4 ++-- src/components/ble/SimpleWeatherService.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/SimpleWeatherService.md b/doc/SimpleWeatherService.md index 8183637939..68a009b372 100644 --- a/doc/SimpleWeatherService.md +++ b/doc/SimpleWeatherService.md @@ -28,7 +28,7 @@ The byte array must contain the following data: - [0] : Message type = `0` - [1] : Message version = `0` - - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of nanoseconds elapsed since 1 JAN 1970) + - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) - [10, 11] : Current temperature (°C * 100) - [12, 13] : Minimum temperature (°C * 100) - [14, 15] : Maximum temperature (°C * 100) @@ -50,7 +50,7 @@ The byte array must contain the following data: - [0] : Message type = `0` - [1] : Message version = `0` - - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of nanoseconds elapsed since 1 JAN 1970) + - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) - [10] Number of days (Max 5, fields for unused days should be set to `0`) - [11,12] Day 0 Minimum temperature (°C * 100) - [13,14] Day 0 Maximum temperature (°C * 100) diff --git a/src/components/ble/SimpleWeatherService.cpp b/src/components/ble/SimpleWeatherService.cpp index 886bf65939..d545d45b7c 100644 --- a/src/components/ble/SimpleWeatherService.cpp +++ b/src/components/ble/SimpleWeatherService.cpp @@ -127,7 +127,7 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) { std::optional SimpleWeatherService::Current() const { if (currentWeather) { - auto currentTime = dateTimeController.UTCDateTime().time_since_epoch(); + auto currentTime = dateTimeController.CurrentDateTime().time_since_epoch(); auto weatherTpSecond = std::chrono::seconds {currentWeather->timestamp}; auto weatherTp = std::chrono::duration_cast(weatherTpSecond); auto delta = currentTime - weatherTp; @@ -141,7 +141,7 @@ std::optional SimpleWeatherService::Curren std::optional SimpleWeatherService::GetForecast() const { if (forecast) { - auto currentTime = dateTimeController.UTCDateTime().time_since_epoch(); + auto currentTime = dateTimeController.CurrentDateTime().time_since_epoch(); auto weatherTpSecond = std::chrono::seconds {forecast->timestamp}; auto weatherTp = std::chrono::duration_cast(weatherTpSecond); auto delta = currentTime - weatherTp; From f5f986e83372566b5de2861427c6c840a8b095b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Tue, 2 Jan 2024 18:06:44 +0100 Subject: [PATCH 2/3] Simple Weather Service : Fix timestamp Mention that the timestamp should be expressed in localtime time. --- doc/SimpleWeatherService.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/SimpleWeatherService.md b/doc/SimpleWeatherService.md index 68a009b372..9df606cc18 100644 --- a/doc/SimpleWeatherService.md +++ b/doc/SimpleWeatherService.md @@ -28,7 +28,7 @@ The byte array must contain the following data: - [0] : Message type = `0` - [1] : Message version = `0` - - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) + - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) in local time (the same timezone than the one used to set the time) - [10, 11] : Current temperature (°C * 100) - [12, 13] : Minimum temperature (°C * 100) - [14, 15] : Maximum temperature (°C * 100) @@ -50,7 +50,7 @@ The byte array must contain the following data: - [0] : Message type = `0` - [1] : Message version = `0` - - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) + - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) in local time (the same timezone than the one used to set the time) - [10] Number of days (Max 5, fields for unused days should be set to `0`) - [11,12] Day 0 Minimum temperature (°C * 100) - [13,14] Day 0 Maximum temperature (°C * 100) From e77b051ac705c2902933892ba8ffe5fd83c0482d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Thu, 4 Jan 2024 12:56:22 +0100 Subject: [PATCH 3/3] Simple Weather Service : Fix timestamp Wording improvements in doc. Co-authored-by: Reinhold Gschweicher --- doc/SimpleWeatherService.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/SimpleWeatherService.md b/doc/SimpleWeatherService.md index 9df606cc18..5f95ee67ab 100644 --- a/doc/SimpleWeatherService.md +++ b/doc/SimpleWeatherService.md @@ -28,7 +28,7 @@ The byte array must contain the following data: - [0] : Message type = `0` - [1] : Message version = `0` - - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) in local time (the same timezone than the one used to set the time) + - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) in local time (the same timezone as the one used to set the time) - [10, 11] : Current temperature (°C * 100) - [12, 13] : Minimum temperature (°C * 100) - [14, 15] : Maximum temperature (°C * 100) @@ -50,7 +50,7 @@ The byte array must contain the following data: - [0] : Message type = `0` - [1] : Message version = `0` - - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) in local time (the same timezone than the one used to set the time) + - [2][3][4][5][6][7][8][9] : Timestamp (64 bits UNIX timestamp, number of seconds elapsed since 1 JAN 1970) in local time (the same timezone as the one used to set the time) - [10] Number of days (Max 5, fields for unused days should be set to `0`) - [11,12] Day 0 Minimum temperature (°C * 100) - [13,14] Day 0 Maximum temperature (°C * 100)