aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ble/SimpleWeatherService.h
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2023-12-23 15:54:23 +0100
committerJF <JF002@users.noreply.github.com>2023-12-23 21:12:25 +0100
commitef2c43156928b659d02a4ac9412ee947d0cc4d27 (patch)
treea588c9b835d6cb4fb0c09c67746a78920224e283 /src/components/ble/SimpleWeatherService.h
parent199aefc617b8e655ad5edf97a0e6b00285512993 (diff)
Simple Weather Service
Code improvements : icon fields are now typed as Icons, move the location string when creating a new instance of CurrentWeather, fix SimpleWeatherService::CurrentWeather::operator== (location was missing from the comparison).
Diffstat (limited to 'src/components/ble/SimpleWeatherService.h')
-rw-r--r--src/components/ble/SimpleWeatherService.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/components/ble/SimpleWeatherService.h b/src/components/ble/SimpleWeatherService.h
index 890497d7..561917eb 100644
--- a/src/components/ble/SimpleWeatherService.h
+++ b/src/components/ble/SimpleWeatherService.h
@@ -61,20 +61,20 @@ namespace Pinetime {
Unknown = 255
};
+ using Location = std::array<char, 33>; // 32 char + \0 (end of string)
struct CurrentWeather {
CurrentWeather(uint64_t timestamp,
uint8_t temperature,
uint8_t minTemperature,
uint8_t maxTemperature,
- uint8_t iconId,
- const char* location)
+ Icons iconId,
+ Location&& location)
: timestamp {timestamp},
temperature {temperature},
minTemperature {minTemperature},
maxTemperature {maxTemperature},
- iconId {iconId} {
- std::memcpy(this->location, location, 32);
- this->location[32] = 0;
+ iconId {iconId},
+ location{std::move(location)} {
}
uint64_t timestamp;
@@ -82,7 +82,7 @@ namespace Pinetime {
uint8_t minTemperature;
uint8_t maxTemperature;
Icons iconId;
- char location[33]; // 32 char + \0 (end of string)
+ Location location;
bool operator==(const CurrentWeather& other) const;
};
@@ -94,7 +94,7 @@ namespace Pinetime {
struct Day {
uint8_t minTemperature;
uint8_t maxTemperature;
- uint8_t iconId;
+ Icons iconId;
};
std::array<Day, MaxNbForecastDays> days;