Skip to content

Commit

Permalink
SimpleWeatherService: Generate random weather data on start
Browse files Browse the repository at this point in the history
  • Loading branch information
vkareh committed Jan 11, 2024
1 parent 71877a1 commit 9e4f899
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sim/components/ble/SimpleWeatherService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ SimpleWeatherService::SimpleWeatherService(const DateTime& dateTimeController) :
}

void SimpleWeatherService::Init() {
// Generate random weather data on every sim start
auto now = dateTimeController.UTCDateTime().time_since_epoch().count();
srand((int)now);
int temp = (rand() % 81 - 40) * 100;
int icon = rand() % 9;
SimpleWeatherService::Location cityName;
cityName[32] = '\0';
currentWeather = SimpleWeatherService::CurrentWeather((uint64_t)now, temp, temp, temp, Icons(icon), std::move(cityName));
//ble_gatts_count_cfg(serviceDefinition);
//ble_gatts_add_svcs(serviceDefinition);
}
Expand Down

0 comments on commit 9e4f899

Please sign in to comment.