Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of weather and TZ for andorid #6

Open
wants to merge 2 commits into
base: watchface
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/Timely.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,18 @@ static void request_weather(void *data) {
layer_mark_dirty(weather_layer); // update UI element to indicate we're fetching weather...
DictionaryIterator *iter;
AppMessageResult result = app_message_outbox_begin(&iter);
if (iter == NULL) {
if (debug.general) { app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "iterator is null: %d", result); }
if (iter == NULL) { // This mean that message bug are busy now, so we could re-schedule task bit later
if (debug.general) { app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "iterator is null: %d", result); }
if (bluetooth_connected) { // Only if bluetooth still connected
if (weather.requests < 5) { // Not more that 5 times(5 tries in 10 seconds)
weather_request = app_timer_register(2000, &request_weather, NULL);
weather.requests++;
}
else { // If we tried five times and have no luck, will try in next minute tick
weather_request = NULL; // Allow check in next minute tick
weather.requests = 0; // Reset requestes counter
}
}
return;
}
if (dict_write_uint8(iter, AK_MESSAGE_TYPE, AK_REQUEST_WEATHER) != DICT_OK) {
Expand All @@ -1108,8 +1118,13 @@ static void request_timezone(void *data) {
AppMessageResult result = app_message_outbox_begin(&iter);
if (iter == NULL) {
if (debug.general) { app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "iterator is null: %d", result); }
return;

if (bluetooth_connected) { // Only if bluetooth still connected
weather_request = app_timer_register(2000, &request_weather, NULL); // we wil retry in two seconds later
}
return;
}

if (dict_write_uint8(iter, AK_MESSAGE_TYPE, AK_TIMEZONE_OFFSET) != DICT_OK) {
return;
}
Expand Down Expand Up @@ -1317,6 +1332,9 @@ static void handle_bluetooth(bool connected) {
timezone_request = app_timer_register(5000, &request_timezone, NULL); // give it time to settle...
if (debug.general) { app_log(APP_LOG_LEVEL_DEBUG, __FILE__, __LINE__, "timezone request timer queued"); }
}
if (weather.current == 999 && adv_settings.weather_update) {
if (weather_request == NULL) { weather_request = app_timer_register(7000, &request_weather, NULL); } // If we have no weather information, we should request it after TZ will be recieved
}
}
}
}
Expand Down