SimpleWeatherService: Generate random weather data

Add a new simulation key handler for weather data:
- 'w' will generate new weather, cycling through the various conditions
- 'W' will clear the weather data
This commit is contained in:
Victor Kareh
2024-01-11 12:52:44 -05:00
parent 3ba07f574e
commit bb18300c9e
4 changed files with 32 additions and 0 deletions

View File

@@ -70,6 +70,13 @@ void SimpleWeatherService::Init() {
//ble_gatts_add_svcs(serviceDefinition);
}
void SimpleWeatherService::SetCurrentWeather(uint64_t timestamp, int16_t temperature, int iconId) {
SimpleWeatherService::Location cityName;
cityName[32] = '\0';
currentWeather = SimpleWeatherService::CurrentWeather((uint64_t)timestamp, temperature, temperature, temperature, SimpleWeatherService::Icons(iconId), std::move(cityName));
printf("currentWeather: timestamp=%d, temperature=%d, icon=%d\n", currentWeather->timestamp, currentWeather->temperature, currentWeather->iconId);
}
int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) {
return 0;

View File

@@ -27,6 +27,7 @@ public:
explicit SimpleWeatherService(const DateTime& dateTimeController);
void Init();
void SetCurrentWeather(uint64_t timestamp, int16_t temperature, int iconId);
int OnCommand(struct ble_gatt_access_ctxt* ctxt);