Пример #1
0
void failed(int32_t cookie, int http_status, void* context) {
	if(cookie == 0 || cookie == WEATHER_HTTP_COOKIE) {
#ifndef ANTONIO
		weather_layer_set_icon(&weather_layer, WEATHER_ICON_NO_WEATHER);
		text_layer_set_text(&weather_layer.temp_layer, "---°   ");
#endif
	}
	
	link_monitor_handle_failure(http_status);
	
	//Re-request the location and subsequently weather on next minute tick
	located = false;
}
Пример #2
0
static void app_send_failed(DictionaryIterator* failed, AppMessageResult reason, void* context) {
	link_monitor_handle_failure(reason, &data);
	//display_counters(&calls_layer, data, 1);
	//display_counters(&sms_layer, data, 2);
}
Пример #3
0
void failed(int32_t cookie, int http_status, void* context) {
	
	/* This is triggered by invalid responses from the bridge on the phone,
	 * due to e.g. HTTP errors or phone disconnections.
	 */
	if(HTTP_INVALID_BRIDGE_RESPONSE) {
		
		// Phone can still be reached (assume HTTP error)
		if (http_time_request() == HTTP_OK) {
			
			/* Display 'cloud error' icon if:
			 * - HTTP error is noticed upon inital load
			 * - watch has recovered from a phone disconnection, but has no internet connection
			 */
			if (!has_temperature || phone_disconnected) {
				weather_layer_set_icon(&weather_layer, WEATHER_ICON_CLOUD_ERROR);
				phone_disconnected = false;
			}
			
			/* Assume that weather information is stale after 1 hour without a successful
			 * weather request. Indicate this by removing the degree symbol.			
			 */
			else if (has_timed_out || has_temperature || 
					 http_request_build_count > 0 || http_request_send_count > 0) {
				if (fail_count >= 60) {
					is_stale = true;
					weather_layer_set_temperature(&weather_layer, last_valid_temperature, is_stale);
				}
			}
		}
		else {
			
			/* Redundant check to make sure that HTTP time-outs are not triggering the
			 * 'phone error' icon. If appearing to be timed out after 1 hour without a
			 * successful weather request, indicate stale weather information by removing
			 * the degree symbol.
			 */
			if (fail_count >= 60 && has_timed_out && !phone_disconnected) {
				is_stale = true;
				weather_layer_set_temperature(&weather_layer, last_valid_temperature, is_stale);
			}
			
			/* Display 'phone error' icon if:
			 * - watch appears to be disconnected from phone
			 * - watch appears to be disconnected from bridge app on phone
			 *
			 * In case this is triggered by a HTTP time-out, subsequently send a 
			 * weather request for a possible quick re-connection.
			 */
			else {
				if (http_status==1008) {
					phone_disconnected = true;
					weather_layer_set_icon(&weather_layer, WEATHER_ICON_PHONE_ERROR);
					link_monitor_handle_failure(http_status);
				
					http_location_request();
					request_weather();
				}
			}
		}
	}
	
	// Remove temperature text 30 minutes after a phone/bridge app disconnection
	if (fail_count >= 30 && phone_disconnected) {
		text_layer_set_text(weather_layer.temp_layer, " ");
		has_temperature = false;
	}
	
	// Indicate failure and activate fail counter (see handle_tick() function)
	has_failed = true;
	
	// Re-request the location and subsequently weather on next minute tick
	located = false;
}