@@ -77,6 +77,13 @@ void SimpleWeatherService::SetCurrentWeather(uint64_t timestamp, int16_t tempera
7777 printf (" currentWeather: timestamp=%d, temperature=%d, icon=%d\n " , currentWeather->timestamp , currentWeather->temperature , currentWeather->iconId );
7878}
7979
80+ void SimpleWeatherService::SetForecast (uint64_t timestamp, std::array<SimpleWeatherService::Forecast::Day, SimpleWeatherService::MaxNbForecastDays> days) {
81+ forecast = SimpleWeatherService::Forecast {timestamp, SimpleWeatherService::MaxNbForecastDays, days};
82+ for (int i = 0 ; i < SimpleWeatherService::MaxNbForecastDays; i++) {
83+ printf (" forecast: day=%d. min=%d, max=%d icon=%d\n " , i, days[i].minTemperature , days[i].maxTemperature , days[i].iconId );
84+ }
85+ }
86+
8087int SimpleWeatherService::OnCommand (struct ble_gatt_access_ctxt * ctxt) {
8188
8289 return 0 ;
@@ -115,3 +122,17 @@ bool SimpleWeatherService::CurrentWeather::operator==(const SimpleWeatherService
115122 this ->maxTemperature == other.maxTemperature && this ->minTemperature == other.maxTemperature &&
116123 std::strcmp (this ->location .data (), other.location .data ()) == 0 ;
117124}
125+
126+ bool SimpleWeatherService::Forecast::Day::operator ==(const SimpleWeatherService::Forecast::Day& other) const {
127+ return this ->iconId == other.iconId &&
128+ this ->maxTemperature == other.maxTemperature && this ->minTemperature == other.maxTemperature ;
129+ }
130+
131+ bool SimpleWeatherService::Forecast::operator ==(const SimpleWeatherService::Forecast& other) const {
132+ for (int i = 0 ; i < this ->nbDays ; i++) {
133+ if (this ->days [i] != other.days [i]) {
134+ return false ;
135+ }
136+ }
137+ return this ->timestamp == other.timestamp && this ->nbDays == other.nbDays ;
138+ }
0 commit comments