PebbleOS
Loading...
Searching...
No Matches
Modules | Data Structures | Macros | Typedefs | Functions
Weather

Weather forecasts sent by the phone. More...

Modules

 Weather app preferences
 Location ordering stored in the watch app preferences database.
 
 Weather types
 Weather conditions and their presentation.
 

Data Structures

struct  WeatherLocationForecast
 Forecast for one location, as sent by the phone. More...
 
struct  WeatherDataListNode
 List node holding the forecast of one location. More...
 

Macros

#define WEATHER_SERVICE_MAX_SHORT_PHRASE_BUFFER_SIZE   (32)
 Buffer size for a short weather phrase.
 
#define WEATHER_SERVICE_MAX_WEATHER_LOCATION_BUFFER_SIZE   (64)
 Buffer size for a location name.
 
#define WEATHER_SERVICE_INVALID_DATA_LAST_UPDATE_TIME   (0)
 Last update time marking an entry without valid data.
 
#define WEATHER_SERVICE_LOCATION_FORECAST_UNKNOWN_TEMP   (INT16_MAX)
 Temperature value meaning unknown.
 

Typedefs

typedef int WeatherLocationID
 Index of a weather location in the user's ordering.
 

Functions

void weather_service_init (void)
 Initialize the weather service.
 
WeatherLocationForecast * weather_service_create_default_forecast (void)
 Get a copy of the default location's forecast.
 
void weather_service_destroy_default_forecast (WeatherLocationForecast *forecast)
 Free a forecast created by weather_service_create_default_forecast().
 
WeatherDataListNode * weather_service_locations_list_create (size_t *count_out)
 Build a list of the forecasts of all valid locations.
 
WeatherDataListNode * weather_service_locations_list_get_location_at_index (WeatherDataListNode *head, unsigned int index)
 Get the list node at an index.
 
void weather_service_locations_list_destroy (WeatherDataListNode *head)
 Free a list created by weather_service_locations_list_create().
 
bool weather_service_supported_by_phone (void)
 Check whether the connected phone app supports weather.
 

Detailed Description

Weather forecasts sent by the phone.

Forecast and location data is pushed from the phone into the weather database; the watch never requests it. Locations are ordered by the weather app preferences, the first one being the default location. Entries last updated before yesterday are ignored. Subscribe to PEBBLE_WEATHER_CHANGED_EVENT to learn about database changes.

if (forecast) {
PBL_LOG_DBG("%d degrees", forecast->current_temp);
}
#define PBL_LOG_DBG(fmt,...)
Log a routine debug message, possibly queued.
Definition logging.h:570
int current_temp
Current temperature.
Definition weather_service.h:52
Forecast for one location, as sent by the phone.
Definition weather_service.h:46
WeatherLocationForecast * weather_service_create_default_forecast(void)
Get a copy of the default location's forecast.
void weather_service_destroy_default_forecast(WeatherLocationForecast *forecast)
Free a forecast created by weather_service_create_default_forecast().

Data Structure Documentation

◆ WeatherLocationForecast

struct WeatherLocationForecast

Forecast for one location, as sent by the phone.

Data Fields
int current_temp Current temperature.
char * current_weather_phrase Short description of the current conditions, owned by the forecast.
WeatherType current_weather_type Current conditions.
bool is_current_location Whether this is the phone's current location.
char * location_name Location name, owned by the forecast.
time_t time_updated_utc Time the forecast was last updated, UTC.
int today_high Today's high temperature.
int today_low Today's low temperature.
int tomorrow_high Tomorrow's high temperature.
int tomorrow_low Tomorrow's low temperature.
WeatherType tomorrow_weather_type Tomorrow's conditions.

◆ WeatherDataListNode

struct WeatherDataListNode

List node holding the forecast of one location.

Data Fields
WeatherLocationForecast forecast Forecast of the location.
WeatherLocationID id Position of the location in the user's ordering.
ListNode node List linkage.

Macro Definition Documentation

◆ WEATHER_SERVICE_INVALID_DATA_LAST_UPDATE_TIME

#define WEATHER_SERVICE_INVALID_DATA_LAST_UPDATE_TIME   (0)

Last update time marking an entry without valid data.

◆ WEATHER_SERVICE_LOCATION_FORECAST_UNKNOWN_TEMP

#define WEATHER_SERVICE_LOCATION_FORECAST_UNKNOWN_TEMP   (INT16_MAX)

Temperature value meaning unknown.

◆ WEATHER_SERVICE_MAX_SHORT_PHRASE_BUFFER_SIZE

#define WEATHER_SERVICE_MAX_SHORT_PHRASE_BUFFER_SIZE   (32)

Buffer size for a short weather phrase.

◆ WEATHER_SERVICE_MAX_WEATHER_LOCATION_BUFFER_SIZE

#define WEATHER_SERVICE_MAX_WEATHER_LOCATION_BUFFER_SIZE   (64)

Buffer size for a location name.

Typedef Documentation

◆ WeatherLocationID

typedef int WeatherLocationID

Index of a weather location in the user's ordering.

Function Documentation

◆ weather_service_create_default_forecast()

WeatherLocationForecast * weather_service_create_default_forecast ( void  )

Get a copy of the default location's forecast.

Returns
Forecast allocated on the caller's task heap, to be freed with weather_service_destroy_default_forecast(), or NULL if none is available.

◆ weather_service_destroy_default_forecast()

void weather_service_destroy_default_forecast ( WeatherLocationForecast *  forecast)

Free a forecast created by weather_service_create_default_forecast().

Parameters
forecastForecast to free, may be NULL.

◆ weather_service_init()

void weather_service_init ( void  )

Initialize the weather service.

Caches the default location's forecast and keeps it up to date on database changes.

◆ weather_service_locations_list_create()

WeatherDataListNode * weather_service_locations_list_create ( size_t *  count_out)

Build a list of the forecasts of all valid locations.

The list is sorted by WeatherDataListNode::id. Locations missing from the user's ordering or with invalid or outdated data are skipped.

Parameters
[out]count_outNumber of locations in the list. Left untouched if the location ordering is unavailable.
Returns
Head of the list, to be freed with weather_service_locations_list_destroy(). May be NULL.

◆ weather_service_locations_list_destroy()

void weather_service_locations_list_destroy ( WeatherDataListNode *  head)

Free a list created by weather_service_locations_list_create().

Parameters
headHead of the list, may be NULL.

◆ weather_service_locations_list_get_location_at_index()

WeatherDataListNode * weather_service_locations_list_get_location_at_index ( WeatherDataListNode *  head,
unsigned int  index 
)

Get the list node at an index.

Parameters
headHead of a list from weather_service_locations_list_create().
indexIndex of the node.
Returns
Node at index, or NULL if out of range.

◆ weather_service_supported_by_phone()

bool weather_service_supported_by_phone ( void  )

Check whether the connected phone app supports weather.

Always true on QEMU.

Returns
true if the phone reported weather support.