diff options
| author | FintasticMan <finlay.neon.kid@gmail.com> | 2024-10-09 12:04:53 +0200 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2024-11-04 21:22:38 +0100 |
| commit | f7c87a700d2d9cd05469f1b5b2966a01808ce0e1 (patch) | |
| tree | bac5094b51df022074ed30e584d8ea38ae23950b /src/components/ble/SimpleWeatherService.cpp | |
| parent | e247bd701903cc507ba0e0ac4f938ab4616562e7 (diff) | |
weather: Switch to std::optional for Forecast days
Also only iterate over the number of days actually in use, rather than
MaxNbForecastDays.
Diffstat (limited to 'src/components/ble/SimpleWeatherService.cpp')
| -rw-r--r-- | src/components/ble/SimpleWeatherService.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/components/ble/SimpleWeatherService.cpp b/src/components/ble/SimpleWeatherService.cpp index a58c3a76..51baf543 100644 --- a/src/components/ble/SimpleWeatherService.cpp +++ b/src/components/ble/SimpleWeatherService.cpp @@ -52,7 +52,7 @@ namespace { SimpleWeatherService::Forecast CreateForecast(const uint8_t* dataBuffer) { auto timestamp = static_cast<uint64_t>(ToUInt64(&dataBuffer[2])); - std::array<SimpleWeatherService::Forecast::Day, SimpleWeatherService::MaxNbForecastDays> days; + std::array<std::optional<SimpleWeatherService::Forecast::Day>, SimpleWeatherService::MaxNbForecastDays> days; const uint8_t nbDaysInBuffer = dataBuffer[10]; const uint8_t nbDays = std::min(SimpleWeatherService::MaxNbForecastDays, nbDaysInBuffer); for (int i = 0; i < nbDays; i++) { @@ -112,9 +112,9 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) { for (int i = 0; i < 5; i++) { NRF_LOG_INFO("\t[%d] Min: %d - Max : %d - Icon : %d", i, - forecast->days[i].minTemperature.PreciseCelsius(), - forecast->days[i].maxTemperature.PreciseCelsius(), - forecast->days[i].iconId); + forecast->days[i]->minTemperature.PreciseCelsius(), + forecast->days[i]->maxTemperature.PreciseCelsius(), + forecast->days[i]->iconId); } } break; |
