Skip to content

Commit 9e4f899

Browse files
committed
SimpleWeatherService: Generate random weather data on start
1 parent 71877a1 commit 9e4f899

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

sim/components/ble/SimpleWeatherService.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ SimpleWeatherService::SimpleWeatherService(const DateTime& dateTimeController) :
6666
}
6767

6868
void SimpleWeatherService::Init() {
69+
// Generate random weather data on every sim start
70+
auto now = dateTimeController.UTCDateTime().time_since_epoch().count();
71+
srand((int)now);
72+
int temp = (rand() % 81 - 40) * 100;
73+
int icon = rand() % 9;
74+
SimpleWeatherService::Location cityName;
75+
cityName[32] = '\0';
76+
currentWeather = SimpleWeatherService::CurrentWeather((uint64_t)now, temp, temp, temp, Icons(icon), std::move(cityName));
6977
//ble_gatts_count_cfg(serviceDefinition);
7078
//ble_gatts_add_svcs(serviceDefinition);
7179
}

0 commit comments

Comments
 (0)